diff options
Diffstat (limited to 'docs/sqlglot/generator.html')
-rw-r--r-- | docs/sqlglot/generator.html | 15627 |
1 files changed, 7894 insertions, 7733 deletions
diff --git a/docs/sqlglot/generator.html b/docs/sqlglot/generator.html index e560028..98ec9d8 100644 --- a/docs/sqlglot/generator.html +++ b/docs/sqlglot/generator.html @@ -3,7 +3,7 @@ <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> - <meta name="generator" content="pdoc 14.1.0"/> + <meta name="generator" content="pdoc 14.2.0"/> <title>sqlglot.generator API documentation</title> <style>/*! * Bootstrap Reboot v5.0.0 (https://getbootstrap.com/) * Copyright 2011-2021 The Bootstrap Authors * Copyright 2011-2021 Twitter, Inc. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * Forked from Normalize.css, licensed MIT (https://github.com/necolas/normalize.css/blob/master/LICENSE.md) */*,::after,::before{box-sizing:border-box}@media (prefers-reduced-motion:no-preference){:root{scroll-behavior:smooth}}body{margin:0;font-family:system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans","Liberation Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";font-size:1rem;font-weight:400;line-height:1.5;color:#212529;background-color:#fff;-webkit-text-size-adjust:100%;-webkit-tap-highlight-color:transparent}hr{margin:1rem 0;color:inherit;background-color:currentColor;border:0;opacity:.25}hr:not([size]){height:1px}h1,h2,h3,h4,h5,h6{margin-top:0;margin-bottom:.5rem;font-weight:500;line-height:1.2}h1{font-size:calc(1.375rem + 1.5vw)}@media (min-width:1200px){h1{font-size:2.5rem}}h2{font-size:calc(1.325rem + .9vw)}@media (min-width:1200px){h2{font-size:2rem}}h3{font-size:calc(1.3rem + .6vw)}@media (min-width:1200px){h3{font-size:1.75rem}}h4{font-size:calc(1.275rem + .3vw)}@media (min-width:1200px){h4{font-size:1.5rem}}h5{font-size:1.25rem}h6{font-size:1rem}p{margin-top:0;margin-bottom:1rem}abbr[data-bs-original-title],abbr[title]{-webkit-text-decoration:underline dotted;text-decoration:underline dotted;cursor:help;-webkit-text-decoration-skip-ink:none;text-decoration-skip-ink:none}address{margin-bottom:1rem;font-style:normal;line-height:inherit}ol,ul{padding-left:2rem}dl,ol,ul{margin-top:0;margin-bottom:1rem}ol ol,ol ul,ul ol,ul ul{margin-bottom:0}dt{font-weight:700}dd{margin-bottom:.5rem;margin-left:0}blockquote{margin:0 0 1rem}b,strong{font-weight:bolder}small{font-size:.875em}mark{padding:.2em;background-color:#fcf8e3}sub,sup{position:relative;font-size:.75em;line-height:0;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}a{color:#0d6efd;text-decoration:underline}a:hover{color:#0a58ca}a:not([href]):not([class]),a:not([href]):not([class]):hover{color:inherit;text-decoration:none}code,kbd,pre,samp{font-family:SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;font-size:1em;direction:ltr;unicode-bidi:bidi-override}pre{display:block;margin-top:0;margin-bottom:1rem;overflow:auto;font-size:.875em}pre code{font-size:inherit;color:inherit;word-break:normal}code{font-size:.875em;color:#d63384;word-wrap:break-word}a>code{color:inherit}kbd{padding:.2rem .4rem;font-size:.875em;color:#fff;background-color:#212529;border-radius:.2rem}kbd kbd{padding:0;font-size:1em;font-weight:700}figure{margin:0 0 1rem}img,svg{vertical-align:middle}table{caption-side:bottom;border-collapse:collapse}caption{padding-top:.5rem;padding-bottom:.5rem;color:#6c757d;text-align:left}th{text-align:inherit;text-align:-webkit-match-parent}tbody,td,tfoot,th,thead,tr{border-color:inherit;border-style:solid;border-width:0}label{display:inline-block}button{border-radius:0}button:focus:not(:focus-visible){outline:0}button,input,optgroup,select,textarea{margin:0;font-family:inherit;font-size:inherit;line-height:inherit}button,select{text-transform:none}[role=button]{cursor:pointer}select{word-wrap:normal}select:disabled{opacity:1}[list]::-webkit-calendar-picker-indicator{display:none}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button}[type=button]:not(:disabled),[type=reset]:not(:disabled),[type=submit]:not(:disabled),button:not(:disabled){cursor:pointer}::-moz-focus-inner{padding:0;border-style:none}textarea{resize:vertical}fieldset{min-width:0;padding:0;margin:0;border:0}legend{float:left;width:100%;padding:0;margin-bottom:.5rem;font-size:calc(1.275rem + .3vw);line-height:inherit}@media (min-width:1200px){legend{font-size:1.5rem}}legend+*{clear:left}::-webkit-datetime-edit-day-field,::-webkit-datetime-edit-fields-wrapper,::-webkit-datetime-edit-hour-field,::-webkit-datetime-edit-minute,::-webkit-datetime-edit-month-field,::-webkit-datetime-edit-text,::-webkit-datetime-edit-year-field{padding:0}::-webkit-inner-spin-button{height:auto}[type=search]{outline-offset:-2px;-webkit-appearance:textfield}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-color-swatch-wrapper{padding:0}::file-selector-button{font:inherit}::-webkit-file-upload-button{font:inherit;-webkit-appearance:button}output{display:inline-block}iframe{border:0}summary{display:list-item;cursor:pointer}progress{vertical-align:baseline}[hidden]{display:none!important}</style> @@ -163,6 +163,9 @@ <a class="variable" href="#Generator.CTE_RECURSIVE_KEYWORD_REQUIRED">CTE_RECURSIVE_KEYWORD_REQUIRED</a> </li> <li> + <a class="variable" href="#Generator.SUPPORTS_SINGLE_ARG_CONCAT">SUPPORTS_SINGLE_ARG_CONCAT</a> + </li> + <li> <a class="variable" href="#Generator.TYPE_MAPPING">TYPE_MAPPING</a> </li> <li> @@ -508,6 +511,9 @@ <a class="function" href="#Generator.indextablehint_sql">indextablehint_sql</a> </li> <li> + <a class="function" href="#Generator.historicaldata_sql">historicaldata_sql</a> + </li> + <li> <a class="function" href="#Generator.table_sql">table_sql</a> </li> <li> @@ -703,9 +709,15 @@ <a class="function" href="#Generator.trim_sql">trim_sql</a> </li> <li> + <a class="function" href="#Generator.convert_concat_args">convert_concat_args</a> + </li> + <li> <a class="function" href="#Generator.concat_sql">concat_sql</a> </li> <li> + <a class="function" href="#Generator.concatws_sql">concatws_sql</a> + </li> + <li> <a class="function" href="#Generator.check_sql">check_sql</a> </li> <li> @@ -1327,2809 +1339,2842 @@ </span><span id="L-228"><a href="#L-228"><span class="linenos"> 228</span></a> <span class="c1"># Whether or not the "RECURSIVE" keyword is required when defining recursive CTEs</span> </span><span id="L-229"><a href="#L-229"><span class="linenos"> 229</span></a> <span class="n">CTE_RECURSIVE_KEYWORD_REQUIRED</span> <span class="o">=</span> <span class="kc">True</span> </span><span id="L-230"><a href="#L-230"><span class="linenos"> 230</span></a> -</span><span id="L-231"><a href="#L-231"><span class="linenos"> 231</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-232"><a href="#L-232"><span class="linenos"> 232</span></a> <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">NCHAR</span><span class="p">:</span> <span class="s2">"CHAR"</span><span class="p">,</span> -</span><span id="L-233"><a href="#L-233"><span class="linenos"> 233</span></a> <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">NVARCHAR</span><span class="p">:</span> <span class="s2">"VARCHAR"</span><span class="p">,</span> -</span><span id="L-234"><a href="#L-234"><span class="linenos"> 234</span></a> <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">MEDIUMTEXT</span><span class="p">:</span> <span class="s2">"TEXT"</span><span class="p">,</span> -</span><span id="L-235"><a href="#L-235"><span class="linenos"> 235</span></a> <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">LONGTEXT</span><span class="p">:</span> <span class="s2">"TEXT"</span><span class="p">,</span> -</span><span id="L-236"><a href="#L-236"><span class="linenos"> 236</span></a> <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">TINYTEXT</span><span class="p">:</span> <span class="s2">"TEXT"</span><span class="p">,</span> -</span><span id="L-237"><a href="#L-237"><span class="linenos"> 237</span></a> <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">MEDIUMBLOB</span><span class="p">:</span> <span class="s2">"BLOB"</span><span class="p">,</span> -</span><span id="L-238"><a href="#L-238"><span class="linenos"> 238</span></a> <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">LONGBLOB</span><span class="p">:</span> <span class="s2">"BLOB"</span><span class="p">,</span> -</span><span id="L-239"><a href="#L-239"><span class="linenos"> 239</span></a> <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">TINYBLOB</span><span class="p">:</span> <span class="s2">"BLOB"</span><span class="p">,</span> -</span><span id="L-240"><a href="#L-240"><span class="linenos"> 240</span></a> <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">INET</span><span class="p">:</span> <span class="s2">"INET"</span><span class="p">,</span> -</span><span id="L-241"><a href="#L-241"><span class="linenos"> 241</span></a> <span class="p">}</span> -</span><span id="L-242"><a href="#L-242"><span class="linenos"> 242</span></a> -</span><span id="L-243"><a href="#L-243"><span class="linenos"> 243</span></a> <span class="n">STAR_MAPPING</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-244"><a href="#L-244"><span class="linenos"> 244</span></a> <span class="s2">"except"</span><span class="p">:</span> <span class="s2">"EXCEPT"</span><span class="p">,</span> -</span><span id="L-245"><a href="#L-245"><span class="linenos"> 245</span></a> <span class="s2">"replace"</span><span class="p">:</span> <span class="s2">"REPLACE"</span><span class="p">,</span> -</span><span id="L-246"><a href="#L-246"><span class="linenos"> 246</span></a> <span class="p">}</span> -</span><span id="L-247"><a href="#L-247"><span class="linenos"> 247</span></a> -</span><span id="L-248"><a href="#L-248"><span class="linenos"> 248</span></a> <span class="n">TIME_PART_SINGULARS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-249"><a href="#L-249"><span class="linenos"> 249</span></a> <span class="s2">"microseconds"</span><span class="p">:</span> <span class="s2">"microsecond"</span><span class="p">,</span> -</span><span id="L-250"><a href="#L-250"><span class="linenos"> 250</span></a> <span class="s2">"seconds"</span><span class="p">:</span> <span class="s2">"second"</span><span class="p">,</span> -</span><span id="L-251"><a href="#L-251"><span class="linenos"> 251</span></a> <span class="s2">"minutes"</span><span class="p">:</span> <span class="s2">"minute"</span><span class="p">,</span> -</span><span id="L-252"><a href="#L-252"><span class="linenos"> 252</span></a> <span class="s2">"hours"</span><span class="p">:</span> <span class="s2">"hour"</span><span class="p">,</span> -</span><span id="L-253"><a href="#L-253"><span class="linenos"> 253</span></a> <span class="s2">"days"</span><span class="p">:</span> <span class="s2">"day"</span><span class="p">,</span> -</span><span id="L-254"><a href="#L-254"><span class="linenos"> 254</span></a> <span class="s2">"weeks"</span><span class="p">:</span> <span class="s2">"week"</span><span class="p">,</span> -</span><span id="L-255"><a href="#L-255"><span class="linenos"> 255</span></a> <span class="s2">"months"</span><span class="p">:</span> <span class="s2">"month"</span><span class="p">,</span> -</span><span id="L-256"><a href="#L-256"><span class="linenos"> 256</span></a> <span class="s2">"quarters"</span><span class="p">:</span> <span class="s2">"quarter"</span><span class="p">,</span> -</span><span id="L-257"><a href="#L-257"><span class="linenos"> 257</span></a> <span class="s2">"years"</span><span class="p">:</span> <span class="s2">"year"</span><span class="p">,</span> -</span><span id="L-258"><a href="#L-258"><span class="linenos"> 258</span></a> <span class="p">}</span> -</span><span id="L-259"><a href="#L-259"><span class="linenos"> 259</span></a> -</span><span id="L-260"><a href="#L-260"><span class="linenos"> 260</span></a> <span class="n">TOKEN_MAPPING</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="n">TokenType</span><span class="p">,</span> <span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> -</span><span id="L-261"><a href="#L-261"><span class="linenos"> 261</span></a> -</span><span id="L-262"><a href="#L-262"><span class="linenos"> 262</span></a> <span class="n">STRUCT_DELIMITER</span> <span class="o">=</span> <span class="p">(</span><span class="s2">"<"</span><span class="p">,</span> <span class="s2">">"</span><span class="p">)</span> -</span><span id="L-263"><a href="#L-263"><span class="linenos"> 263</span></a> -</span><span id="L-264"><a href="#L-264"><span class="linenos"> 264</span></a> <span class="n">PARAMETER_TOKEN</span> <span class="o">=</span> <span class="s2">"@"</span> -</span><span id="L-265"><a href="#L-265"><span class="linenos"> 265</span></a> -</span><span id="L-266"><a href="#L-266"><span class="linenos"> 266</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-267"><a href="#L-267"><span class="linenos"> 267</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">AlgorithmProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">,</span> -</span><span id="L-268"><a href="#L-268"><span class="linenos"> 268</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">AutoIncrementProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="L-269"><a href="#L-269"><span class="linenos"> 269</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BlockCompressionProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> -</span><span id="L-270"><a href="#L-270"><span class="linenos"> 270</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CharacterSetProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="L-271"><a href="#L-271"><span class="linenos"> 271</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ChecksumProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> -</span><span id="L-272"><a href="#L-272"><span class="linenos"> 272</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CollateProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="L-273"><a href="#L-273"><span class="linenos"> 273</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CopyGrantsProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="L-274"><a href="#L-274"><span class="linenos"> 274</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Cluster</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="L-275"><a href="#L-275"><span class="linenos"> 275</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ClusteredByProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="L-276"><a href="#L-276"><span class="linenos"> 276</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataBlocksizeProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> -</span><span id="L-277"><a href="#L-277"><span class="linenos"> 277</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DefinerProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">,</span> -</span><span id="L-278"><a href="#L-278"><span class="linenos"> 278</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DictRange</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="L-279"><a href="#L-279"><span class="linenos"> 279</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DictProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="L-280"><a href="#L-280"><span class="linenos"> 280</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DistKeyProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="L-281"><a href="#L-281"><span class="linenos"> 281</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DistStyleProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="L-282"><a href="#L-282"><span class="linenos"> 282</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">EngineProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="L-283"><a href="#L-283"><span class="linenos"> 283</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ExecuteAsProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="L-284"><a href="#L-284"><span class="linenos"> 284</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ExternalProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">,</span> -</span><span id="L-285"><a href="#L-285"><span class="linenos"> 285</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FallbackProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> -</span><span id="L-286"><a href="#L-286"><span class="linenos"> 286</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FileFormatProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">,</span> -</span><span id="L-287"><a href="#L-287"><span class="linenos"> 287</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FreespaceProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> -</span><span id="L-288"><a href="#L-288"><span class="linenos"> 288</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">HeapProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">,</span> -</span><span id="L-289"><a href="#L-289"><span class="linenos"> 289</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">InputModelProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="L-290"><a href="#L-290"><span class="linenos"> 290</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">IsolatedLoadingProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> -</span><span id="L-291"><a href="#L-291"><span class="linenos"> 291</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JournalProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> -</span><span id="L-292"><a href="#L-292"><span class="linenos"> 292</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LanguageProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="L-293"><a href="#L-293"><span class="linenos"> 293</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LikeProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="L-294"><a href="#L-294"><span class="linenos"> 294</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LocationProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="L-295"><a href="#L-295"><span class="linenos"> 295</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LockingProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_ALIAS</span><span class="p">,</span> -</span><span id="L-296"><a href="#L-296"><span class="linenos"> 296</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LogProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> -</span><span id="L-297"><a href="#L-297"><span class="linenos"> 297</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MaterializedProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">,</span> -</span><span id="L-298"><a href="#L-298"><span class="linenos"> 298</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MergeBlockRatioProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> -</span><span id="L-299"><a href="#L-299"><span class="linenos"> 299</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">NoPrimaryIndexProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_EXPRESSION</span><span class="p">,</span> -</span><span id="L-300"><a href="#L-300"><span class="linenos"> 300</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">OnProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="L-301"><a href="#L-301"><span class="linenos"> 301</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">OnCommitProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_EXPRESSION</span><span class="p">,</span> -</span><span id="L-302"><a href="#L-302"><span class="linenos"> 302</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Order</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="L-303"><a href="#L-303"><span class="linenos"> 303</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">OutputModelProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="L-304"><a href="#L-304"><span class="linenos"> 304</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionedByProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">,</span> -</span><span id="L-305"><a href="#L-305"><span class="linenos"> 305</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionedOfProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="L-306"><a href="#L-306"><span class="linenos"> 306</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PrimaryKey</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="L-307"><a href="#L-307"><span class="linenos"> 307</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Property</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">,</span> -</span><span id="L-308"><a href="#L-308"><span class="linenos"> 308</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RemoteWithConnectionModelProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="L-309"><a href="#L-309"><span class="linenos"> 309</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ReturnsProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="L-310"><a href="#L-310"><span class="linenos"> 310</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RowFormatProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="L-311"><a href="#L-311"><span class="linenos"> 311</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RowFormatDelimitedProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="L-312"><a href="#L-312"><span class="linenos"> 312</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RowFormatSerdeProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="L-313"><a href="#L-313"><span class="linenos"> 313</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SampleProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="L-314"><a href="#L-314"><span class="linenos"> 314</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SchemaCommentProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="L-315"><a href="#L-315"><span class="linenos"> 315</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SerdeProperties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="L-316"><a href="#L-316"><span class="linenos"> 316</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Set</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="L-317"><a href="#L-317"><span class="linenos"> 317</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SettingsProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="L-318"><a href="#L-318"><span class="linenos"> 318</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SetProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">,</span> -</span><span id="L-319"><a href="#L-319"><span class="linenos"> 319</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SortKeyProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="L-320"><a href="#L-320"><span class="linenos"> 320</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SqlSecurityProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">,</span> -</span><span id="L-321"><a href="#L-321"><span class="linenos"> 321</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StabilityProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="L-322"><a href="#L-322"><span class="linenos"> 322</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TemporaryProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">,</span> -</span><span id="L-323"><a href="#L-323"><span class="linenos"> 323</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ToTableProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="L-324"><a href="#L-324"><span class="linenos"> 324</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TransientProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">,</span> -</span><span id="L-325"><a href="#L-325"><span class="linenos"> 325</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TransformModelProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="L-326"><a href="#L-326"><span class="linenos"> 326</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MergeTreeTTL</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="L-327"><a href="#L-327"><span class="linenos"> 327</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VolatileProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">,</span> -</span><span id="L-328"><a href="#L-328"><span class="linenos"> 328</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">WithDataProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_EXPRESSION</span><span class="p">,</span> -</span><span id="L-329"><a href="#L-329"><span class="linenos"> 329</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">WithJournalTableProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> -</span><span id="L-330"><a href="#L-330"><span class="linenos"> 330</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">WithSystemVersioningProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="L-331"><a href="#L-331"><span class="linenos"> 331</span></a> <span class="p">}</span> -</span><span id="L-332"><a href="#L-332"><span class="linenos"> 332</span></a> -</span><span id="L-333"><a href="#L-333"><span class="linenos"> 333</span></a> <span class="c1"># Keywords that can't be used as unquoted identifier names</span> -</span><span id="L-334"><a href="#L-334"><span class="linenos"> 334</span></a> <span class="n">RESERVED_KEYWORDS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Set</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="nb">set</span><span class="p">()</span> +</span><span id="L-231"><a href="#L-231"><span class="linenos"> 231</span></a> <span class="c1"># Whether or not CONCAT requires >1 arguments</span> +</span><span id="L-232"><a href="#L-232"><span class="linenos"> 232</span></a> <span class="n">SUPPORTS_SINGLE_ARG_CONCAT</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-233"><a href="#L-233"><span class="linenos"> 233</span></a> +</span><span id="L-234"><a href="#L-234"><span class="linenos"> 234</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-235"><a href="#L-235"><span class="linenos"> 235</span></a> <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">NCHAR</span><span class="p">:</span> <span class="s2">"CHAR"</span><span class="p">,</span> +</span><span id="L-236"><a href="#L-236"><span class="linenos"> 236</span></a> <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">NVARCHAR</span><span class="p">:</span> <span class="s2">"VARCHAR"</span><span class="p">,</span> +</span><span id="L-237"><a href="#L-237"><span class="linenos"> 237</span></a> <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">MEDIUMTEXT</span><span class="p">:</span> <span class="s2">"TEXT"</span><span class="p">,</span> +</span><span id="L-238"><a href="#L-238"><span class="linenos"> 238</span></a> <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">LONGTEXT</span><span class="p">:</span> <span class="s2">"TEXT"</span><span class="p">,</span> +</span><span id="L-239"><a href="#L-239"><span class="linenos"> 239</span></a> <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">TINYTEXT</span><span class="p">:</span> <span class="s2">"TEXT"</span><span class="p">,</span> +</span><span id="L-240"><a href="#L-240"><span class="linenos"> 240</span></a> <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">MEDIUMBLOB</span><span class="p">:</span> <span class="s2">"BLOB"</span><span class="p">,</span> +</span><span id="L-241"><a href="#L-241"><span class="linenos"> 241</span></a> <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">LONGBLOB</span><span class="p">:</span> <span class="s2">"BLOB"</span><span class="p">,</span> +</span><span id="L-242"><a href="#L-242"><span class="linenos"> 242</span></a> <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">TINYBLOB</span><span class="p">:</span> <span class="s2">"BLOB"</span><span class="p">,</span> +</span><span id="L-243"><a href="#L-243"><span class="linenos"> 243</span></a> <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">INET</span><span class="p">:</span> <span class="s2">"INET"</span><span class="p">,</span> +</span><span id="L-244"><a href="#L-244"><span class="linenos"> 244</span></a> <span class="p">}</span> +</span><span id="L-245"><a href="#L-245"><span class="linenos"> 245</span></a> +</span><span id="L-246"><a href="#L-246"><span class="linenos"> 246</span></a> <span class="n">STAR_MAPPING</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-247"><a href="#L-247"><span class="linenos"> 247</span></a> <span class="s2">"except"</span><span class="p">:</span> <span class="s2">"EXCEPT"</span><span class="p">,</span> +</span><span id="L-248"><a href="#L-248"><span class="linenos"> 248</span></a> <span class="s2">"replace"</span><span class="p">:</span> <span class="s2">"REPLACE"</span><span class="p">,</span> +</span><span id="L-249"><a href="#L-249"><span class="linenos"> 249</span></a> <span class="p">}</span> +</span><span id="L-250"><a href="#L-250"><span class="linenos"> 250</span></a> +</span><span id="L-251"><a href="#L-251"><span class="linenos"> 251</span></a> <span class="n">TIME_PART_SINGULARS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-252"><a href="#L-252"><span class="linenos"> 252</span></a> <span class="s2">"microseconds"</span><span class="p">:</span> <span class="s2">"microsecond"</span><span class="p">,</span> +</span><span id="L-253"><a href="#L-253"><span class="linenos"> 253</span></a> <span class="s2">"seconds"</span><span class="p">:</span> <span class="s2">"second"</span><span class="p">,</span> +</span><span id="L-254"><a href="#L-254"><span class="linenos"> 254</span></a> <span class="s2">"minutes"</span><span class="p">:</span> <span class="s2">"minute"</span><span class="p">,</span> +</span><span id="L-255"><a href="#L-255"><span class="linenos"> 255</span></a> <span class="s2">"hours"</span><span class="p">:</span> <span class="s2">"hour"</span><span class="p">,</span> +</span><span id="L-256"><a href="#L-256"><span class="linenos"> 256</span></a> <span class="s2">"days"</span><span class="p">:</span> <span class="s2">"day"</span><span class="p">,</span> +</span><span id="L-257"><a href="#L-257"><span class="linenos"> 257</span></a> <span class="s2">"weeks"</span><span class="p">:</span> <span class="s2">"week"</span><span class="p">,</span> +</span><span id="L-258"><a href="#L-258"><span class="linenos"> 258</span></a> <span class="s2">"months"</span><span class="p">:</span> <span class="s2">"month"</span><span class="p">,</span> +</span><span id="L-259"><a href="#L-259"><span class="linenos"> 259</span></a> <span class="s2">"quarters"</span><span class="p">:</span> <span class="s2">"quarter"</span><span class="p">,</span> +</span><span id="L-260"><a href="#L-260"><span class="linenos"> 260</span></a> <span class="s2">"years"</span><span class="p">:</span> <span class="s2">"year"</span><span class="p">,</span> +</span><span id="L-261"><a href="#L-261"><span class="linenos"> 261</span></a> <span class="p">}</span> +</span><span id="L-262"><a href="#L-262"><span class="linenos"> 262</span></a> +</span><span id="L-263"><a href="#L-263"><span class="linenos"> 263</span></a> <span class="n">TOKEN_MAPPING</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="n">TokenType</span><span class="p">,</span> <span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> +</span><span id="L-264"><a href="#L-264"><span class="linenos"> 264</span></a> +</span><span id="L-265"><a href="#L-265"><span class="linenos"> 265</span></a> <span class="n">STRUCT_DELIMITER</span> <span class="o">=</span> <span class="p">(</span><span class="s2">"<"</span><span class="p">,</span> <span class="s2">">"</span><span class="p">)</span> +</span><span id="L-266"><a href="#L-266"><span class="linenos"> 266</span></a> +</span><span id="L-267"><a href="#L-267"><span class="linenos"> 267</span></a> <span class="n">PARAMETER_TOKEN</span> <span class="o">=</span> <span class="s2">"@"</span> +</span><span id="L-268"><a href="#L-268"><span class="linenos"> 268</span></a> +</span><span id="L-269"><a href="#L-269"><span class="linenos"> 269</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-270"><a href="#L-270"><span class="linenos"> 270</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">AlgorithmProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">,</span> +</span><span id="L-271"><a href="#L-271"><span class="linenos"> 271</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">AutoIncrementProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="L-272"><a href="#L-272"><span class="linenos"> 272</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BlockCompressionProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> +</span><span id="L-273"><a href="#L-273"><span class="linenos"> 273</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CharacterSetProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="L-274"><a href="#L-274"><span class="linenos"> 274</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ChecksumProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> +</span><span id="L-275"><a href="#L-275"><span class="linenos"> 275</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CollateProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="L-276"><a href="#L-276"><span class="linenos"> 276</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CopyGrantsProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="L-277"><a href="#L-277"><span class="linenos"> 277</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Cluster</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="L-278"><a href="#L-278"><span class="linenos"> 278</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ClusteredByProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="L-279"><a href="#L-279"><span class="linenos"> 279</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataBlocksizeProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> +</span><span id="L-280"><a href="#L-280"><span class="linenos"> 280</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DefinerProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">,</span> +</span><span id="L-281"><a href="#L-281"><span class="linenos"> 281</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DictRange</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="L-282"><a href="#L-282"><span class="linenos"> 282</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DictProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="L-283"><a href="#L-283"><span class="linenos"> 283</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DistKeyProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="L-284"><a href="#L-284"><span class="linenos"> 284</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DistStyleProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="L-285"><a href="#L-285"><span class="linenos"> 285</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">EngineProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="L-286"><a href="#L-286"><span class="linenos"> 286</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ExecuteAsProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="L-287"><a href="#L-287"><span class="linenos"> 287</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ExternalProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">,</span> +</span><span id="L-288"><a href="#L-288"><span class="linenos"> 288</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FallbackProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> +</span><span id="L-289"><a href="#L-289"><span class="linenos"> 289</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FileFormatProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">,</span> +</span><span id="L-290"><a href="#L-290"><span class="linenos"> 290</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FreespaceProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> +</span><span id="L-291"><a href="#L-291"><span class="linenos"> 291</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">HeapProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">,</span> +</span><span id="L-292"><a href="#L-292"><span class="linenos"> 292</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">InputModelProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="L-293"><a href="#L-293"><span class="linenos"> 293</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">IsolatedLoadingProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> +</span><span id="L-294"><a href="#L-294"><span class="linenos"> 294</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JournalProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> +</span><span id="L-295"><a href="#L-295"><span class="linenos"> 295</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LanguageProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="L-296"><a href="#L-296"><span class="linenos"> 296</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LikeProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="L-297"><a href="#L-297"><span class="linenos"> 297</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LocationProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="L-298"><a href="#L-298"><span class="linenos"> 298</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LockingProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_ALIAS</span><span class="p">,</span> +</span><span id="L-299"><a href="#L-299"><span class="linenos"> 299</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LogProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> +</span><span id="L-300"><a href="#L-300"><span class="linenos"> 300</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MaterializedProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">,</span> +</span><span id="L-301"><a href="#L-301"><span class="linenos"> 301</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MergeBlockRatioProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> +</span><span id="L-302"><a href="#L-302"><span class="linenos"> 302</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">NoPrimaryIndexProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_EXPRESSION</span><span class="p">,</span> +</span><span id="L-303"><a href="#L-303"><span class="linenos"> 303</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">OnProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="L-304"><a href="#L-304"><span class="linenos"> 304</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">OnCommitProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_EXPRESSION</span><span class="p">,</span> +</span><span id="L-305"><a href="#L-305"><span class="linenos"> 305</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Order</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="L-306"><a href="#L-306"><span class="linenos"> 306</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">OutputModelProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="L-307"><a href="#L-307"><span class="linenos"> 307</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionedByProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">,</span> +</span><span id="L-308"><a href="#L-308"><span class="linenos"> 308</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionedOfProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="L-309"><a href="#L-309"><span class="linenos"> 309</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PrimaryKey</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="L-310"><a href="#L-310"><span class="linenos"> 310</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Property</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">,</span> +</span><span id="L-311"><a href="#L-311"><span class="linenos"> 311</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RemoteWithConnectionModelProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="L-312"><a href="#L-312"><span class="linenos"> 312</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ReturnsProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="L-313"><a href="#L-313"><span class="linenos"> 313</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RowFormatProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="L-314"><a href="#L-314"><span class="linenos"> 314</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RowFormatDelimitedProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="L-315"><a href="#L-315"><span class="linenos"> 315</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RowFormatSerdeProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="L-316"><a href="#L-316"><span class="linenos"> 316</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SampleProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="L-317"><a href="#L-317"><span class="linenos"> 317</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SchemaCommentProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="L-318"><a href="#L-318"><span class="linenos"> 318</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SerdeProperties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="L-319"><a href="#L-319"><span class="linenos"> 319</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Set</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="L-320"><a href="#L-320"><span class="linenos"> 320</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SettingsProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="L-321"><a href="#L-321"><span class="linenos"> 321</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SetProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">,</span> +</span><span id="L-322"><a href="#L-322"><span class="linenos"> 322</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SortKeyProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="L-323"><a href="#L-323"><span class="linenos"> 323</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SqlSecurityProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">,</span> +</span><span id="L-324"><a href="#L-324"><span class="linenos"> 324</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StabilityProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="L-325"><a href="#L-325"><span class="linenos"> 325</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TemporaryProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">,</span> +</span><span id="L-326"><a href="#L-326"><span class="linenos"> 326</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ToTableProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="L-327"><a href="#L-327"><span class="linenos"> 327</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TransientProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">,</span> +</span><span id="L-328"><a href="#L-328"><span class="linenos"> 328</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TransformModelProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="L-329"><a href="#L-329"><span class="linenos"> 329</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MergeTreeTTL</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="L-330"><a href="#L-330"><span class="linenos"> 330</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VolatileProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">,</span> +</span><span id="L-331"><a href="#L-331"><span class="linenos"> 331</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">WithDataProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_EXPRESSION</span><span class="p">,</span> +</span><span id="L-332"><a href="#L-332"><span class="linenos"> 332</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">WithJournalTableProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> +</span><span id="L-333"><a href="#L-333"><span class="linenos"> 333</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">WithSystemVersioningProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="L-334"><a href="#L-334"><span class="linenos"> 334</span></a> <span class="p">}</span> </span><span id="L-335"><a href="#L-335"><span class="linenos"> 335</span></a> -</span><span id="L-336"><a href="#L-336"><span class="linenos"> 336</span></a> <span class="c1"># Expressions whose comments are separated from them for better formatting</span> -</span><span id="L-337"><a href="#L-337"><span class="linenos"> 337</span></a> <span class="n">WITH_SEPARATED_COMMENTS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Type</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="p">]</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="L-338"><a href="#L-338"><span class="linenos"> 338</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">,</span> -</span><span id="L-339"><a href="#L-339"><span class="linenos"> 339</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Delete</span><span class="p">,</span> -</span><span id="L-340"><a href="#L-340"><span class="linenos"> 340</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Drop</span><span class="p">,</span> -</span><span id="L-341"><a href="#L-341"><span class="linenos"> 341</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">From</span><span class="p">,</span> -</span><span id="L-342"><a href="#L-342"><span class="linenos"> 342</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Insert</span><span class="p">,</span> -</span><span id="L-343"><a href="#L-343"><span class="linenos"> 343</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Join</span><span class="p">,</span> -</span><span id="L-344"><a href="#L-344"><span class="linenos"> 344</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">,</span> -</span><span id="L-345"><a href="#L-345"><span class="linenos"> 345</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Update</span><span class="p">,</span> -</span><span id="L-346"><a href="#L-346"><span class="linenos"> 346</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Where</span><span class="p">,</span> -</span><span id="L-347"><a href="#L-347"><span class="linenos"> 347</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">With</span><span class="p">,</span> -</span><span id="L-348"><a href="#L-348"><span class="linenos"> 348</span></a> <span class="p">)</span> -</span><span id="L-349"><a href="#L-349"><span class="linenos"> 349</span></a> -</span><span id="L-350"><a href="#L-350"><span class="linenos"> 350</span></a> <span class="c1"># Expressions that should not have their comments generated in maybe_comment</span> -</span><span id="L-351"><a href="#L-351"><span class="linenos"> 351</span></a> <span class="n">EXCLUDE_COMMENTS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Type</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="p">]</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="L-352"><a href="#L-352"><span class="linenos"> 352</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Binary</span><span class="p">,</span> -</span><span id="L-353"><a href="#L-353"><span class="linenos"> 353</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Union</span><span class="p">,</span> -</span><span id="L-354"><a href="#L-354"><span class="linenos"> 354</span></a> <span class="p">)</span> -</span><span id="L-355"><a href="#L-355"><span class="linenos"> 355</span></a> -</span><span id="L-356"><a href="#L-356"><span class="linenos"> 356</span></a> <span class="c1"># Expressions that can remain unwrapped when appearing in the context of an INTERVAL</span> -</span><span id="L-357"><a href="#L-357"><span class="linenos"> 357</span></a> <span class="n">UNWRAPPED_INTERVAL_VALUES</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Type</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="p">]</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="L-358"><a href="#L-358"><span class="linenos"> 358</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">,</span> -</span><span id="L-359"><a href="#L-359"><span class="linenos"> 359</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="p">,</span> -</span><span id="L-360"><a href="#L-360"><span class="linenos"> 360</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Neg</span><span class="p">,</span> -</span><span id="L-361"><a href="#L-361"><span class="linenos"> 361</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Paren</span><span class="p">,</span> -</span><span id="L-362"><a href="#L-362"><span class="linenos"> 362</span></a> <span class="p">)</span> -</span><span id="L-363"><a href="#L-363"><span class="linenos"> 363</span></a> -</span><span id="L-364"><a href="#L-364"><span class="linenos"> 364</span></a> <span class="c1"># Expressions that need to have all CTEs under them bubbled up to them</span> -</span><span id="L-365"><a href="#L-365"><span class="linenos"> 365</span></a> <span class="n">EXPRESSIONS_WITHOUT_NESTED_CTES</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Set</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Type</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="nb">set</span><span class="p">()</span> +</span><span id="L-336"><a href="#L-336"><span class="linenos"> 336</span></a> <span class="c1"># Keywords that can't be used as unquoted identifier names</span> +</span><span id="L-337"><a href="#L-337"><span class="linenos"> 337</span></a> <span class="n">RESERVED_KEYWORDS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Set</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="nb">set</span><span class="p">()</span> +</span><span id="L-338"><a href="#L-338"><span class="linenos"> 338</span></a> +</span><span id="L-339"><a href="#L-339"><span class="linenos"> 339</span></a> <span class="c1"># Expressions whose comments are separated from them for better formatting</span> +</span><span id="L-340"><a href="#L-340"><span class="linenos"> 340</span></a> <span class="n">WITH_SEPARATED_COMMENTS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Type</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="p">]</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="L-341"><a href="#L-341"><span class="linenos"> 341</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">,</span> +</span><span id="L-342"><a href="#L-342"><span class="linenos"> 342</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Delete</span><span class="p">,</span> +</span><span id="L-343"><a href="#L-343"><span class="linenos"> 343</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Drop</span><span class="p">,</span> +</span><span id="L-344"><a href="#L-344"><span class="linenos"> 344</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">From</span><span class="p">,</span> +</span><span id="L-345"><a href="#L-345"><span class="linenos"> 345</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Insert</span><span class="p">,</span> +</span><span id="L-346"><a href="#L-346"><span class="linenos"> 346</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Join</span><span class="p">,</span> +</span><span id="L-347"><a href="#L-347"><span class="linenos"> 347</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">,</span> +</span><span id="L-348"><a href="#L-348"><span class="linenos"> 348</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Update</span><span class="p">,</span> +</span><span id="L-349"><a href="#L-349"><span class="linenos"> 349</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Where</span><span class="p">,</span> +</span><span id="L-350"><a href="#L-350"><span class="linenos"> 350</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">With</span><span class="p">,</span> +</span><span id="L-351"><a href="#L-351"><span class="linenos"> 351</span></a> <span class="p">)</span> +</span><span id="L-352"><a href="#L-352"><span class="linenos"> 352</span></a> +</span><span id="L-353"><a href="#L-353"><span class="linenos"> 353</span></a> <span class="c1"># Expressions that should not have their comments generated in maybe_comment</span> +</span><span id="L-354"><a href="#L-354"><span class="linenos"> 354</span></a> <span class="n">EXCLUDE_COMMENTS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Type</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="p">]</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="L-355"><a href="#L-355"><span class="linenos"> 355</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Binary</span><span class="p">,</span> +</span><span id="L-356"><a href="#L-356"><span class="linenos"> 356</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Union</span><span class="p">,</span> +</span><span id="L-357"><a href="#L-357"><span class="linenos"> 357</span></a> <span class="p">)</span> +</span><span id="L-358"><a href="#L-358"><span class="linenos"> 358</span></a> +</span><span id="L-359"><a href="#L-359"><span class="linenos"> 359</span></a> <span class="c1"># Expressions that can remain unwrapped when appearing in the context of an INTERVAL</span> +</span><span id="L-360"><a href="#L-360"><span class="linenos"> 360</span></a> <span class="n">UNWRAPPED_INTERVAL_VALUES</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Type</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="p">]</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="L-361"><a href="#L-361"><span class="linenos"> 361</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">,</span> +</span><span id="L-362"><a href="#L-362"><span class="linenos"> 362</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="p">,</span> +</span><span id="L-363"><a href="#L-363"><span class="linenos"> 363</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Neg</span><span class="p">,</span> +</span><span id="L-364"><a href="#L-364"><span class="linenos"> 364</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Paren</span><span class="p">,</span> +</span><span id="L-365"><a href="#L-365"><span class="linenos"> 365</span></a> <span class="p">)</span> </span><span id="L-366"><a href="#L-366"><span class="linenos"> 366</span></a> -</span><span id="L-367"><a href="#L-367"><span class="linenos"> 367</span></a> <span class="n">KEY_VALUE_DEFINITONS</span> <span class="o">=</span> <span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Bracket</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="n">exp</span><span class="o">.</span><span class="n">PropertyEQ</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Slice</span><span class="p">)</span> -</span><span id="L-368"><a href="#L-368"><span class="linenos"> 368</span></a> -</span><span id="L-369"><a href="#L-369"><span class="linenos"> 369</span></a> <span class="n">SENTINEL_LINE_BREAK</span> <span class="o">=</span> <span class="s2">"__SQLGLOT__LB__"</span> -</span><span id="L-370"><a href="#L-370"><span class="linenos"> 370</span></a> -</span><span id="L-371"><a href="#L-371"><span class="linenos"> 371</span></a> <span class="vm">__slots__</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="L-372"><a href="#L-372"><span class="linenos"> 372</span></a> <span class="s2">"pretty"</span><span class="p">,</span> -</span><span id="L-373"><a href="#L-373"><span class="linenos"> 373</span></a> <span class="s2">"identify"</span><span class="p">,</span> -</span><span id="L-374"><a href="#L-374"><span class="linenos"> 374</span></a> <span class="s2">"normalize"</span><span class="p">,</span> -</span><span id="L-375"><a href="#L-375"><span class="linenos"> 375</span></a> <span class="s2">"pad"</span><span class="p">,</span> -</span><span id="L-376"><a href="#L-376"><span class="linenos"> 376</span></a> <span class="s2">"_indent"</span><span class="p">,</span> -</span><span id="L-377"><a href="#L-377"><span class="linenos"> 377</span></a> <span class="s2">"normalize_functions"</span><span class="p">,</span> -</span><span id="L-378"><a href="#L-378"><span class="linenos"> 378</span></a> <span class="s2">"unsupported_level"</span><span class="p">,</span> -</span><span id="L-379"><a href="#L-379"><span class="linenos"> 379</span></a> <span class="s2">"max_unsupported"</span><span class="p">,</span> -</span><span id="L-380"><a href="#L-380"><span class="linenos"> 380</span></a> <span class="s2">"leading_comma"</span><span class="p">,</span> -</span><span id="L-381"><a href="#L-381"><span class="linenos"> 381</span></a> <span class="s2">"max_text_width"</span><span class="p">,</span> -</span><span id="L-382"><a href="#L-382"><span class="linenos"> 382</span></a> <span class="s2">"comments"</span><span class="p">,</span> -</span><span id="L-383"><a href="#L-383"><span class="linenos"> 383</span></a> <span class="s2">"dialect"</span><span class="p">,</span> -</span><span id="L-384"><a href="#L-384"><span class="linenos"> 384</span></a> <span class="s2">"unsupported_messages"</span><span class="p">,</span> -</span><span id="L-385"><a href="#L-385"><span class="linenos"> 385</span></a> <span class="s2">"_escaped_quote_end"</span><span class="p">,</span> -</span><span id="L-386"><a href="#L-386"><span class="linenos"> 386</span></a> <span class="s2">"_escaped_identifier_end"</span><span class="p">,</span> -</span><span id="L-387"><a href="#L-387"><span class="linenos"> 387</span></a> <span class="p">)</span> -</span><span id="L-388"><a href="#L-388"><span class="linenos"> 388</span></a> -</span><span id="L-389"><a href="#L-389"><span class="linenos"> 389</span></a> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span> -</span><span id="L-390"><a href="#L-390"><span class="linenos"> 390</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="L-391"><a href="#L-391"><span class="linenos"> 391</span></a> <span class="n">pretty</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">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-392"><a href="#L-392"><span class="linenos"> 392</span></a> <span class="n">identify</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-393"><a href="#L-393"><span class="linenos"> 393</span></a> <span class="n">normalize</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-394"><a href="#L-394"><span class="linenos"> 394</span></a> <span class="n">pad</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">2</span><span class="p">,</span> -</span><span id="L-395"><a href="#L-395"><span class="linenos"> 395</span></a> <span class="n">indent</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">2</span><span class="p">,</span> -</span><span id="L-396"><a href="#L-396"><span class="linenos"> 396</span></a> <span class="n">normalize_functions</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="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-397"><a href="#L-397"><span class="linenos"> 397</span></a> <span class="n">unsupported_level</span><span class="p">:</span> <span class="n">ErrorLevel</span> <span class="o">=</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">WARN</span><span class="p">,</span> -</span><span id="L-398"><a href="#L-398"><span class="linenos"> 398</span></a> <span class="n">max_unsupported</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">3</span><span class="p">,</span> -</span><span id="L-399"><a href="#L-399"><span class="linenos"> 399</span></a> <span class="n">leading_comma</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-400"><a href="#L-400"><span class="linenos"> 400</span></a> <span class="n">max_text_width</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">80</span><span class="p">,</span> -</span><span id="L-401"><a href="#L-401"><span class="linenos"> 401</span></a> <span class="n">comments</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-402"><a href="#L-402"><span class="linenos"> 402</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-403"><a href="#L-403"><span class="linenos"> 403</span></a> <span class="p">):</span> -</span><span id="L-404"><a href="#L-404"><span class="linenos"> 404</span></a> <span class="kn">import</span> <span class="nn">sqlglot</span> -</span><span id="L-405"><a href="#L-405"><span class="linenos"> 405</span></a> <span class="kn">from</span> <span class="nn">sqlglot.dialects</span> <span class="kn">import</span> <span class="n">Dialect</span> -</span><span id="L-406"><a href="#L-406"><span class="linenos"> 406</span></a> -</span><span id="L-407"><a href="#L-407"><span class="linenos"> 407</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span> <span class="o">=</span> <span class="n">pretty</span> <span class="k">if</span> <span class="n">pretty</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">sqlglot</span><span class="o">.</span><span class="n">pretty</span> -</span><span id="L-408"><a href="#L-408"><span class="linenos"> 408</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">identify</span> <span class="o">=</span> <span class="n">identify</span> -</span><span id="L-409"><a href="#L-409"><span class="linenos"> 409</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">normalize</span> <span class="o">=</span> <span class="n">normalize</span> -</span><span id="L-410"><a href="#L-410"><span class="linenos"> 410</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">pad</span> <span class="o">=</span> <span class="n">pad</span> -</span><span id="L-411"><a href="#L-411"><span class="linenos"> 411</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_indent</span> <span class="o">=</span> <span class="n">indent</span> -</span><span id="L-412"><a href="#L-412"><span class="linenos"> 412</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_level</span> <span class="o">=</span> <span class="n">unsupported_level</span> -</span><span id="L-413"><a href="#L-413"><span class="linenos"> 413</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">max_unsupported</span> <span class="o">=</span> <span class="n">max_unsupported</span> -</span><span id="L-414"><a href="#L-414"><span class="linenos"> 414</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">leading_comma</span> <span class="o">=</span> <span class="n">leading_comma</span> -</span><span id="L-415"><a href="#L-415"><span class="linenos"> 415</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">max_text_width</span> <span class="o">=</span> <span class="n">max_text_width</span> -</span><span id="L-416"><a href="#L-416"><span class="linenos"> 416</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">comments</span> <span class="o">=</span> <span class="n">comments</span> -</span><span id="L-417"><a href="#L-417"><span class="linenos"> 417</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span> <span class="o">=</span> <span class="n">Dialect</span><span class="o">.</span><span class="n">get_or_raise</span><span class="p">(</span><span class="n">dialect</span><span class="p">)</span> -</span><span id="L-418"><a href="#L-418"><span class="linenos"> 418</span></a> -</span><span id="L-419"><a href="#L-419"><span class="linenos"> 419</span></a> <span class="c1"># This is both a Dialect property and a Generator argument, so we prioritize the latter</span> -</span><span id="L-420"><a href="#L-420"><span class="linenos"> 420</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">normalize_functions</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="L-421"><a href="#L-421"><span class="linenos"> 421</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">NORMALIZE_FUNCTIONS</span> <span class="k">if</span> <span class="n">normalize_functions</span> <span class="ow">is</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">normalize_functions</span> -</span><span id="L-422"><a href="#L-422"><span class="linenos"> 422</span></a> <span class="p">)</span> -</span><span id="L-423"><a href="#L-423"><span class="linenos"> 423</span></a> -</span><span id="L-424"><a href="#L-424"><span class="linenos"> 424</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_messages</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="L-425"><a href="#L-425"><span class="linenos"> 425</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_escaped_quote_end</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="L-426"><a href="#L-426"><span class="linenos"> 426</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">tokenizer_class</span><span class="o">.</span><span class="n">STRING_ESCAPES</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">QUOTE_END</span> -</span><span id="L-427"><a href="#L-427"><span class="linenos"> 427</span></a> <span class="p">)</span> -</span><span id="L-428"><a href="#L-428"><span class="linenos"> 428</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_escaped_identifier_end</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="L-429"><a href="#L-429"><span class="linenos"> 429</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">tokenizer_class</span><span class="o">.</span><span class="n">IDENTIFIER_ESCAPES</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">IDENTIFIER_END</span> +</span><span id="L-367"><a href="#L-367"><span class="linenos"> 367</span></a> <span class="c1"># Expressions that need to have all CTEs under them bubbled up to them</span> +</span><span id="L-368"><a href="#L-368"><span class="linenos"> 368</span></a> <span class="n">EXPRESSIONS_WITHOUT_NESTED_CTES</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Set</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Type</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="nb">set</span><span class="p">()</span> +</span><span id="L-369"><a href="#L-369"><span class="linenos"> 369</span></a> +</span><span id="L-370"><a href="#L-370"><span class="linenos"> 370</span></a> <span class="n">KEY_VALUE_DEFINITONS</span> <span class="o">=</span> <span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Bracket</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="n">exp</span><span class="o">.</span><span class="n">PropertyEQ</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Slice</span><span class="p">)</span> +</span><span id="L-371"><a href="#L-371"><span class="linenos"> 371</span></a> +</span><span id="L-372"><a href="#L-372"><span class="linenos"> 372</span></a> <span class="n">SENTINEL_LINE_BREAK</span> <span class="o">=</span> <span class="s2">"__SQLGLOT__LB__"</span> +</span><span id="L-373"><a href="#L-373"><span class="linenos"> 373</span></a> +</span><span id="L-374"><a href="#L-374"><span class="linenos"> 374</span></a> <span class="vm">__slots__</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="L-375"><a href="#L-375"><span class="linenos"> 375</span></a> <span class="s2">"pretty"</span><span class="p">,</span> +</span><span id="L-376"><a href="#L-376"><span class="linenos"> 376</span></a> <span class="s2">"identify"</span><span class="p">,</span> +</span><span id="L-377"><a href="#L-377"><span class="linenos"> 377</span></a> <span class="s2">"normalize"</span><span class="p">,</span> +</span><span id="L-378"><a href="#L-378"><span class="linenos"> 378</span></a> <span class="s2">"pad"</span><span class="p">,</span> +</span><span id="L-379"><a href="#L-379"><span class="linenos"> 379</span></a> <span class="s2">"_indent"</span><span class="p">,</span> +</span><span id="L-380"><a href="#L-380"><span class="linenos"> 380</span></a> <span class="s2">"normalize_functions"</span><span class="p">,</span> +</span><span id="L-381"><a href="#L-381"><span class="linenos"> 381</span></a> <span class="s2">"unsupported_level"</span><span class="p">,</span> +</span><span id="L-382"><a href="#L-382"><span class="linenos"> 382</span></a> <span class="s2">"max_unsupported"</span><span class="p">,</span> +</span><span id="L-383"><a href="#L-383"><span class="linenos"> 383</span></a> <span class="s2">"leading_comma"</span><span class="p">,</span> +</span><span id="L-384"><a href="#L-384"><span class="linenos"> 384</span></a> <span class="s2">"max_text_width"</span><span class="p">,</span> +</span><span id="L-385"><a href="#L-385"><span class="linenos"> 385</span></a> <span class="s2">"comments"</span><span class="p">,</span> +</span><span id="L-386"><a href="#L-386"><span class="linenos"> 386</span></a> <span class="s2">"dialect"</span><span class="p">,</span> +</span><span id="L-387"><a href="#L-387"><span class="linenos"> 387</span></a> <span class="s2">"unsupported_messages"</span><span class="p">,</span> +</span><span id="L-388"><a href="#L-388"><span class="linenos"> 388</span></a> <span class="s2">"_escaped_quote_end"</span><span class="p">,</span> +</span><span id="L-389"><a href="#L-389"><span class="linenos"> 389</span></a> <span class="s2">"_escaped_identifier_end"</span><span class="p">,</span> +</span><span id="L-390"><a href="#L-390"><span class="linenos"> 390</span></a> <span class="p">)</span> +</span><span id="L-391"><a href="#L-391"><span class="linenos"> 391</span></a> +</span><span id="L-392"><a href="#L-392"><span class="linenos"> 392</span></a> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span> +</span><span id="L-393"><a href="#L-393"><span class="linenos"> 393</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="L-394"><a href="#L-394"><span class="linenos"> 394</span></a> <span class="n">pretty</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">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-395"><a href="#L-395"><span class="linenos"> 395</span></a> <span class="n">identify</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-396"><a href="#L-396"><span class="linenos"> 396</span></a> <span class="n">normalize</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-397"><a href="#L-397"><span class="linenos"> 397</span></a> <span class="n">pad</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">2</span><span class="p">,</span> +</span><span id="L-398"><a href="#L-398"><span class="linenos"> 398</span></a> <span class="n">indent</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">2</span><span class="p">,</span> +</span><span id="L-399"><a href="#L-399"><span class="linenos"> 399</span></a> <span class="n">normalize_functions</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="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-400"><a href="#L-400"><span class="linenos"> 400</span></a> <span class="n">unsupported_level</span><span class="p">:</span> <span class="n">ErrorLevel</span> <span class="o">=</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">WARN</span><span class="p">,</span> +</span><span id="L-401"><a href="#L-401"><span class="linenos"> 401</span></a> <span class="n">max_unsupported</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">3</span><span class="p">,</span> +</span><span id="L-402"><a href="#L-402"><span class="linenos"> 402</span></a> <span class="n">leading_comma</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-403"><a href="#L-403"><span class="linenos"> 403</span></a> <span class="n">max_text_width</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">80</span><span class="p">,</span> +</span><span id="L-404"><a href="#L-404"><span class="linenos"> 404</span></a> <span class="n">comments</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-405"><a href="#L-405"><span class="linenos"> 405</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-406"><a href="#L-406"><span class="linenos"> 406</span></a> <span class="p">):</span> +</span><span id="L-407"><a href="#L-407"><span class="linenos"> 407</span></a> <span class="kn">import</span> <span class="nn">sqlglot</span> +</span><span id="L-408"><a href="#L-408"><span class="linenos"> 408</span></a> <span class="kn">from</span> <span class="nn">sqlglot.dialects</span> <span class="kn">import</span> <span class="n">Dialect</span> +</span><span id="L-409"><a href="#L-409"><span class="linenos"> 409</span></a> +</span><span id="L-410"><a href="#L-410"><span class="linenos"> 410</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span> <span class="o">=</span> <span class="n">pretty</span> <span class="k">if</span> <span class="n">pretty</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">sqlglot</span><span class="o">.</span><span class="n">pretty</span> +</span><span id="L-411"><a href="#L-411"><span class="linenos"> 411</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">identify</span> <span class="o">=</span> <span class="n">identify</span> +</span><span id="L-412"><a href="#L-412"><span class="linenos"> 412</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">normalize</span> <span class="o">=</span> <span class="n">normalize</span> +</span><span id="L-413"><a href="#L-413"><span class="linenos"> 413</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">pad</span> <span class="o">=</span> <span class="n">pad</span> +</span><span id="L-414"><a href="#L-414"><span class="linenos"> 414</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_indent</span> <span class="o">=</span> <span class="n">indent</span> +</span><span id="L-415"><a href="#L-415"><span class="linenos"> 415</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_level</span> <span class="o">=</span> <span class="n">unsupported_level</span> +</span><span id="L-416"><a href="#L-416"><span class="linenos"> 416</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">max_unsupported</span> <span class="o">=</span> <span class="n">max_unsupported</span> +</span><span id="L-417"><a href="#L-417"><span class="linenos"> 417</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">leading_comma</span> <span class="o">=</span> <span class="n">leading_comma</span> +</span><span id="L-418"><a href="#L-418"><span class="linenos"> 418</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">max_text_width</span> <span class="o">=</span> <span class="n">max_text_width</span> +</span><span id="L-419"><a href="#L-419"><span class="linenos"> 419</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">comments</span> <span class="o">=</span> <span class="n">comments</span> +</span><span id="L-420"><a href="#L-420"><span class="linenos"> 420</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span> <span class="o">=</span> <span class="n">Dialect</span><span class="o">.</span><span class="n">get_or_raise</span><span class="p">(</span><span class="n">dialect</span><span class="p">)</span> +</span><span id="L-421"><a href="#L-421"><span class="linenos"> 421</span></a> +</span><span id="L-422"><a href="#L-422"><span class="linenos"> 422</span></a> <span class="c1"># This is both a Dialect property and a Generator argument, so we prioritize the latter</span> +</span><span id="L-423"><a href="#L-423"><span class="linenos"> 423</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">normalize_functions</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="L-424"><a href="#L-424"><span class="linenos"> 424</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">NORMALIZE_FUNCTIONS</span> <span class="k">if</span> <span class="n">normalize_functions</span> <span class="ow">is</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">normalize_functions</span> +</span><span id="L-425"><a href="#L-425"><span class="linenos"> 425</span></a> <span class="p">)</span> +</span><span id="L-426"><a href="#L-426"><span class="linenos"> 426</span></a> +</span><span id="L-427"><a href="#L-427"><span class="linenos"> 427</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_messages</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="L-428"><a href="#L-428"><span class="linenos"> 428</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_escaped_quote_end</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="L-429"><a href="#L-429"><span class="linenos"> 429</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">tokenizer_class</span><span class="o">.</span><span class="n">STRING_ESCAPES</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">QUOTE_END</span> </span><span id="L-430"><a href="#L-430"><span class="linenos"> 430</span></a> <span class="p">)</span> -</span><span id="L-431"><a href="#L-431"><span class="linenos"> 431</span></a> -</span><span id="L-432"><a href="#L-432"><span class="linenos"> 432</span></a> <span class="k">def</span> <span class="nf">generate</span><span class="p">(</span><span class="bp">self</span><span 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">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-433"><a href="#L-433"><span class="linenos"> 433</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-434"><a href="#L-434"><span class="linenos"> 434</span></a><span class="sd"> Generates the SQL string corresponding to the given syntax tree.</span> -</span><span id="L-435"><a href="#L-435"><span class="linenos"> 435</span></a> -</span><span id="L-436"><a href="#L-436"><span class="linenos"> 436</span></a><span class="sd"> Args:</span> -</span><span id="L-437"><a href="#L-437"><span class="linenos"> 437</span></a><span class="sd"> expression: The syntax tree.</span> -</span><span id="L-438"><a href="#L-438"><span class="linenos"> 438</span></a><span class="sd"> copy: Whether or not to copy the expression. The generator performs mutations so</span> -</span><span id="L-439"><a href="#L-439"><span class="linenos"> 439</span></a><span class="sd"> it is safer to copy.</span> -</span><span id="L-440"><a href="#L-440"><span class="linenos"> 440</span></a> -</span><span id="L-441"><a href="#L-441"><span class="linenos"> 441</span></a><span class="sd"> Returns:</span> -</span><span id="L-442"><a href="#L-442"><span class="linenos"> 442</span></a><span class="sd"> The SQL string corresponding to `expression`.</span> -</span><span id="L-443"><a href="#L-443"><span class="linenos"> 443</span></a><span class="sd"> """</span> -</span><span id="L-444"><a href="#L-444"><span class="linenos"> 444</span></a> <span class="k">if</span> <span class="n">copy</span><span class="p">:</span> -</span><span id="L-445"><a href="#L-445"><span class="linenos"> 445</span></a> <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-446"><a href="#L-446"><span class="linenos"> 446</span></a> -</span><span id="L-447"><a href="#L-447"><span class="linenos"> 447</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">preprocess</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="L-448"><a href="#L-448"><span class="linenos"> 448</span></a> -</span><span id="L-449"><a href="#L-449"><span class="linenos"> 449</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_messages</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="L-450"><a href="#L-450"><span class="linenos"> 450</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">expression</span><span class="p">)</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> +</span><span id="L-431"><a href="#L-431"><span class="linenos"> 431</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_escaped_identifier_end</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="L-432"><a href="#L-432"><span class="linenos"> 432</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">tokenizer_class</span><span class="o">.</span><span class="n">IDENTIFIER_ESCAPES</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">IDENTIFIER_END</span> +</span><span id="L-433"><a href="#L-433"><span class="linenos"> 433</span></a> <span class="p">)</span> +</span><span id="L-434"><a href="#L-434"><span class="linenos"> 434</span></a> +</span><span id="L-435"><a href="#L-435"><span class="linenos"> 435</span></a> <span class="k">def</span> <span class="nf">generate</span><span class="p">(</span><span class="bp">self</span><span 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">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-436"><a href="#L-436"><span class="linenos"> 436</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-437"><a href="#L-437"><span class="linenos"> 437</span></a><span class="sd"> Generates the SQL string corresponding to the given syntax tree.</span> +</span><span id="L-438"><a href="#L-438"><span class="linenos"> 438</span></a> +</span><span id="L-439"><a href="#L-439"><span class="linenos"> 439</span></a><span class="sd"> Args:</span> +</span><span id="L-440"><a href="#L-440"><span class="linenos"> 440</span></a><span class="sd"> expression: The syntax tree.</span> +</span><span id="L-441"><a href="#L-441"><span class="linenos"> 441</span></a><span class="sd"> copy: Whether or not to copy the expression. The generator performs mutations so</span> +</span><span id="L-442"><a href="#L-442"><span class="linenos"> 442</span></a><span class="sd"> it is safer to copy.</span> +</span><span id="L-443"><a href="#L-443"><span class="linenos"> 443</span></a> +</span><span id="L-444"><a href="#L-444"><span class="linenos"> 444</span></a><span class="sd"> Returns:</span> +</span><span id="L-445"><a href="#L-445"><span class="linenos"> 445</span></a><span class="sd"> The SQL string corresponding to `expression`.</span> +</span><span id="L-446"><a href="#L-446"><span class="linenos"> 446</span></a><span class="sd"> """</span> +</span><span id="L-447"><a href="#L-447"><span class="linenos"> 447</span></a> <span class="k">if</span> <span class="n">copy</span><span class="p">:</span> +</span><span id="L-448"><a href="#L-448"><span class="linenos"> 448</span></a> <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-449"><a href="#L-449"><span class="linenos"> 449</span></a> +</span><span id="L-450"><a href="#L-450"><span class="linenos"> 450</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">preprocess</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> </span><span id="L-451"><a href="#L-451"><span class="linenos"> 451</span></a> -</span><span id="L-452"><a href="#L-452"><span class="linenos"> 452</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-453"><a href="#L-453"><span class="linenos"> 453</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="n">sql</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">SENTINEL_LINE_BREAK</span><span class="p">,</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">)</span> +</span><span id="L-452"><a href="#L-452"><span class="linenos"> 452</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_messages</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="L-453"><a href="#L-453"><span class="linenos"> 453</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">expression</span><span class="p">)</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> </span><span id="L-454"><a href="#L-454"><span class="linenos"> 454</span></a> -</span><span id="L-455"><a href="#L-455"><span class="linenos"> 455</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_level</span> <span class="o">==</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">IGNORE</span><span class="p">:</span> -</span><span id="L-456"><a href="#L-456"><span class="linenos"> 456</span></a> <span class="k">return</span> <span class="n">sql</span> +</span><span id="L-455"><a href="#L-455"><span class="linenos"> 455</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-456"><a href="#L-456"><span class="linenos"> 456</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="n">sql</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">SENTINEL_LINE_BREAK</span><span class="p">,</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">)</span> </span><span id="L-457"><a href="#L-457"><span class="linenos"> 457</span></a> -</span><span id="L-458"><a href="#L-458"><span class="linenos"> 458</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_level</span> <span class="o">==</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">WARN</span><span class="p">:</span> -</span><span id="L-459"><a href="#L-459"><span class="linenos"> 459</span></a> <span class="k">for</span> <span class="n">msg</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_messages</span><span class="p">:</span> -</span><span id="L-460"><a href="#L-460"><span class="linenos"> 460</span></a> <span class="n">logger</span><span class="o">.</span><span class="n">warning</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span> -</span><span id="L-461"><a href="#L-461"><span class="linenos"> 461</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_level</span> <span class="o">==</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">RAISE</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_messages</span><span class="p">:</span> -</span><span id="L-462"><a href="#L-462"><span class="linenos"> 462</span></a> <span class="k">raise</span> <span class="n">UnsupportedError</span><span class="p">(</span><span class="n">concat_messages</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">unsupported_messages</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">max_unsupported</span><span class="p">))</span> -</span><span id="L-463"><a href="#L-463"><span class="linenos"> 463</span></a> -</span><span id="L-464"><a href="#L-464"><span class="linenos"> 464</span></a> <span class="k">return</span> <span class="n">sql</span> -</span><span id="L-465"><a href="#L-465"><span class="linenos"> 465</span></a> -</span><span id="L-466"><a href="#L-466"><span class="linenos"> 466</span></a> <span class="k">def</span> <span class="nf">preprocess</span><span class="p">(</span><span class="bp">self</span><span 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">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">:</span> -</span><span id="L-467"><a href="#L-467"><span class="linenos"> 467</span></a><span class="w"> </span><span class="sd">"""Apply generic preprocessing transformations to a given expression."""</span> -</span><span id="L-468"><a href="#L-468"><span class="linenos"> 468</span></a> <span class="k">if</span> <span class="p">(</span> -</span><span id="L-469"><a href="#L-469"><span class="linenos"> 469</span></a> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">parent</span> -</span><span id="L-470"><a href="#L-470"><span class="linenos"> 470</span></a> <span class="ow">and</span> <span class="nb">type</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">EXPRESSIONS_WITHOUT_NESTED_CTES</span> -</span><span id="L-471"><a href="#L-471"><span class="linenos"> 471</span></a> <span class="ow">and</span> <span class="nb">any</span><span class="p">(</span><span class="n">node</span><span class="o">.</span><span class="n">parent</span> <span class="ow">is</span> <span class="ow">not</span> <span class="n">expression</span> <span class="k">for</span> <span class="n">node</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">find_all</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">With</span><span class="p">))</span> -</span><span id="L-472"><a href="#L-472"><span class="linenos"> 472</span></a> <span class="p">):</span> -</span><span id="L-473"><a href="#L-473"><span class="linenos"> 473</span></a> <span class="kn">from</span> <span class="nn">sqlglot.transforms</span> <span class="kn">import</span> <span class="n">move_ctes_to_top_level</span> -</span><span id="L-474"><a href="#L-474"><span class="linenos"> 474</span></a> -</span><span id="L-475"><a href="#L-475"><span class="linenos"> 475</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">move_ctes_to_top_level</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="L-476"><a href="#L-476"><span class="linenos"> 476</span></a> -</span><span id="L-477"><a href="#L-477"><span class="linenos"> 477</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">ENSURE_BOOLS</span><span class="p">:</span> -</span><span id="L-478"><a href="#L-478"><span class="linenos"> 478</span></a> <span class="kn">from</span> <span class="nn">sqlglot.transforms</span> <span class="kn">import</span> <span class="n">ensure_bools</span> +</span><span id="L-458"><a href="#L-458"><span class="linenos"> 458</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_level</span> <span class="o">==</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">IGNORE</span><span class="p">:</span> +</span><span id="L-459"><a href="#L-459"><span class="linenos"> 459</span></a> <span class="k">return</span> <span class="n">sql</span> +</span><span id="L-460"><a href="#L-460"><span class="linenos"> 460</span></a> +</span><span id="L-461"><a href="#L-461"><span class="linenos"> 461</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_level</span> <span class="o">==</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">WARN</span><span class="p">:</span> +</span><span id="L-462"><a href="#L-462"><span class="linenos"> 462</span></a> <span class="k">for</span> <span class="n">msg</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_messages</span><span class="p">:</span> +</span><span id="L-463"><a href="#L-463"><span class="linenos"> 463</span></a> <span class="n">logger</span><span class="o">.</span><span class="n">warning</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span> +</span><span id="L-464"><a href="#L-464"><span class="linenos"> 464</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_level</span> <span class="o">==</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">RAISE</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_messages</span><span class="p">:</span> +</span><span id="L-465"><a href="#L-465"><span class="linenos"> 465</span></a> <span class="k">raise</span> <span class="n">UnsupportedError</span><span class="p">(</span><span class="n">concat_messages</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">unsupported_messages</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">max_unsupported</span><span class="p">))</span> +</span><span id="L-466"><a href="#L-466"><span class="linenos"> 466</span></a> +</span><span id="L-467"><a href="#L-467"><span class="linenos"> 467</span></a> <span class="k">return</span> <span class="n">sql</span> +</span><span id="L-468"><a href="#L-468"><span class="linenos"> 468</span></a> +</span><span id="L-469"><a href="#L-469"><span class="linenos"> 469</span></a> <span class="k">def</span> <span class="nf">preprocess</span><span class="p">(</span><span class="bp">self</span><span 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">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">:</span> +</span><span id="L-470"><a href="#L-470"><span class="linenos"> 470</span></a><span class="w"> </span><span class="sd">"""Apply generic preprocessing transformations to a given expression."""</span> +</span><span id="L-471"><a href="#L-471"><span class="linenos"> 471</span></a> <span class="k">if</span> <span class="p">(</span> +</span><span id="L-472"><a href="#L-472"><span class="linenos"> 472</span></a> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">parent</span> +</span><span id="L-473"><a href="#L-473"><span class="linenos"> 473</span></a> <span class="ow">and</span> <span class="nb">type</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">EXPRESSIONS_WITHOUT_NESTED_CTES</span> +</span><span id="L-474"><a href="#L-474"><span class="linenos"> 474</span></a> <span class="ow">and</span> <span class="nb">any</span><span class="p">(</span><span class="n">node</span><span class="o">.</span><span class="n">parent</span> <span class="ow">is</span> <span class="ow">not</span> <span class="n">expression</span> <span class="k">for</span> <span class="n">node</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">find_all</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">With</span><span class="p">))</span> +</span><span id="L-475"><a href="#L-475"><span class="linenos"> 475</span></a> <span class="p">):</span> +</span><span id="L-476"><a href="#L-476"><span class="linenos"> 476</span></a> <span class="kn">from</span> <span class="nn">sqlglot.transforms</span> <span class="kn">import</span> <span class="n">move_ctes_to_top_level</span> +</span><span id="L-477"><a href="#L-477"><span class="linenos"> 477</span></a> +</span><span id="L-478"><a href="#L-478"><span class="linenos"> 478</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">move_ctes_to_top_level</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> </span><span id="L-479"><a href="#L-479"><span class="linenos"> 479</span></a> -</span><span id="L-480"><a href="#L-480"><span class="linenos"> 480</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">ensure_bools</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="L-481"><a href="#L-481"><span class="linenos"> 481</span></a> -</span><span id="L-482"><a href="#L-482"><span class="linenos"> 482</span></a> <span class="k">return</span> <span class="n">expression</span> -</span><span id="L-483"><a href="#L-483"><span class="linenos"> 483</span></a> -</span><span id="L-484"><a href="#L-484"><span class="linenos"> 484</span></a> <span class="k">def</span> <span class="nf">unsupported</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">message</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-485"><a href="#L-485"><span class="linenos"> 485</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_level</span> <span class="o">==</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">IMMEDIATE</span><span class="p">:</span> -</span><span id="L-486"><a href="#L-486"><span class="linenos"> 486</span></a> <span class="k">raise</span> <span class="n">UnsupportedError</span><span class="p">(</span><span class="n">message</span><span class="p">)</span> -</span><span id="L-487"><a href="#L-487"><span class="linenos"> 487</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_messages</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">message</span><span class="p">)</span> -</span><span id="L-488"><a href="#L-488"><span class="linenos"> 488</span></a> -</span><span id="L-489"><a href="#L-489"><span class="linenos"> 489</span></a> <span class="k">def</span> <span class="nf">sep</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <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 class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-490"><a href="#L-490"><span class="linenos"> 490</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="o">.</span><span class="n">strip</span><span class="p">()</span><span class="si">}</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">pretty</span> <span class="k">else</span> <span class="n">sep</span> +</span><span id="L-480"><a href="#L-480"><span class="linenos"> 480</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">ENSURE_BOOLS</span><span class="p">:</span> +</span><span id="L-481"><a href="#L-481"><span class="linenos"> 481</span></a> <span class="kn">from</span> <span class="nn">sqlglot.transforms</span> <span class="kn">import</span> <span class="n">ensure_bools</span> +</span><span id="L-482"><a href="#L-482"><span class="linenos"> 482</span></a> +</span><span id="L-483"><a href="#L-483"><span class="linenos"> 483</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">ensure_bools</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-484"><a href="#L-484"><span class="linenos"> 484</span></a> +</span><span id="L-485"><a href="#L-485"><span class="linenos"> 485</span></a> <span class="k">return</span> <span class="n">expression</span> +</span><span id="L-486"><a href="#L-486"><span class="linenos"> 486</span></a> +</span><span id="L-487"><a href="#L-487"><span class="linenos"> 487</span></a> <span class="k">def</span> <span class="nf">unsupported</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">message</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-488"><a href="#L-488"><span class="linenos"> 488</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_level</span> <span class="o">==</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">IMMEDIATE</span><span class="p">:</span> +</span><span id="L-489"><a href="#L-489"><span class="linenos"> 489</span></a> <span class="k">raise</span> <span class="n">UnsupportedError</span><span class="p">(</span><span class="n">message</span><span class="p">)</span> +</span><span id="L-490"><a href="#L-490"><span class="linenos"> 490</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_messages</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">message</span><span class="p">)</span> </span><span id="L-491"><a href="#L-491"><span class="linenos"> 491</span></a> -</span><span id="L-492"><a href="#L-492"><span class="linenos"> 492</span></a> <span class="k">def</span> <span class="nf">seg</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sql</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <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 class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-493"><a href="#L-493"><span class="linenos"> 493</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">sep</span><span class="p">(</span><span class="n">sep</span><span class="p">)</span><span class="si">}{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-492"><a href="#L-492"><span class="linenos"> 492</span></a> <span class="k">def</span> <span class="nf">sep</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <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 class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-493"><a href="#L-493"><span class="linenos"> 493</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="o">.</span><span class="n">strip</span><span class="p">()</span><span class="si">}</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">pretty</span> <span class="k">else</span> <span class="n">sep</span> </span><span id="L-494"><a href="#L-494"><span class="linenos"> 494</span></a> -</span><span id="L-495"><a href="#L-495"><span class="linenos"> 495</span></a> <span class="k">def</span> <span class="nf">pad_comment</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">comment</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-496"><a href="#L-496"><span class="linenos"> 496</span></a> <span class="n">comment</span> <span class="o">=</span> <span class="s2">" "</span> <span class="o">+</span> <span class="n">comment</span> <span class="k">if</span> <span class="n">comment</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> <span class="k">else</span> <span class="n">comment</span> -</span><span id="L-497"><a href="#L-497"><span class="linenos"> 497</span></a> <span class="n">comment</span> <span class="o">=</span> <span class="n">comment</span> <span class="o">+</span> <span class="s2">" "</span> <span class="k">if</span> <span class="n">comment</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> <span class="k">else</span> <span class="n">comment</span> -</span><span id="L-498"><a href="#L-498"><span class="linenos"> 498</span></a> <span class="k">return</span> <span class="n">comment</span> -</span><span id="L-499"><a href="#L-499"><span class="linenos"> 499</span></a> -</span><span id="L-500"><a href="#L-500"><span class="linenos"> 500</span></a> <span class="k">def</span> <span class="nf">maybe_comment</span><span class="p">(</span> -</span><span id="L-501"><a href="#L-501"><span class="linenos"> 501</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="L-502"><a href="#L-502"><span class="linenos"> 502</span></a> <span class="n">sql</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> -</span><span id="L-503"><a href="#L-503"><span class="linenos"> 503</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-504"><a href="#L-504"><span class="linenos"> 504</span></a> <span class="n">comments</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">List</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-505"><a href="#L-505"><span class="linenos"> 505</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-506"><a href="#L-506"><span class="linenos"> 506</span></a> <span class="n">comments</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="L-507"><a href="#L-507"><span class="linenos"> 507</span></a> <span class="p">((</span><span class="n">expression</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">comments</span><span class="p">)</span> <span class="k">if</span> <span class="n">comments</span> <span class="ow">is</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">comments</span><span class="p">)</span> <span class="c1"># type: ignore</span> -</span><span id="L-508"><a href="#L-508"><span class="linenos"> 508</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">comments</span> -</span><span id="L-509"><a href="#L-509"><span class="linenos"> 509</span></a> <span class="k">else</span> <span class="kc">None</span> -</span><span id="L-510"><a href="#L-510"><span class="linenos"> 510</span></a> <span class="p">)</span> -</span><span id="L-511"><a href="#L-511"><span class="linenos"> 511</span></a> -</span><span id="L-512"><a href="#L-512"><span class="linenos"> 512</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">comments</span> <span class="ow">or</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">EXCLUDE_COMMENTS</span><span class="p">):</span> -</span><span id="L-513"><a href="#L-513"><span class="linenos"> 513</span></a> <span class="k">return</span> <span class="n">sql</span> +</span><span id="L-495"><a href="#L-495"><span class="linenos"> 495</span></a> <span class="k">def</span> <span class="nf">seg</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sql</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <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 class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-496"><a href="#L-496"><span class="linenos"> 496</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">sep</span><span class="p">(</span><span class="n">sep</span><span class="p">)</span><span class="si">}{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-497"><a href="#L-497"><span class="linenos"> 497</span></a> +</span><span id="L-498"><a href="#L-498"><span class="linenos"> 498</span></a> <span class="k">def</span> <span class="nf">pad_comment</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">comment</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-499"><a href="#L-499"><span class="linenos"> 499</span></a> <span class="n">comment</span> <span class="o">=</span> <span class="s2">" "</span> <span class="o">+</span> <span class="n">comment</span> <span class="k">if</span> <span class="n">comment</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> <span class="k">else</span> <span class="n">comment</span> +</span><span id="L-500"><a href="#L-500"><span class="linenos"> 500</span></a> <span class="n">comment</span> <span class="o">=</span> <span class="n">comment</span> <span class="o">+</span> <span class="s2">" "</span> <span class="k">if</span> <span class="n">comment</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> <span class="k">else</span> <span class="n">comment</span> +</span><span id="L-501"><a href="#L-501"><span class="linenos"> 501</span></a> <span class="k">return</span> <span class="n">comment</span> +</span><span id="L-502"><a href="#L-502"><span class="linenos"> 502</span></a> +</span><span id="L-503"><a href="#L-503"><span class="linenos"> 503</span></a> <span class="k">def</span> <span class="nf">maybe_comment</span><span class="p">(</span> +</span><span id="L-504"><a href="#L-504"><span class="linenos"> 504</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="L-505"><a href="#L-505"><span class="linenos"> 505</span></a> <span class="n">sql</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> +</span><span id="L-506"><a href="#L-506"><span class="linenos"> 506</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-507"><a href="#L-507"><span class="linenos"> 507</span></a> <span class="n">comments</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">List</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-508"><a href="#L-508"><span class="linenos"> 508</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-509"><a href="#L-509"><span class="linenos"> 509</span></a> <span class="n">comments</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="L-510"><a href="#L-510"><span class="linenos"> 510</span></a> <span class="p">((</span><span class="n">expression</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">comments</span><span class="p">)</span> <span class="k">if</span> <span class="n">comments</span> <span class="ow">is</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">comments</span><span class="p">)</span> <span class="c1"># type: ignore</span> +</span><span id="L-511"><a href="#L-511"><span class="linenos"> 511</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">comments</span> +</span><span id="L-512"><a href="#L-512"><span class="linenos"> 512</span></a> <span class="k">else</span> <span class="kc">None</span> +</span><span id="L-513"><a href="#L-513"><span class="linenos"> 513</span></a> <span class="p">)</span> </span><span id="L-514"><a href="#L-514"><span class="linenos"> 514</span></a> -</span><span id="L-515"><a href="#L-515"><span class="linenos"> 515</span></a> <span class="n">comments_sql</span> <span class="o">=</span> <span class="s2">" "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> -</span><span id="L-516"><a href="#L-516"><span class="linenos"> 516</span></a> <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">pad_comment</span><span class="p">(</span><span class="n">comment</span><span class="p">)</span><span class="si">}</span><span class="s2">*/"</span> <span class="k">for</span> <span class="n">comment</span> <span class="ow">in</span> <span class="n">comments</span> <span class="k">if</span> <span class="n">comment</span> -</span><span id="L-517"><a href="#L-517"><span class="linenos"> 517</span></a> <span class="p">)</span> -</span><span id="L-518"><a href="#L-518"><span class="linenos"> 518</span></a> -</span><span id="L-519"><a href="#L-519"><span class="linenos"> 519</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">comments_sql</span><span class="p">:</span> -</span><span id="L-520"><a href="#L-520"><span class="linenos"> 520</span></a> <span class="k">return</span> <span class="n">sql</span> +</span><span id="L-515"><a href="#L-515"><span class="linenos"> 515</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">comments</span> <span class="ow">or</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">EXCLUDE_COMMENTS</span><span class="p">):</span> +</span><span id="L-516"><a href="#L-516"><span class="linenos"> 516</span></a> <span class="k">return</span> <span class="n">sql</span> +</span><span id="L-517"><a href="#L-517"><span class="linenos"> 517</span></a> +</span><span id="L-518"><a href="#L-518"><span class="linenos"> 518</span></a> <span class="n">comments_sql</span> <span class="o">=</span> <span class="s2">" "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> +</span><span id="L-519"><a href="#L-519"><span class="linenos"> 519</span></a> <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">pad_comment</span><span class="p">(</span><span class="n">comment</span><span class="p">)</span><span class="si">}</span><span class="s2">*/"</span> <span class="k">for</span> <span class="n">comment</span> <span class="ow">in</span> <span class="n">comments</span> <span class="k">if</span> <span class="n">comment</span> +</span><span id="L-520"><a href="#L-520"><span class="linenos"> 520</span></a> <span class="p">)</span> </span><span id="L-521"><a href="#L-521"><span class="linenos"> 521</span></a> -</span><span id="L-522"><a href="#L-522"><span class="linenos"> 522</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">WITH_SEPARATED_COMMENTS</span><span class="p">):</span> -</span><span id="L-523"><a href="#L-523"><span class="linenos"> 523</span></a> <span class="k">return</span> <span class="p">(</span> -</span><span id="L-524"><a href="#L-524"><span class="linenos"> 524</span></a> <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="si">}{</span><span class="n">comments_sql</span><span class="si">}{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-525"><a href="#L-525"><span class="linenos"> 525</span></a> <span class="k">if</span> <span class="n">sql</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">isspace</span><span class="p">()</span> -</span><span id="L-526"><a href="#L-526"><span class="linenos"> 526</span></a> <span class="k">else</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">comments_sql</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="n">sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-527"><a href="#L-527"><span class="linenos"> 527</span></a> <span class="p">)</span> -</span><span id="L-528"><a href="#L-528"><span class="linenos"> 528</span></a> -</span><span id="L-529"><a href="#L-529"><span class="linenos"> 529</span></a> <span class="k">return</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="s2"> </span><span class="si">{</span><span class="n">comments_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-530"><a href="#L-530"><span class="linenos"> 530</span></a> -</span><span id="L-531"><a href="#L-531"><span class="linenos"> 531</span></a> <span class="k">def</span> <span class="nf">wrap</span><span class="p">(</span><span class="bp">self</span><span 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="o">|</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-532"><a href="#L-532"><span class="linenos"> 532</span></a> <span class="n">this_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span> -</span><span id="L-533"><a href="#L-533"><span class="linenos"> 533</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><span id="L-534"><a href="#L-534"><span class="linenos"> 534</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Union</span><span class="p">))</span> -</span><span id="L-535"><a href="#L-535"><span class="linenos"> 535</span></a> <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">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">),</span> -</span><span id="L-536"><a href="#L-536"><span class="linenos"> 536</span></a> <span class="n">level</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> -</span><span id="L-537"><a href="#L-537"><span class="linenos"> 537</span></a> <span class="n">pad</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> -</span><span id="L-538"><a href="#L-538"><span class="linenos"> 538</span></a> <span class="p">)</span> -</span><span id="L-539"><a href="#L-539"><span class="linenos"> 539</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">sep</span><span class="p">(</span><span class="s1">''</span><span class="p">)</span><span class="si">}{</span><span class="n">this_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-540"><a href="#L-540"><span class="linenos"> 540</span></a> -</span><span id="L-541"><a href="#L-541"><span class="linenos"> 541</span></a> <span class="k">def</span> <span class="nf">no_identify</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">func</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">[</span><span class="o">...</span><span class="p">,</span> <span class="nb">str</span><span class="p">],</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-542"><a href="#L-542"><span class="linenos"> 542</span></a> <span class="n">original</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">identify</span> -</span><span id="L-543"><a href="#L-543"><span class="linenos"> 543</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">identify</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-544"><a href="#L-544"><span class="linenos"> 544</span></a> <span class="n">result</span> <span class="o">=</span> <span class="n">func</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> -</span><span id="L-545"><a href="#L-545"><span class="linenos"> 545</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">identify</span> <span class="o">=</span> <span class="n">original</span> -</span><span id="L-546"><a href="#L-546"><span class="linenos"> 546</span></a> <span class="k">return</span> <span class="n">result</span> -</span><span id="L-547"><a href="#L-547"><span class="linenos"> 547</span></a> -</span><span id="L-548"><a href="#L-548"><span class="linenos"> 548</span></a> <span class="k">def</span> <span class="nf">normalize_func</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</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-549"><a href="#L-549"><span class="linenos"> 549</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">normalize_functions</span> <span class="o">==</span> <span class="s2">"upper"</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">normalize_functions</span> <span class="ow">is</span> <span class="kc">True</span><span class="p">:</span> -</span><span id="L-550"><a href="#L-550"><span class="linenos"> 550</span></a> <span class="k">return</span> <span class="n">name</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> -</span><span id="L-551"><a href="#L-551"><span class="linenos"> 551</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">normalize_functions</span> <span class="o">==</span> <span class="s2">"lower"</span><span class="p">:</span> -</span><span id="L-552"><a href="#L-552"><span class="linenos"> 552</span></a> <span class="k">return</span> <span class="n">name</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> -</span><span id="L-553"><a href="#L-553"><span class="linenos"> 553</span></a> <span class="k">return</span> <span class="n">name</span> -</span><span id="L-554"><a href="#L-554"><span class="linenos"> 554</span></a> -</span><span id="L-555"><a href="#L-555"><span class="linenos"> 555</span></a> <span class="k">def</span> <span class="nf">indent</span><span class="p">(</span> -</span><span id="L-556"><a href="#L-556"><span class="linenos"> 556</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="L-557"><a href="#L-557"><span class="linenos"> 557</span></a> <span class="n">sql</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> -</span><span id="L-558"><a href="#L-558"><span class="linenos"> 558</span></a> <span class="n">level</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span> -</span><span id="L-559"><a href="#L-559"><span class="linenos"> 559</span></a> <span class="n">pad</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">int</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-560"><a href="#L-560"><span class="linenos"> 560</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-561"><a href="#L-561"><span class="linenos"> 561</span></a> <span class="n">skip_last</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-562"><a href="#L-562"><span class="linenos"> 562</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-563"><a href="#L-563"><span class="linenos"> 563</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-564"><a href="#L-564"><span class="linenos"> 564</span></a> <span class="k">return</span> <span class="n">sql</span> -</span><span id="L-565"><a href="#L-565"><span class="linenos"> 565</span></a> -</span><span id="L-566"><a href="#L-566"><span class="linenos"> 566</span></a> <span class="n">pad</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">pad</span> <span class="k">if</span> <span class="n">pad</span> <span class="ow">is</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">pad</span> -</span><span id="L-567"><a href="#L-567"><span class="linenos"> 567</span></a> <span class="n">lines</span> <span class="o">=</span> <span class="n">sql</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">)</span> +</span><span id="L-522"><a href="#L-522"><span class="linenos"> 522</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">comments_sql</span><span class="p">:</span> +</span><span id="L-523"><a href="#L-523"><span class="linenos"> 523</span></a> <span class="k">return</span> <span class="n">sql</span> +</span><span id="L-524"><a href="#L-524"><span class="linenos"> 524</span></a> +</span><span id="L-525"><a href="#L-525"><span class="linenos"> 525</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">WITH_SEPARATED_COMMENTS</span><span class="p">):</span> +</span><span id="L-526"><a href="#L-526"><span class="linenos"> 526</span></a> <span class="k">return</span> <span class="p">(</span> +</span><span id="L-527"><a href="#L-527"><span class="linenos"> 527</span></a> <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="si">}{</span><span class="n">comments_sql</span><span class="si">}{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-528"><a href="#L-528"><span class="linenos"> 528</span></a> <span class="k">if</span> <span class="n">sql</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">isspace</span><span class="p">()</span> +</span><span id="L-529"><a href="#L-529"><span class="linenos"> 529</span></a> <span class="k">else</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">comments_sql</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="n">sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-530"><a href="#L-530"><span class="linenos"> 530</span></a> <span class="p">)</span> +</span><span id="L-531"><a href="#L-531"><span class="linenos"> 531</span></a> +</span><span id="L-532"><a href="#L-532"><span class="linenos"> 532</span></a> <span class="k">return</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="s2"> </span><span class="si">{</span><span class="n">comments_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-533"><a href="#L-533"><span class="linenos"> 533</span></a> +</span><span id="L-534"><a href="#L-534"><span class="linenos"> 534</span></a> <span class="k">def</span> <span class="nf">wrap</span><span class="p">(</span><span class="bp">self</span><span 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="o">|</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-535"><a href="#L-535"><span class="linenos"> 535</span></a> <span class="n">this_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span> +</span><span id="L-536"><a href="#L-536"><span class="linenos"> 536</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><span id="L-537"><a href="#L-537"><span class="linenos"> 537</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Union</span><span class="p">))</span> +</span><span id="L-538"><a href="#L-538"><span class="linenos"> 538</span></a> <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">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">),</span> +</span><span id="L-539"><a href="#L-539"><span class="linenos"> 539</span></a> <span class="n">level</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> +</span><span id="L-540"><a href="#L-540"><span class="linenos"> 540</span></a> <span class="n">pad</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> +</span><span id="L-541"><a href="#L-541"><span class="linenos"> 541</span></a> <span class="p">)</span> +</span><span id="L-542"><a href="#L-542"><span class="linenos"> 542</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">sep</span><span class="p">(</span><span class="s1">''</span><span class="p">)</span><span class="si">}{</span><span class="n">this_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-543"><a href="#L-543"><span class="linenos"> 543</span></a> +</span><span id="L-544"><a href="#L-544"><span class="linenos"> 544</span></a> <span class="k">def</span> <span class="nf">no_identify</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">func</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">[</span><span class="o">...</span><span class="p">,</span> <span class="nb">str</span><span class="p">],</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-545"><a href="#L-545"><span class="linenos"> 545</span></a> <span class="n">original</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">identify</span> +</span><span id="L-546"><a href="#L-546"><span class="linenos"> 546</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">identify</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-547"><a href="#L-547"><span class="linenos"> 547</span></a> <span class="n">result</span> <span class="o">=</span> <span class="n">func</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> +</span><span id="L-548"><a href="#L-548"><span class="linenos"> 548</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">identify</span> <span class="o">=</span> <span class="n">original</span> +</span><span id="L-549"><a href="#L-549"><span class="linenos"> 549</span></a> <span class="k">return</span> <span class="n">result</span> +</span><span id="L-550"><a href="#L-550"><span class="linenos"> 550</span></a> +</span><span id="L-551"><a href="#L-551"><span class="linenos"> 551</span></a> <span class="k">def</span> <span class="nf">normalize_func</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</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-552"><a href="#L-552"><span class="linenos"> 552</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">normalize_functions</span> <span class="o">==</span> <span class="s2">"upper"</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">normalize_functions</span> <span class="ow">is</span> <span class="kc">True</span><span class="p">:</span> +</span><span id="L-553"><a href="#L-553"><span class="linenos"> 553</span></a> <span class="k">return</span> <span class="n">name</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> +</span><span id="L-554"><a href="#L-554"><span class="linenos"> 554</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">normalize_functions</span> <span class="o">==</span> <span class="s2">"lower"</span><span class="p">:</span> +</span><span id="L-555"><a href="#L-555"><span class="linenos"> 555</span></a> <span class="k">return</span> <span class="n">name</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> +</span><span id="L-556"><a href="#L-556"><span class="linenos"> 556</span></a> <span class="k">return</span> <span class="n">name</span> +</span><span id="L-557"><a href="#L-557"><span class="linenos"> 557</span></a> +</span><span id="L-558"><a href="#L-558"><span class="linenos"> 558</span></a> <span class="k">def</span> <span class="nf">indent</span><span class="p">(</span> +</span><span id="L-559"><a href="#L-559"><span class="linenos"> 559</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="L-560"><a href="#L-560"><span class="linenos"> 560</span></a> <span class="n">sql</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> +</span><span id="L-561"><a href="#L-561"><span class="linenos"> 561</span></a> <span class="n">level</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span> +</span><span id="L-562"><a href="#L-562"><span class="linenos"> 562</span></a> <span class="n">pad</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">int</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-563"><a href="#L-563"><span class="linenos"> 563</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-564"><a href="#L-564"><span class="linenos"> 564</span></a> <span class="n">skip_last</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-565"><a href="#L-565"><span class="linenos"> 565</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-566"><a href="#L-566"><span class="linenos"> 566</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-567"><a href="#L-567"><span class="linenos"> 567</span></a> <span class="k">return</span> <span class="n">sql</span> </span><span id="L-568"><a href="#L-568"><span class="linenos"> 568</span></a> -</span><span id="L-569"><a href="#L-569"><span class="linenos"> 569</span></a> <span class="k">return</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><span id="L-570"><a href="#L-570"><span class="linenos"> 570</span></a> <span class="n">line</span> -</span><span id="L-571"><a href="#L-571"><span class="linenos"> 571</span></a> <span class="k">if</span> <span class="p">(</span><span class="n">skip_first</span> <span class="ow">and</span> <span class="n">i</span> <span class="o">==</span> <span class="mi">0</span><span class="p">)</span> <span class="ow">or</span> <span class="p">(</span><span class="n">skip_last</span> <span class="ow">and</span> <span class="n">i</span> <span class="o">==</span> <span class="nb">len</span><span class="p">(</span><span class="n">lines</span><span class="p">)</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> -</span><span id="L-572"><a href="#L-572"><span class="linenos"> 572</span></a> <span class="k">else</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="s1">' '</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="p">(</span><span class="n">level</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="bp">self</span><span class="o">.</span><span class="n">_indent</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">pad</span><span class="p">)</span><span class="si">}{</span><span class="n">line</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-573"><a href="#L-573"><span class="linenos"> 573</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">line</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">lines</span><span class="p">)</span> -</span><span id="L-574"><a href="#L-574"><span class="linenos"> 574</span></a> <span class="p">)</span> -</span><span id="L-575"><a href="#L-575"><span class="linenos"> 575</span></a> -</span><span id="L-576"><a href="#L-576"><span class="linenos"> 576</span></a> <span class="k">def</span> <span class="nf">sql</span><span class="p">(</span> -</span><span id="L-577"><a href="#L-577"><span class="linenos"> 577</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="L-578"><a href="#L-578"><span class="linenos"> 578</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="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><span id="L-579"><a href="#L-579"><span class="linenos"> 579</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-580"><a href="#L-580"><span class="linenos"> 580</span></a> <span class="n">comment</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-581"><a href="#L-581"><span class="linenos"> 581</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-582"><a href="#L-582"><span class="linenos"> 582</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expression</span><span class="p">:</span> -</span><span id="L-583"><a href="#L-583"><span class="linenos"> 583</span></a> <span class="k">return</span> <span class="s2">""</span> -</span><span id="L-584"><a href="#L-584"><span class="linenos"> 584</span></a> -</span><span id="L-585"><a href="#L-585"><span class="linenos"> 585</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span> -</span><span id="L-586"><a href="#L-586"><span class="linenos"> 586</span></a> <span class="k">return</span> <span class="n">expression</span> +</span><span id="L-569"><a href="#L-569"><span class="linenos"> 569</span></a> <span class="n">pad</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">pad</span> <span class="k">if</span> <span class="n">pad</span> <span class="ow">is</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">pad</span> +</span><span id="L-570"><a href="#L-570"><span class="linenos"> 570</span></a> <span class="n">lines</span> <span class="o">=</span> <span class="n">sql</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">)</span> +</span><span id="L-571"><a href="#L-571"><span class="linenos"> 571</span></a> +</span><span id="L-572"><a href="#L-572"><span class="linenos"> 572</span></a> <span class="k">return</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><span id="L-573"><a href="#L-573"><span class="linenos"> 573</span></a> <span class="n">line</span> +</span><span id="L-574"><a href="#L-574"><span class="linenos"> 574</span></a> <span class="k">if</span> <span class="p">(</span><span class="n">skip_first</span> <span class="ow">and</span> <span class="n">i</span> <span class="o">==</span> <span class="mi">0</span><span class="p">)</span> <span class="ow">or</span> <span class="p">(</span><span class="n">skip_last</span> <span class="ow">and</span> <span class="n">i</span> <span class="o">==</span> <span class="nb">len</span><span class="p">(</span><span class="n">lines</span><span class="p">)</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> +</span><span id="L-575"><a href="#L-575"><span class="linenos"> 575</span></a> <span class="k">else</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="s1">' '</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="p">(</span><span class="n">level</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="bp">self</span><span class="o">.</span><span class="n">_indent</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">pad</span><span class="p">)</span><span class="si">}{</span><span class="n">line</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-576"><a href="#L-576"><span class="linenos"> 576</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">line</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">lines</span><span class="p">)</span> +</span><span id="L-577"><a href="#L-577"><span class="linenos"> 577</span></a> <span class="p">)</span> +</span><span id="L-578"><a href="#L-578"><span class="linenos"> 578</span></a> +</span><span id="L-579"><a href="#L-579"><span class="linenos"> 579</span></a> <span class="k">def</span> <span class="nf">sql</span><span class="p">(</span> +</span><span id="L-580"><a href="#L-580"><span class="linenos"> 580</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="L-581"><a href="#L-581"><span class="linenos"> 581</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="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><span id="L-582"><a href="#L-582"><span class="linenos"> 582</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-583"><a href="#L-583"><span class="linenos"> 583</span></a> <span class="n">comment</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-584"><a href="#L-584"><span class="linenos"> 584</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-585"><a href="#L-585"><span class="linenos"> 585</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expression</span><span class="p">:</span> +</span><span id="L-586"><a href="#L-586"><span class="linenos"> 586</span></a> <span class="k">return</span> <span class="s2">""</span> </span><span id="L-587"><a href="#L-587"><span class="linenos"> 587</span></a> -</span><span id="L-588"><a href="#L-588"><span class="linenos"> 588</span></a> <span class="k">if</span> <span class="n">key</span><span class="p">:</span> -</span><span id="L-589"><a href="#L-589"><span class="linenos"> 589</span></a> <span class="n">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-590"><a href="#L-590"><span class="linenos"> 590</span></a> <span class="k">if</span> <span class="n">value</span><span class="p">:</span> -</span><span id="L-591"><a href="#L-591"><span class="linenos"> 591</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">value</span><span class="p">)</span> -</span><span id="L-592"><a href="#L-592"><span class="linenos"> 592</span></a> <span class="k">return</span> <span class="s2">""</span> -</span><span id="L-593"><a href="#L-593"><span class="linenos"> 593</span></a> -</span><span id="L-594"><a href="#L-594"><span class="linenos"> 594</span></a> <span class="n">transform</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">TRANSFORMS</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-595"><a href="#L-595"><span class="linenos"> 595</span></a> -</span><span id="L-596"><a href="#L-596"><span class="linenos"> 596</span></a> <span class="k">if</span> <span class="nb">callable</span><span class="p">(</span><span class="n">transform</span><span class="p">):</span> -</span><span id="L-597"><a href="#L-597"><span class="linenos"> 597</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="n">transform</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> -</span><span id="L-598"><a href="#L-598"><span class="linenos"> 598</span></a> <span class="k">elif</span> <span class="n">transform</span><span class="p">:</span> -</span><span id="L-599"><a href="#L-599"><span class="linenos"> 599</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="n">transform</span> -</span><span id="L-600"><a href="#L-600"><span class="linenos"> 600</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="L-601"><a href="#L-601"><span class="linenos"> 601</span></a> <span class="n">exp_handler_name</span> <span class="o">=</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">key</span><span class="si">}</span><span class="s2">_sql"</span> -</span><span id="L-602"><a href="#L-602"><span class="linenos"> 602</span></a> -</span><span id="L-603"><a href="#L-603"><span class="linenos"> 603</span></a> <span class="k">if</span> <span class="nb">hasattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">exp_handler_name</span><span class="p">):</span> -</span><span id="L-604"><a href="#L-604"><span class="linenos"> 604</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">exp_handler_name</span><span class="p">)(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="L-605"><a href="#L-605"><span class="linenos"> 605</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-606"><a href="#L-606"><span class="linenos"> 606</span></a> <span class="n">sql</span> <span class="o">=</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-607"><a href="#L-607"><span class="linenos"> 607</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Property</span><span class="p">):</span> -</span><span id="L-608"><a href="#L-608"><span class="linenos"> 608</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">property_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="L-609"><a href="#L-609"><span class="linenos"> 609</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-610"><a href="#L-610"><span class="linenos"> 610</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unsupported expression type </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-611"><a href="#L-611"><span class="linenos"> 611</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-612"><a href="#L-612"><span class="linenos"> 612</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Expected an Expression. Received </span><span class="si">{</span><span class="nb">type</span><span class="p">(</span><span class="n">expression</span><span class="p">)</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 class="p">)</span> -</span><span id="L-613"><a href="#L-613"><span class="linenos"> 613</span></a> -</span><span id="L-614"><a href="#L-614"><span class="linenos"> 614</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">maybe_comment</span><span class="p">(</span><span class="n">sql</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">comments</span> <span class="ow">and</span> <span class="n">comment</span> <span class="k">else</span> <span class="n">sql</span> -</span><span id="L-615"><a href="#L-615"><span class="linenos"> 615</span></a> -</span><span id="L-616"><a href="#L-616"><span class="linenos"> 616</span></a> <span class="k">def</span> <span class="nf">uncache_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Uncache</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-617"><a href="#L-617"><span class="linenos"> 617</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">"this"</span><span class="p">)</span> -</span><span id="L-618"><a href="#L-618"><span class="linenos"> 618</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-619"><a href="#L-619"><span class="linenos"> 619</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"UNCACHE TABLE</span><span class="si">{</span><span class="n">exists_sql</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">table</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-620"><a href="#L-620"><span class="linenos"> 620</span></a> -</span><span id="L-621"><a href="#L-621"><span class="linenos"> 621</span></a> <span class="k">def</span> <span class="nf">cache_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cache</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-622"><a href="#L-622"><span class="linenos"> 622</span></a> <span class="n">lazy</span> <span class="o">=</span> <span class="s2">" LAZY"</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">"lazy"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-623"><a href="#L-623"><span class="linenos"> 623</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">"this"</span><span class="p">)</span> -</span><span id="L-624"><a href="#L-624"><span class="linenos"> 624</span></a> <span class="n">options</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">"options"</span><span class="p">)</span> -</span><span id="L-625"><a href="#L-625"><span class="linenos"> 625</span></a> <span class="n">options</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" OPTIONS(</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">options</span><span class="p">[</span><span class="mi">0</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">options</span><span class="p">[</span><span class="mi">1</span><span class="p">])</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-626"><a href="#L-626"><span class="linenos"> 626</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">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> -</span><span id="L-627"><a href="#L-627"><span class="linenos"> 627</span></a> <span class="n">sql</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">sep</span><span class="p">()</span><span class="si">}{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">sql</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-628"><a href="#L-628"><span class="linenos"> 628</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"CACHE</span><span class="si">{</span><span class="n">lazy</span><span class="si">}</span><span class="s2"> TABLE </span><span class="si">{</span><span class="n">table</span><span class="si">}{</span><span class="n">options</span><span class="si">}{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-629"><a href="#L-629"><span class="linenos"> 629</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-630"><a href="#L-630"><span class="linenos"> 630</span></a> -</span><span id="L-631"><a href="#L-631"><span class="linenos"> 631</span></a> <span class="k">def</span> <span class="nf">characterset_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">CharacterSet</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-632"><a href="#L-632"><span class="linenos"> 632</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">parent</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">):</span> -</span><span id="L-633"><a href="#L-633"><span class="linenos"> 633</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CHAR CHARACTER SET </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-634"><a href="#L-634"><span class="linenos"> 634</span></a> <span class="n">default</span> <span class="o">=</span> <span class="s2">"DEFAULT "</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">"default"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-635"><a href="#L-635"><span class="linenos"> 635</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">default</span><span class="si">}</span><span class="s2">CHARACTER SET=</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-636"><a href="#L-636"><span class="linenos"> 636</span></a> -</span><span id="L-637"><a href="#L-637"><span class="linenos"> 637</span></a> <span class="k">def</span> <span class="nf">column_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-638"><a href="#L-638"><span class="linenos"> 638</span></a> <span class="n">join_mark</span> <span class="o">=</span> <span class="s2">" (+)"</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">"join_mark"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-588"><a href="#L-588"><span class="linenos"> 588</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span> +</span><span id="L-589"><a href="#L-589"><span class="linenos"> 589</span></a> <span class="k">return</span> <span class="n">expression</span> +</span><span id="L-590"><a href="#L-590"><span class="linenos"> 590</span></a> +</span><span id="L-591"><a href="#L-591"><span class="linenos"> 591</span></a> <span class="k">if</span> <span class="n">key</span><span class="p">:</span> +</span><span id="L-592"><a href="#L-592"><span class="linenos"> 592</span></a> <span class="n">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-593"><a href="#L-593"><span class="linenos"> 593</span></a> <span class="k">if</span> <span class="n">value</span><span class="p">:</span> +</span><span id="L-594"><a href="#L-594"><span class="linenos"> 594</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">value</span><span class="p">)</span> +</span><span id="L-595"><a href="#L-595"><span class="linenos"> 595</span></a> <span class="k">return</span> <span class="s2">""</span> +</span><span id="L-596"><a href="#L-596"><span class="linenos"> 596</span></a> +</span><span id="L-597"><a href="#L-597"><span class="linenos"> 597</span></a> <span class="n">transform</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">TRANSFORMS</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-598"><a href="#L-598"><span class="linenos"> 598</span></a> +</span><span id="L-599"><a href="#L-599"><span class="linenos"> 599</span></a> <span class="k">if</span> <span class="nb">callable</span><span class="p">(</span><span class="n">transform</span><span class="p">):</span> +</span><span id="L-600"><a href="#L-600"><span class="linenos"> 600</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="n">transform</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> +</span><span id="L-601"><a href="#L-601"><span class="linenos"> 601</span></a> <span class="k">elif</span> <span class="n">transform</span><span class="p">:</span> +</span><span id="L-602"><a href="#L-602"><span class="linenos"> 602</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="n">transform</span> +</span><span id="L-603"><a href="#L-603"><span class="linenos"> 603</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="L-604"><a href="#L-604"><span class="linenos"> 604</span></a> <span class="n">exp_handler_name</span> <span class="o">=</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">key</span><span class="si">}</span><span class="s2">_sql"</span> +</span><span id="L-605"><a href="#L-605"><span class="linenos"> 605</span></a> +</span><span id="L-606"><a href="#L-606"><span class="linenos"> 606</span></a> <span class="k">if</span> <span class="nb">hasattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">exp_handler_name</span><span class="p">):</span> +</span><span id="L-607"><a href="#L-607"><span class="linenos"> 607</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">exp_handler_name</span><span class="p">)(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-608"><a href="#L-608"><span class="linenos"> 608</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-609"><a href="#L-609"><span class="linenos"> 609</span></a> <span class="n">sql</span> <span class="o">=</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-610"><a href="#L-610"><span class="linenos"> 610</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Property</span><span class="p">):</span> +</span><span id="L-611"><a href="#L-611"><span class="linenos"> 611</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">property_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-612"><a href="#L-612"><span class="linenos"> 612</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-613"><a href="#L-613"><span class="linenos"> 613</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unsupported expression type </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-614"><a href="#L-614"><span class="linenos"> 614</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-615"><a href="#L-615"><span class="linenos"> 615</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Expected an Expression. Received </span><span class="si">{</span><span class="nb">type</span><span class="p">(</span><span class="n">expression</span><span class="p">)</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 class="p">)</span> +</span><span id="L-616"><a href="#L-616"><span class="linenos"> 616</span></a> +</span><span id="L-617"><a href="#L-617"><span class="linenos"> 617</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">maybe_comment</span><span class="p">(</span><span class="n">sql</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">comments</span> <span class="ow">and</span> <span class="n">comment</span> <span class="k">else</span> <span class="n">sql</span> +</span><span id="L-618"><a href="#L-618"><span class="linenos"> 618</span></a> +</span><span id="L-619"><a href="#L-619"><span class="linenos"> 619</span></a> <span class="k">def</span> <span class="nf">uncache_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Uncache</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-620"><a href="#L-620"><span class="linenos"> 620</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">"this"</span><span class="p">)</span> +</span><span id="L-621"><a href="#L-621"><span class="linenos"> 621</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-622"><a href="#L-622"><span class="linenos"> 622</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"UNCACHE TABLE</span><span class="si">{</span><span class="n">exists_sql</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">table</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-623"><a href="#L-623"><span class="linenos"> 623</span></a> +</span><span id="L-624"><a href="#L-624"><span class="linenos"> 624</span></a> <span class="k">def</span> <span class="nf">cache_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cache</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-625"><a href="#L-625"><span class="linenos"> 625</span></a> <span class="n">lazy</span> <span class="o">=</span> <span class="s2">" LAZY"</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">"lazy"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-626"><a href="#L-626"><span class="linenos"> 626</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">"this"</span><span class="p">)</span> +</span><span id="L-627"><a href="#L-627"><span class="linenos"> 627</span></a> <span class="n">options</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">"options"</span><span class="p">)</span> +</span><span id="L-628"><a href="#L-628"><span class="linenos"> 628</span></a> <span class="n">options</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" OPTIONS(</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">options</span><span class="p">[</span><span class="mi">0</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">options</span><span class="p">[</span><span class="mi">1</span><span class="p">])</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-629"><a href="#L-629"><span class="linenos"> 629</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">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> +</span><span id="L-630"><a href="#L-630"><span class="linenos"> 630</span></a> <span class="n">sql</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">sep</span><span class="p">()</span><span class="si">}{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">sql</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-631"><a href="#L-631"><span class="linenos"> 631</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"CACHE</span><span class="si">{</span><span class="n">lazy</span><span class="si">}</span><span class="s2"> TABLE </span><span class="si">{</span><span class="n">table</span><span class="si">}{</span><span class="n">options</span><span class="si">}{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-632"><a href="#L-632"><span class="linenos"> 632</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-633"><a href="#L-633"><span class="linenos"> 633</span></a> +</span><span id="L-634"><a href="#L-634"><span class="linenos"> 634</span></a> <span class="k">def</span> <span class="nf">characterset_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">CharacterSet</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-635"><a href="#L-635"><span class="linenos"> 635</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">parent</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">):</span> +</span><span id="L-636"><a href="#L-636"><span class="linenos"> 636</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CHAR CHARACTER SET </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-637"><a href="#L-637"><span class="linenos"> 637</span></a> <span class="n">default</span> <span class="o">=</span> <span class="s2">"DEFAULT "</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">"default"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-638"><a href="#L-638"><span class="linenos"> 638</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">default</span><span class="si">}</span><span class="s2">CHARACTER SET=</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-639"><a href="#L-639"><span class="linenos"> 639</span></a> -</span><span id="L-640"><a href="#L-640"><span class="linenos"> 640</span></a> <span class="k">if</span> <span class="n">join_mark</span> <span class="ow">and</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">COLUMN_JOIN_MARKS_SUPPORTED</span><span class="p">:</span> -</span><span id="L-641"><a href="#L-641"><span class="linenos"> 641</span></a> <span class="n">join_mark</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="L-642"><a href="#L-642"><span class="linenos"> 642</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Outer join syntax using the (+) operator is not supported."</span><span class="p">)</span> -</span><span id="L-643"><a href="#L-643"><span class="linenos"> 643</span></a> -</span><span id="L-644"><a href="#L-644"><span class="linenos"> 644</span></a> <span class="n">column</span> <span class="o">=</span> <span class="s2">"."</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> -</span><span id="L-645"><a href="#L-645"><span class="linenos"> 645</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">part</span><span class="p">)</span> -</span><span id="L-646"><a href="#L-646"><span class="linenos"> 646</span></a> <span class="k">for</span> <span class="n">part</span> <span class="ow">in</span> <span class="p">(</span> -</span><span id="L-647"><a href="#L-647"><span class="linenos"> 647</span></a> <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">"catalog"</span><span class="p">),</span> -</span><span id="L-648"><a href="#L-648"><span class="linenos"> 648</span></a> <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">"db"</span><span class="p">),</span> -</span><span id="L-649"><a href="#L-649"><span class="linenos"> 649</span></a> <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">"table"</span><span class="p">),</span> -</span><span id="L-650"><a href="#L-650"><span class="linenos"> 650</span></a> <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">"this"</span><span class="p">),</span> -</span><span id="L-651"><a href="#L-651"><span class="linenos"> 651</span></a> <span class="p">)</span> -</span><span id="L-652"><a href="#L-652"><span class="linenos"> 652</span></a> <span class="k">if</span> <span class="n">part</span> -</span><span id="L-653"><a href="#L-653"><span class="linenos"> 653</span></a> <span class="p">)</span> -</span><span id="L-654"><a href="#L-654"><span class="linenos"> 654</span></a> -</span><span id="L-655"><a href="#L-655"><span class="linenos"> 655</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">column</span><span class="si">}{</span><span class="n">join_mark</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-656"><a href="#L-656"><span class="linenos"> 656</span></a> -</span><span id="L-657"><a href="#L-657"><span class="linenos"> 657</span></a> <span class="k">def</span> <span class="nf">columnposition_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ColumnPosition</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-658"><a href="#L-658"><span class="linenos"> 658</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-659"><a href="#L-659"><span class="linenos"> 659</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-660"><a href="#L-660"><span class="linenos"> 660</span></a> <span class="n">position</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"position"</span><span class="p">)</span> -</span><span id="L-661"><a href="#L-661"><span class="linenos"> 661</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">position</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-662"><a href="#L-662"><span class="linenos"> 662</span></a> -</span><span id="L-663"><a href="#L-663"><span class="linenos"> 663</span></a> <span class="k">def</span> <span class="nf">columndef_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ColumnDef</span><span class="p">,</span> <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 class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-664"><a href="#L-664"><span class="linenos"> 664</span></a> <span class="n">column</span> <span class="o">=</span> <span class="bp">self</span><span 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-665"><a href="#L-665"><span class="linenos"> 665</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-666"><a href="#L-666"><span class="linenos"> 666</span></a> <span class="n">constraints</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">"constraints"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</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-667"><a href="#L-667"><span class="linenos"> 667</span></a> <span class="n">exists</span> <span class="o">=</span> <span class="s2">"IF NOT 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-668"><a href="#L-668"><span class="linenos"> 668</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">sep</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-669"><a href="#L-669"><span class="linenos"> 669</span></a> <span class="n">constraints</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">constraints</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">constraints</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-670"><a href="#L-670"><span class="linenos"> 670</span></a> <span class="n">position</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"position"</span><span class="p">)</span> -</span><span id="L-671"><a href="#L-671"><span class="linenos"> 671</span></a> <span class="n">position</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">position</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">position</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-672"><a href="#L-672"><span class="linenos"> 672</span></a> -</span><span id="L-673"><a href="#L-673"><span class="linenos"> 673</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">find</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">ComputedColumnConstraint</span><span class="p">)</span> <span class="ow">and</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">COMPUTED_COLUMN_WITH_TYPE</span><span class="p">:</span> -</span><span id="L-674"><a href="#L-674"><span class="linenos"> 674</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="L-640"><a href="#L-640"><span class="linenos"> 640</span></a> <span class="k">def</span> <span class="nf">column_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-641"><a href="#L-641"><span class="linenos"> 641</span></a> <span class="n">join_mark</span> <span class="o">=</span> <span class="s2">" (+)"</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">"join_mark"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-642"><a href="#L-642"><span class="linenos"> 642</span></a> +</span><span id="L-643"><a href="#L-643"><span class="linenos"> 643</span></a> <span class="k">if</span> <span class="n">join_mark</span> <span class="ow">and</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">COLUMN_JOIN_MARKS_SUPPORTED</span><span class="p">:</span> +</span><span id="L-644"><a href="#L-644"><span class="linenos"> 644</span></a> <span class="n">join_mark</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="L-645"><a href="#L-645"><span class="linenos"> 645</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Outer join syntax using the (+) operator is not supported."</span><span class="p">)</span> +</span><span id="L-646"><a href="#L-646"><span class="linenos"> 646</span></a> +</span><span id="L-647"><a href="#L-647"><span class="linenos"> 647</span></a> <span class="n">column</span> <span class="o">=</span> <span class="s2">"."</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> +</span><span id="L-648"><a href="#L-648"><span class="linenos"> 648</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">part</span><span class="p">)</span> +</span><span id="L-649"><a href="#L-649"><span class="linenos"> 649</span></a> <span class="k">for</span> <span class="n">part</span> <span class="ow">in</span> <span class="p">(</span> +</span><span id="L-650"><a href="#L-650"><span class="linenos"> 650</span></a> <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">"catalog"</span><span class="p">),</span> +</span><span id="L-651"><a href="#L-651"><span class="linenos"> 651</span></a> <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">"db"</span><span class="p">),</span> +</span><span id="L-652"><a href="#L-652"><span class="linenos"> 652</span></a> <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">"table"</span><span class="p">),</span> +</span><span id="L-653"><a href="#L-653"><span class="linenos"> 653</span></a> <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">"this"</span><span class="p">),</span> +</span><span id="L-654"><a href="#L-654"><span class="linenos"> 654</span></a> <span class="p">)</span> +</span><span id="L-655"><a href="#L-655"><span class="linenos"> 655</span></a> <span class="k">if</span> <span class="n">part</span> +</span><span id="L-656"><a href="#L-656"><span class="linenos"> 656</span></a> <span class="p">)</span> +</span><span id="L-657"><a href="#L-657"><span class="linenos"> 657</span></a> +</span><span id="L-658"><a href="#L-658"><span class="linenos"> 658</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">column</span><span class="si">}{</span><span class="n">join_mark</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-659"><a href="#L-659"><span class="linenos"> 659</span></a> +</span><span id="L-660"><a href="#L-660"><span class="linenos"> 660</span></a> <span class="k">def</span> <span class="nf">columnposition_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ColumnPosition</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-661"><a href="#L-661"><span class="linenos"> 661</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-662"><a href="#L-662"><span class="linenos"> 662</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-663"><a href="#L-663"><span class="linenos"> 663</span></a> <span class="n">position</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"position"</span><span class="p">)</span> +</span><span id="L-664"><a href="#L-664"><span class="linenos"> 664</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">position</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-665"><a href="#L-665"><span class="linenos"> 665</span></a> +</span><span id="L-666"><a href="#L-666"><span class="linenos"> 666</span></a> <span class="k">def</span> <span class="nf">columndef_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ColumnDef</span><span class="p">,</span> <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 class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-667"><a href="#L-667"><span class="linenos"> 667</span></a> <span class="n">column</span> <span class="o">=</span> <span class="bp">self</span><span 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-668"><a href="#L-668"><span class="linenos"> 668</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-669"><a href="#L-669"><span class="linenos"> 669</span></a> <span class="n">constraints</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">"constraints"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</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-670"><a href="#L-670"><span class="linenos"> 670</span></a> <span class="n">exists</span> <span class="o">=</span> <span class="s2">"IF NOT 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-671"><a href="#L-671"><span class="linenos"> 671</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">sep</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-672"><a href="#L-672"><span class="linenos"> 672</span></a> <span class="n">constraints</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">constraints</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">constraints</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-673"><a href="#L-673"><span class="linenos"> 673</span></a> <span class="n">position</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"position"</span><span class="p">)</span> +</span><span id="L-674"><a href="#L-674"><span class="linenos"> 674</span></a> <span class="n">position</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">position</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">position</span> <span class="k">else</span> <span class="s2">""</span> </span><span id="L-675"><a href="#L-675"><span class="linenos"> 675</span></a> -</span><span id="L-676"><a href="#L-676"><span class="linenos"> 676</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">exists</span><span class="si">}{</span><span class="n">column</span><span class="si">}{</span><span class="n">kind</span><span class="si">}{</span><span class="n">constraints</span><span class="si">}{</span><span class="n">position</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-677"><a href="#L-677"><span class="linenos"> 677</span></a> -</span><span id="L-678"><a href="#L-678"><span class="linenos"> 678</span></a> <span class="k">def</span> <span class="nf">columnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-679"><a href="#L-679"><span class="linenos"> 679</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-680"><a href="#L-680"><span class="linenos"> 680</span></a> <span class="n">kind_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">"kind"</span><span class="p">)</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> -</span><span id="L-681"><a href="#L-681"><span class="linenos"> 681</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CONSTRAINT </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_sql</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="n">kind_sql</span> -</span><span id="L-682"><a href="#L-682"><span class="linenos"> 682</span></a> -</span><span id="L-683"><a href="#L-683"><span class="linenos"> 683</span></a> <span class="k">def</span> <span class="nf">computedcolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ComputedColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-684"><a href="#L-684"><span class="linenos"> 684</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-685"><a href="#L-685"><span class="linenos"> 685</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">"not_null"</span><span class="p">):</span> -</span><span id="L-686"><a href="#L-686"><span class="linenos"> 686</span></a> <span class="n">persisted</span> <span class="o">=</span> <span class="s2">" PERSISTED NOT NULL"</span> -</span><span id="L-687"><a href="#L-687"><span class="linenos"> 687</span></a> <span class="k">elif</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">"persisted"</span><span class="p">):</span> -</span><span id="L-688"><a href="#L-688"><span class="linenos"> 688</span></a> <span class="n">persisted</span> <span class="o">=</span> <span class="s2">" PERSISTED"</span> -</span><span id="L-689"><a href="#L-689"><span class="linenos"> 689</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-690"><a href="#L-690"><span class="linenos"> 690</span></a> <span class="n">persisted</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="L-691"><a href="#L-691"><span class="linenos"> 691</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"AS </span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">persisted</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-692"><a href="#L-692"><span class="linenos"> 692</span></a> -</span><span id="L-693"><a href="#L-693"><span class="linenos"> 693</span></a> <span class="k">def</span> <span class="nf">autoincrementcolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">_</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-694"><a href="#L-694"><span class="linenos"> 694</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">token_sql</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">AUTO_INCREMENT</span><span class="p">)</span> +</span><span id="L-676"><a href="#L-676"><span class="linenos"> 676</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">find</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">ComputedColumnConstraint</span><span class="p">)</span> <span class="ow">and</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">COMPUTED_COLUMN_WITH_TYPE</span><span class="p">:</span> +</span><span id="L-677"><a href="#L-677"><span class="linenos"> 677</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="L-678"><a href="#L-678"><span class="linenos"> 678</span></a> +</span><span id="L-679"><a href="#L-679"><span class="linenos"> 679</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">exists</span><span class="si">}{</span><span class="n">column</span><span class="si">}{</span><span class="n">kind</span><span class="si">}{</span><span class="n">constraints</span><span class="si">}{</span><span class="n">position</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-680"><a href="#L-680"><span class="linenos"> 680</span></a> +</span><span id="L-681"><a href="#L-681"><span class="linenos"> 681</span></a> <span class="k">def</span> <span class="nf">columnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-682"><a href="#L-682"><span class="linenos"> 682</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-683"><a href="#L-683"><span class="linenos"> 683</span></a> <span class="n">kind_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">"kind"</span><span class="p">)</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> +</span><span id="L-684"><a href="#L-684"><span class="linenos"> 684</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CONSTRAINT </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_sql</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="n">kind_sql</span> +</span><span id="L-685"><a href="#L-685"><span class="linenos"> 685</span></a> +</span><span id="L-686"><a href="#L-686"><span class="linenos"> 686</span></a> <span class="k">def</span> <span class="nf">computedcolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ComputedColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-687"><a href="#L-687"><span class="linenos"> 687</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-688"><a href="#L-688"><span class="linenos"> 688</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">"not_null"</span><span class="p">):</span> +</span><span id="L-689"><a href="#L-689"><span class="linenos"> 689</span></a> <span class="n">persisted</span> <span class="o">=</span> <span class="s2">" PERSISTED NOT NULL"</span> +</span><span id="L-690"><a href="#L-690"><span class="linenos"> 690</span></a> <span class="k">elif</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">"persisted"</span><span class="p">):</span> +</span><span id="L-691"><a href="#L-691"><span class="linenos"> 691</span></a> <span class="n">persisted</span> <span class="o">=</span> <span class="s2">" PERSISTED"</span> +</span><span id="L-692"><a href="#L-692"><span class="linenos"> 692</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-693"><a href="#L-693"><span class="linenos"> 693</span></a> <span class="n">persisted</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="L-694"><a href="#L-694"><span class="linenos"> 694</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"AS </span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">persisted</span><span class="si">}</span><span class="s2">"</span> </span><span id="L-695"><a href="#L-695"><span class="linenos"> 695</span></a> -</span><span id="L-696"><a href="#L-696"><span class="linenos"> 696</span></a> <span class="k">def</span> <span class="nf">compresscolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">CompressColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-697"><a href="#L-697"><span class="linenos"> 697</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">this</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span> -</span><span id="L-698"><a href="#L-698"><span class="linenos"> 698</span></a> <span class="n">this</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="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">"this"</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-699"><a href="#L-699"><span class="linenos"> 699</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-700"><a href="#L-700"><span class="linenos"> 700</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-701"><a href="#L-701"><span class="linenos"> 701</span></a> -</span><span id="L-702"><a href="#L-702"><span class="linenos"> 702</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"COMPRESS </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-703"><a href="#L-703"><span class="linenos"> 703</span></a> -</span><span id="L-704"><a href="#L-704"><span class="linenos"> 704</span></a> <span class="k">def</span> <span class="nf">generatedasidentitycolumnconstraint_sql</span><span class="p">(</span> -</span><span id="L-705"><a href="#L-705"><span class="linenos"> 705</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GeneratedAsIdentityColumnConstraint</span> -</span><span id="L-706"><a href="#L-706"><span class="linenos"> 706</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-707"><a href="#L-707"><span class="linenos"> 707</span></a> <span class="n">this</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="L-708"><a href="#L-708"><span class="linenos"> 708</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="L-709"><a href="#L-709"><span class="linenos"> 709</span></a> <span class="n">on_null</span> <span class="o">=</span> <span class="s2">" ON NULL"</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">"on_null"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-710"><a href="#L-710"><span class="linenos"> 710</span></a> <span class="n">this</span> <span class="o">=</span> <span class="s2">" ALWAYS"</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="sa">f</span><span class="s2">" BY DEFAULT</span><span class="si">{</span><span class="n">on_null</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-711"><a href="#L-711"><span class="linenos"> 711</span></a> -</span><span id="L-712"><a href="#L-712"><span class="linenos"> 712</span></a> <span class="n">start</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">"start"</span><span class="p">)</span> -</span><span id="L-713"><a href="#L-713"><span class="linenos"> 713</span></a> <span class="n">start</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"START WITH </span><span class="si">{</span><span class="n">start</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">start</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-714"><a href="#L-714"><span class="linenos"> 714</span></a> <span class="n">increment</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">"increment"</span><span class="p">)</span> -</span><span id="L-715"><a href="#L-715"><span class="linenos"> 715</span></a> <span class="n">increment</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" INCREMENT BY </span><span class="si">{</span><span class="n">increment</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">increment</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-716"><a href="#L-716"><span class="linenos"> 716</span></a> <span class="n">minvalue</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">"minvalue"</span><span class="p">)</span> -</span><span id="L-717"><a href="#L-717"><span class="linenos"> 717</span></a> <span class="n">minvalue</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" MINVALUE </span><span class="si">{</span><span class="n">minvalue</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">minvalue</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-718"><a href="#L-718"><span class="linenos"> 718</span></a> <span class="n">maxvalue</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">"maxvalue"</span><span class="p">)</span> -</span><span id="L-719"><a href="#L-719"><span class="linenos"> 719</span></a> <span class="n">maxvalue</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" MAXVALUE </span><span class="si">{</span><span class="n">maxvalue</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">maxvalue</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-720"><a href="#L-720"><span class="linenos"> 720</span></a> <span class="n">cycle</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">"cycle"</span><span class="p">)</span> -</span><span id="L-721"><a href="#L-721"><span class="linenos"> 721</span></a> <span class="n">cycle_sql</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="L-722"><a href="#L-722"><span class="linenos"> 722</span></a> -</span><span id="L-723"><a href="#L-723"><span class="linenos"> 723</span></a> <span class="k">if</span> <span class="n">cycle</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="L-724"><a href="#L-724"><span class="linenos"> 724</span></a> <span class="n">cycle_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="s1">' NO'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="ow">not</span><span class="w"> </span><span class="n">cycle</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"> CYCLE"</span> -</span><span id="L-725"><a href="#L-725"><span class="linenos"> 725</span></a> <span class="n">cycle_sql</span> <span class="o">=</span> <span class="n">cycle_sql</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> <span class="k">if</span> <span class="ow">not</span> <span class="n">start</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">increment</span> <span class="k">else</span> <span class="n">cycle_sql</span> -</span><span id="L-726"><a href="#L-726"><span class="linenos"> 726</span></a> -</span><span id="L-727"><a href="#L-727"><span class="linenos"> 727</span></a> <span class="n">sequence_opts</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="L-728"><a href="#L-728"><span class="linenos"> 728</span></a> <span class="k">if</span> <span class="n">start</span> <span class="ow">or</span> <span class="n">increment</span> <span class="ow">or</span> <span class="n">cycle_sql</span><span class="p">:</span> -</span><span id="L-729"><a href="#L-729"><span class="linenos"> 729</span></a> <span class="n">sequence_opts</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">start</span><span class="si">}{</span><span class="n">increment</span><span class="si">}{</span><span class="n">minvalue</span><span class="si">}{</span><span class="n">maxvalue</span><span class="si">}{</span><span class="n">cycle_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-730"><a href="#L-730"><span class="linenos"> 730</span></a> <span class="n">sequence_opts</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" (</span><span class="si">{</span><span class="n">sequence_opts</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-731"><a href="#L-731"><span class="linenos"> 731</span></a> -</span><span id="L-732"><a href="#L-732"><span class="linenos"> 732</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-733"><a href="#L-733"><span class="linenos"> 733</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">expr</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">expr</span> <span class="k">else</span> <span class="s2">"IDENTITY"</span> +</span><span id="L-696"><a href="#L-696"><span class="linenos"> 696</span></a> <span class="k">def</span> <span class="nf">autoincrementcolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">_</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-697"><a href="#L-697"><span class="linenos"> 697</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">token_sql</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">AUTO_INCREMENT</span><span class="p">)</span> +</span><span id="L-698"><a href="#L-698"><span class="linenos"> 698</span></a> +</span><span id="L-699"><a href="#L-699"><span class="linenos"> 699</span></a> <span class="k">def</span> <span class="nf">compresscolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">CompressColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-700"><a href="#L-700"><span class="linenos"> 700</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">this</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span> +</span><span id="L-701"><a href="#L-701"><span class="linenos"> 701</span></a> <span class="n">this</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="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">"this"</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-702"><a href="#L-702"><span class="linenos"> 702</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-703"><a href="#L-703"><span class="linenos"> 703</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-704"><a href="#L-704"><span class="linenos"> 704</span></a> +</span><span id="L-705"><a href="#L-705"><span class="linenos"> 705</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"COMPRESS </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-706"><a href="#L-706"><span class="linenos"> 706</span></a> +</span><span id="L-707"><a href="#L-707"><span class="linenos"> 707</span></a> <span class="k">def</span> <span class="nf">generatedasidentitycolumnconstraint_sql</span><span class="p">(</span> +</span><span id="L-708"><a href="#L-708"><span class="linenos"> 708</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GeneratedAsIdentityColumnConstraint</span> +</span><span id="L-709"><a href="#L-709"><span class="linenos"> 709</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-710"><a href="#L-710"><span class="linenos"> 710</span></a> <span class="n">this</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="L-711"><a href="#L-711"><span class="linenos"> 711</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-712"><a href="#L-712"><span class="linenos"> 712</span></a> <span class="n">on_null</span> <span class="o">=</span> <span class="s2">" ON NULL"</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">"on_null"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-713"><a href="#L-713"><span class="linenos"> 713</span></a> <span class="n">this</span> <span class="o">=</span> <span class="s2">" ALWAYS"</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="sa">f</span><span class="s2">" BY DEFAULT</span><span class="si">{</span><span class="n">on_null</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-714"><a href="#L-714"><span class="linenos"> 714</span></a> +</span><span id="L-715"><a href="#L-715"><span class="linenos"> 715</span></a> <span class="n">start</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">"start"</span><span class="p">)</span> +</span><span id="L-716"><a href="#L-716"><span class="linenos"> 716</span></a> <span class="n">start</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"START WITH </span><span class="si">{</span><span class="n">start</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">start</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-717"><a href="#L-717"><span class="linenos"> 717</span></a> <span class="n">increment</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">"increment"</span><span class="p">)</span> +</span><span id="L-718"><a href="#L-718"><span class="linenos"> 718</span></a> <span class="n">increment</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" INCREMENT BY </span><span class="si">{</span><span class="n">increment</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">increment</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-719"><a href="#L-719"><span class="linenos"> 719</span></a> <span class="n">minvalue</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">"minvalue"</span><span class="p">)</span> +</span><span id="L-720"><a href="#L-720"><span class="linenos"> 720</span></a> <span class="n">minvalue</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" MINVALUE </span><span class="si">{</span><span class="n">minvalue</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">minvalue</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-721"><a href="#L-721"><span class="linenos"> 721</span></a> <span class="n">maxvalue</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">"maxvalue"</span><span class="p">)</span> +</span><span id="L-722"><a href="#L-722"><span class="linenos"> 722</span></a> <span class="n">maxvalue</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" MAXVALUE </span><span class="si">{</span><span class="n">maxvalue</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">maxvalue</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-723"><a href="#L-723"><span class="linenos"> 723</span></a> <span class="n">cycle</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">"cycle"</span><span class="p">)</span> +</span><span id="L-724"><a href="#L-724"><span class="linenos"> 724</span></a> <span class="n">cycle_sql</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="L-725"><a href="#L-725"><span class="linenos"> 725</span></a> +</span><span id="L-726"><a href="#L-726"><span class="linenos"> 726</span></a> <span class="k">if</span> <span class="n">cycle</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-727"><a href="#L-727"><span class="linenos"> 727</span></a> <span class="n">cycle_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="s1">' NO'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="ow">not</span><span class="w"> </span><span class="n">cycle</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"> CYCLE"</span> +</span><span id="L-728"><a href="#L-728"><span class="linenos"> 728</span></a> <span class="n">cycle_sql</span> <span class="o">=</span> <span class="n">cycle_sql</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> <span class="k">if</span> <span class="ow">not</span> <span class="n">start</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">increment</span> <span class="k">else</span> <span class="n">cycle_sql</span> +</span><span id="L-729"><a href="#L-729"><span class="linenos"> 729</span></a> +</span><span id="L-730"><a href="#L-730"><span class="linenos"> 730</span></a> <span class="n">sequence_opts</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="L-731"><a href="#L-731"><span class="linenos"> 731</span></a> <span class="k">if</span> <span class="n">start</span> <span class="ow">or</span> <span class="n">increment</span> <span class="ow">or</span> <span class="n">cycle_sql</span><span class="p">:</span> +</span><span id="L-732"><a href="#L-732"><span class="linenos"> 732</span></a> <span class="n">sequence_opts</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">start</span><span class="si">}{</span><span class="n">increment</span><span class="si">}{</span><span class="n">minvalue</span><span class="si">}{</span><span class="n">maxvalue</span><span class="si">}{</span><span class="n">cycle_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-733"><a href="#L-733"><span class="linenos"> 733</span></a> <span class="n">sequence_opts</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" (</span><span class="si">{</span><span class="n">sequence_opts</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-734"><a href="#L-734"><span class="linenos"> 734</span></a> -</span><span id="L-735"><a href="#L-735"><span class="linenos"> 735</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"GENERATED</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> AS </span><span class="si">{</span><span class="n">expr</span><span class="si">}{</span><span class="n">sequence_opts</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-736"><a href="#L-736"><span class="linenos"> 736</span></a> -</span><span id="L-737"><a href="#L-737"><span class="linenos"> 737</span></a> <span class="k">def</span> <span class="nf">generatedasrowcolumnconstraint_sql</span><span class="p">(</span> -</span><span id="L-738"><a href="#L-738"><span class="linenos"> 738</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GeneratedAsRowColumnConstraint</span> -</span><span id="L-739"><a href="#L-739"><span class="linenos"> 739</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-740"><a href="#L-740"><span class="linenos"> 740</span></a> <span class="n">start</span> <span class="o">=</span> <span class="s2">"START"</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">"start"</span><span class="p">]</span> <span class="k">else</span> <span class="s2">"END"</span> -</span><span id="L-741"><a href="#L-741"><span class="linenos"> 741</span></a> <span class="n">hidden</span> <span class="o">=</span> <span class="s2">" HIDDEN"</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">"hidden"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-742"><a href="#L-742"><span class="linenos"> 742</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"GENERATED ALWAYS AS ROW </span><span class="si">{</span><span class="n">start</span><span class="si">}{</span><span class="n">hidden</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-743"><a href="#L-743"><span class="linenos"> 743</span></a> -</span><span id="L-744"><a href="#L-744"><span class="linenos"> 744</span></a> <span class="k">def</span> <span class="nf">periodforsystemtimeconstraint_sql</span><span class="p">(</span> -</span><span id="L-745"><a href="#L-745"><span class="linenos"> 745</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">PeriodForSystemTimeConstraint</span> -</span><span id="L-746"><a href="#L-746"><span class="linenos"> 746</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-747"><a href="#L-747"><span class="linenos"> 747</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PERIOD FOR SYSTEM_TIME (</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-748"><a href="#L-748"><span class="linenos"> 748</span></a> -</span><span id="L-749"><a href="#L-749"><span class="linenos"> 749</span></a> <span class="k">def</span> <span class="nf">notnullcolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">NotNullColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-750"><a href="#L-750"><span class="linenos"> 750</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="s1">''</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">'allow_null'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">'NOT '</span><span class="si">}</span><span class="s2">NULL"</span> +</span><span id="L-735"><a href="#L-735"><span class="linenos"> 735</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-736"><a href="#L-736"><span class="linenos"> 736</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">expr</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">expr</span> <span class="k">else</span> <span class="s2">"IDENTITY"</span> +</span><span id="L-737"><a href="#L-737"><span class="linenos"> 737</span></a> +</span><span id="L-738"><a href="#L-738"><span class="linenos"> 738</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"GENERATED</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> AS </span><span class="si">{</span><span class="n">expr</span><span class="si">}{</span><span class="n">sequence_opts</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-739"><a href="#L-739"><span class="linenos"> 739</span></a> +</span><span id="L-740"><a href="#L-740"><span class="linenos"> 740</span></a> <span class="k">def</span> <span class="nf">generatedasrowcolumnconstraint_sql</span><span class="p">(</span> +</span><span id="L-741"><a href="#L-741"><span class="linenos"> 741</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GeneratedAsRowColumnConstraint</span> +</span><span id="L-742"><a href="#L-742"><span class="linenos"> 742</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-743"><a href="#L-743"><span class="linenos"> 743</span></a> <span class="n">start</span> <span class="o">=</span> <span class="s2">"START"</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">"start"</span><span class="p">]</span> <span class="k">else</span> <span class="s2">"END"</span> +</span><span id="L-744"><a href="#L-744"><span class="linenos"> 744</span></a> <span class="n">hidden</span> <span class="o">=</span> <span class="s2">" HIDDEN"</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">"hidden"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-745"><a href="#L-745"><span class="linenos"> 745</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"GENERATED ALWAYS AS ROW </span><span class="si">{</span><span class="n">start</span><span class="si">}{</span><span class="n">hidden</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-746"><a href="#L-746"><span class="linenos"> 746</span></a> +</span><span id="L-747"><a href="#L-747"><span class="linenos"> 747</span></a> <span class="k">def</span> <span class="nf">periodforsystemtimeconstraint_sql</span><span class="p">(</span> +</span><span id="L-748"><a href="#L-748"><span class="linenos"> 748</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">PeriodForSystemTimeConstraint</span> +</span><span id="L-749"><a href="#L-749"><span class="linenos"> 749</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-750"><a href="#L-750"><span class="linenos"> 750</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PERIOD FOR SYSTEM_TIME (</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-751"><a href="#L-751"><span class="linenos"> 751</span></a> -</span><span id="L-752"><a href="#L-752"><span class="linenos"> 752</span></a> <span class="k">def</span> <span class="nf">transformcolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TransformColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-753"><a href="#L-753"><span class="linenos"> 753</span></a> <span class="k">return</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">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-752"><a href="#L-752"><span class="linenos"> 752</span></a> <span class="k">def</span> <span class="nf">notnullcolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">NotNullColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-753"><a href="#L-753"><span class="linenos"> 753</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="s1">''</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">'allow_null'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">'NOT '</span><span class="si">}</span><span class="s2">NULL"</span> </span><span id="L-754"><a href="#L-754"><span class="linenos"> 754</span></a> -</span><span id="L-755"><a href="#L-755"><span class="linenos"> 755</span></a> <span class="k">def</span> <span class="nf">primarykeycolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">PrimaryKeyColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-756"><a href="#L-756"><span class="linenos"> 756</span></a> <span class="n">desc</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">"desc"</span><span class="p">)</span> -</span><span id="L-757"><a href="#L-757"><span class="linenos"> 757</span></a> <span class="k">if</span> <span class="n">desc</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="L-758"><a href="#L-758"><span class="linenos"> 758</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PRIMARY KEY</span><span class="si">{</span><span class="s1">' DESC'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">desc</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">' ASC'</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-759"><a href="#L-759"><span class="linenos"> 759</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PRIMARY KEY"</span> -</span><span id="L-760"><a href="#L-760"><span class="linenos"> 760</span></a> -</span><span id="L-761"><a href="#L-761"><span class="linenos"> 761</span></a> <span class="k">def</span> <span class="nf">uniquecolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">UniqueColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-762"><a href="#L-762"><span class="linenos"> 762</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-763"><a href="#L-763"><span class="linenos"> 763</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-764"><a href="#L-764"><span class="linenos"> 764</span></a> <span class="n">index_type</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">"index_type"</span><span class="p">)</span> -</span><span id="L-765"><a href="#L-765"><span class="linenos"> 765</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-766"><a href="#L-766"><span class="linenos"> 766</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"UNIQUE</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="s2">"</span> -</span><span id="L-767"><a href="#L-767"><span class="linenos"> 767</span></a> -</span><span id="L-768"><a href="#L-768"><span class="linenos"> 768</span></a> <span class="k">def</span> <span class="nf">createable_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">,</span> <span class="n">locations</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">DefaultDict</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-769"><a href="#L-769"><span class="linenos"> 769</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">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="L-755"><a href="#L-755"><span class="linenos"> 755</span></a> <span class="k">def</span> <span class="nf">transformcolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TransformColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-756"><a href="#L-756"><span class="linenos"> 756</span></a> <span class="k">return</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">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-757"><a href="#L-757"><span class="linenos"> 757</span></a> +</span><span id="L-758"><a href="#L-758"><span class="linenos"> 758</span></a> <span class="k">def</span> <span class="nf">primarykeycolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">PrimaryKeyColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-759"><a href="#L-759"><span class="linenos"> 759</span></a> <span class="n">desc</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">"desc"</span><span class="p">)</span> +</span><span id="L-760"><a href="#L-760"><span class="linenos"> 760</span></a> <span class="k">if</span> <span class="n">desc</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-761"><a href="#L-761"><span class="linenos"> 761</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PRIMARY KEY</span><span class="si">{</span><span class="s1">' DESC'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">desc</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">' ASC'</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-762"><a href="#L-762"><span class="linenos"> 762</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PRIMARY KEY"</span> +</span><span id="L-763"><a href="#L-763"><span class="linenos"> 763</span></a> +</span><span id="L-764"><a href="#L-764"><span class="linenos"> 764</span></a> <span class="k">def</span> <span class="nf">uniquecolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">UniqueColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-765"><a href="#L-765"><span class="linenos"> 765</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-766"><a href="#L-766"><span class="linenos"> 766</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-767"><a href="#L-767"><span class="linenos"> 767</span></a> <span class="n">index_type</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">"index_type"</span><span class="p">)</span> +</span><span id="L-768"><a href="#L-768"><span class="linenos"> 768</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-769"><a href="#L-769"><span class="linenos"> 769</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"UNIQUE</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="s2">"</span> </span><span id="L-770"><a href="#L-770"><span class="linenos"> 770</span></a> -</span><span id="L-771"><a href="#L-771"><span class="linenos"> 771</span></a> <span class="k">def</span> <span class="nf">create_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-772"><a href="#L-772"><span class="linenos"> 772</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 class="o">.</span><span class="n">upper</span><span class="p">()</span> -</span><span id="L-773"><a href="#L-773"><span class="linenos"> 773</span></a> <span class="n">properties</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">"properties"</span><span class="p">)</span> -</span><span id="L-774"><a href="#L-774"><span class="linenos"> 774</span></a> <span class="n">properties_locs</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">locate_properties</span><span class="p">(</span><span class="n">properties</span><span class="p">)</span> <span class="k">if</span> <span class="n">properties</span> <span class="k">else</span> <span class="n">defaultdict</span><span class="p">()</span> -</span><span id="L-775"><a href="#L-775"><span class="linenos"> 775</span></a> -</span><span id="L-776"><a href="#L-776"><span class="linenos"> 776</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">createable_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">properties_locs</span><span class="p">)</span> -</span><span id="L-777"><a href="#L-777"><span class="linenos"> 777</span></a> -</span><span id="L-778"><a href="#L-778"><span class="linenos"> 778</span></a> <span class="n">properties_sql</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="L-779"><a href="#L-779"><span class="linenos"> 779</span></a> <span class="k">if</span> <span class="n">properties_locs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">)</span> <span class="ow">or</span> <span class="n">properties_locs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span> -</span><span id="L-780"><a href="#L-780"><span class="linenos"> 780</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span> -</span><span id="L-781"><a href="#L-781"><span class="linenos"> 781</span></a> <span class="p">):</span> -</span><span id="L-782"><a href="#L-782"><span class="linenos"> 782</span></a> <span class="n">properties_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><span id="L-783"><a href="#L-783"><span class="linenos"> 783</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span> -</span><span id="L-784"><a href="#L-784"><span class="linenos"> 784</span></a> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span> -</span><span id="L-785"><a href="#L-785"><span class="linenos"> 785</span></a> <span class="o">*</span><span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">],</span> -</span><span id="L-786"><a href="#L-786"><span class="linenos"> 786</span></a> <span class="o">*</span><span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">],</span> -</span><span id="L-787"><a href="#L-787"><span class="linenos"> 787</span></a> <span class="p">]</span> -</span><span id="L-788"><a href="#L-788"><span class="linenos"> 788</span></a> <span class="p">)</span> -</span><span id="L-789"><a href="#L-789"><span class="linenos"> 789</span></a> <span class="p">)</span> -</span><span id="L-790"><a href="#L-790"><span class="linenos"> 790</span></a> -</span><span id="L-791"><a href="#L-791"><span class="linenos"> 791</span></a> <span class="n">begin</span> <span class="o">=</span> <span class="s2">" BEGIN"</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">"begin"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-792"><a href="#L-792"><span class="linenos"> 792</span></a> <span class="n">end</span> <span class="o">=</span> <span class="s2">" END"</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">"end"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-771"><a href="#L-771"><span class="linenos"> 771</span></a> <span class="k">def</span> <span class="nf">createable_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">,</span> <span class="n">locations</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">DefaultDict</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-772"><a href="#L-772"><span class="linenos"> 772</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">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="L-773"><a href="#L-773"><span class="linenos"> 773</span></a> +</span><span id="L-774"><a href="#L-774"><span class="linenos"> 774</span></a> <span class="k">def</span> <span class="nf">create_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-775"><a href="#L-775"><span class="linenos"> 775</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 class="o">.</span><span class="n">upper</span><span class="p">()</span> +</span><span id="L-776"><a href="#L-776"><span class="linenos"> 776</span></a> <span class="n">properties</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">"properties"</span><span class="p">)</span> +</span><span id="L-777"><a href="#L-777"><span class="linenos"> 777</span></a> <span class="n">properties_locs</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">locate_properties</span><span class="p">(</span><span class="n">properties</span><span class="p">)</span> <span class="k">if</span> <span class="n">properties</span> <span class="k">else</span> <span class="n">defaultdict</span><span class="p">()</span> +</span><span id="L-778"><a href="#L-778"><span class="linenos"> 778</span></a> +</span><span id="L-779"><a href="#L-779"><span class="linenos"> 779</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">createable_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">properties_locs</span><span class="p">)</span> +</span><span id="L-780"><a href="#L-780"><span class="linenos"> 780</span></a> +</span><span id="L-781"><a href="#L-781"><span class="linenos"> 781</span></a> <span class="n">properties_sql</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="L-782"><a href="#L-782"><span class="linenos"> 782</span></a> <span class="k">if</span> <span class="n">properties_locs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">)</span> <span class="ow">or</span> <span class="n">properties_locs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span> +</span><span id="L-783"><a href="#L-783"><span class="linenos"> 783</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span> +</span><span id="L-784"><a href="#L-784"><span class="linenos"> 784</span></a> <span class="p">):</span> +</span><span id="L-785"><a href="#L-785"><span class="linenos"> 785</span></a> <span class="n">properties_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><span id="L-786"><a href="#L-786"><span class="linenos"> 786</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span> +</span><span id="L-787"><a href="#L-787"><span class="linenos"> 787</span></a> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span> +</span><span id="L-788"><a href="#L-788"><span class="linenos"> 788</span></a> <span class="o">*</span><span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">],</span> +</span><span id="L-789"><a href="#L-789"><span class="linenos"> 789</span></a> <span class="o">*</span><span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">],</span> +</span><span id="L-790"><a href="#L-790"><span class="linenos"> 790</span></a> <span class="p">]</span> +</span><span id="L-791"><a href="#L-791"><span class="linenos"> 791</span></a> <span class="p">)</span> +</span><span id="L-792"><a href="#L-792"><span class="linenos"> 792</span></a> <span class="p">)</span> </span><span id="L-793"><a href="#L-793"><span class="linenos"> 793</span></a> -</span><span id="L-794"><a href="#L-794"><span class="linenos"> 794</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-795"><a href="#L-795"><span class="linenos"> 795</span></a> <span class="k">if</span> <span class="n">expression_sql</span><span class="p">:</span> -</span><span id="L-796"><a href="#L-796"><span class="linenos"> 796</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">begin</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="n">expression_sql</span><span class="si">}{</span><span class="n">end</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-797"><a href="#L-797"><span class="linenos"> 797</span></a> -</span><span id="L-798"><a href="#L-798"><span class="linenos"> 798</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">CREATE_FUNCTION_RETURN_AS</span> <span class="ow">or</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">Return</span><span class="p">):</span> -</span><span id="L-799"><a href="#L-799"><span class="linenos"> 799</span></a> <span class="k">if</span> <span class="n">properties_locs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_ALIAS</span><span class="p">):</span> -</span><span id="L-800"><a href="#L-800"><span class="linenos"> 800</span></a> <span class="n">postalias_props_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span> -</span><span id="L-801"><a href="#L-801"><span class="linenos"> 801</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span> -</span><span id="L-802"><a href="#L-802"><span class="linenos"> 802</span></a> <span class="n">expressions</span><span class="o">=</span><span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_ALIAS</span><span class="p">]</span> -</span><span id="L-803"><a href="#L-803"><span class="linenos"> 803</span></a> <span class="p">),</span> -</span><span id="L-804"><a href="#L-804"><span class="linenos"> 804</span></a> <span class="n">wrapped</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> -</span><span id="L-805"><a href="#L-805"><span class="linenos"> 805</span></a> <span class="p">)</span> -</span><span id="L-806"><a href="#L-806"><span class="linenos"> 806</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="n">postalias_props_sql</span><span class="si">}{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-807"><a href="#L-807"><span class="linenos"> 807</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-808"><a href="#L-808"><span class="linenos"> 808</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS</span><span class="si">{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-809"><a href="#L-809"><span class="linenos"> 809</span></a> -</span><span id="L-810"><a href="#L-810"><span class="linenos"> 810</span></a> <span class="n">postindex_props_sql</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="L-811"><a href="#L-811"><span class="linenos"> 811</span></a> <span class="k">if</span> <span class="n">properties_locs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_INDEX</span><span class="p">):</span> -</span><span id="L-812"><a href="#L-812"><span class="linenos"> 812</span></a> <span class="n">postindex_props_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span> -</span><span id="L-813"><a href="#L-813"><span class="linenos"> 813</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_INDEX</span><span class="p">]),</span> -</span><span id="L-814"><a href="#L-814"><span class="linenos"> 814</span></a> <span class="n">wrapped</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> -</span><span id="L-815"><a href="#L-815"><span class="linenos"> 815</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> -</span><span id="L-816"><a href="#L-816"><span class="linenos"> 816</span></a> <span class="p">)</span> -</span><span id="L-817"><a href="#L-817"><span class="linenos"> 817</span></a> -</span><span id="L-818"><a href="#L-818"><span class="linenos"> 818</span></a> <span class="n">indexes</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">"indexes"</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="kc">False</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-819"><a href="#L-819"><span class="linenos"> 819</span></a> <span class="n">indexes</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">indexes</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">indexes</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-820"><a href="#L-820"><span class="linenos"> 820</span></a> <span class="n">index_sql</span> <span class="o">=</span> <span class="n">indexes</span> <span class="o">+</span> <span class="n">postindex_props_sql</span> -</span><span id="L-821"><a href="#L-821"><span class="linenos"> 821</span></a> -</span><span id="L-822"><a href="#L-822"><span class="linenos"> 822</span></a> <span class="n">replace</span> <span class="o">=</span> <span class="s2">" OR REPLACE"</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">"replace"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-823"><a href="#L-823"><span class="linenos"> 823</span></a> <span class="n">unique</span> <span class="o">=</span> <span class="s2">" UNIQUE"</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">"unique"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-794"><a href="#L-794"><span class="linenos"> 794</span></a> <span class="n">begin</span> <span class="o">=</span> <span class="s2">" BEGIN"</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">"begin"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-795"><a href="#L-795"><span class="linenos"> 795</span></a> <span class="n">end</span> <span class="o">=</span> <span class="s2">" END"</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">"end"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-796"><a href="#L-796"><span class="linenos"> 796</span></a> +</span><span id="L-797"><a href="#L-797"><span class="linenos"> 797</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-798"><a href="#L-798"><span class="linenos"> 798</span></a> <span class="k">if</span> <span class="n">expression_sql</span><span class="p">:</span> +</span><span id="L-799"><a href="#L-799"><span class="linenos"> 799</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">begin</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="n">expression_sql</span><span class="si">}{</span><span class="n">end</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-800"><a href="#L-800"><span class="linenos"> 800</span></a> +</span><span id="L-801"><a href="#L-801"><span class="linenos"> 801</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">CREATE_FUNCTION_RETURN_AS</span> <span class="ow">or</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">Return</span><span class="p">):</span> +</span><span id="L-802"><a href="#L-802"><span class="linenos"> 802</span></a> <span class="k">if</span> <span class="n">properties_locs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_ALIAS</span><span class="p">):</span> +</span><span id="L-803"><a href="#L-803"><span class="linenos"> 803</span></a> <span class="n">postalias_props_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span> +</span><span id="L-804"><a href="#L-804"><span class="linenos"> 804</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span> +</span><span id="L-805"><a href="#L-805"><span class="linenos"> 805</span></a> <span class="n">expressions</span><span class="o">=</span><span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_ALIAS</span><span class="p">]</span> +</span><span id="L-806"><a href="#L-806"><span class="linenos"> 806</span></a> <span class="p">),</span> +</span><span id="L-807"><a href="#L-807"><span class="linenos"> 807</span></a> <span class="n">wrapped</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> +</span><span id="L-808"><a href="#L-808"><span class="linenos"> 808</span></a> <span class="p">)</span> +</span><span id="L-809"><a href="#L-809"><span class="linenos"> 809</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="n">postalias_props_sql</span><span class="si">}{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-810"><a href="#L-810"><span class="linenos"> 810</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-811"><a href="#L-811"><span class="linenos"> 811</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS</span><span class="si">{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-812"><a href="#L-812"><span class="linenos"> 812</span></a> +</span><span id="L-813"><a href="#L-813"><span class="linenos"> 813</span></a> <span class="n">postindex_props_sql</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="L-814"><a href="#L-814"><span class="linenos"> 814</span></a> <span class="k">if</span> <span class="n">properties_locs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_INDEX</span><span class="p">):</span> +</span><span id="L-815"><a href="#L-815"><span class="linenos"> 815</span></a> <span class="n">postindex_props_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span> +</span><span id="L-816"><a href="#L-816"><span class="linenos"> 816</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_INDEX</span><span class="p">]),</span> +</span><span id="L-817"><a href="#L-817"><span class="linenos"> 817</span></a> <span class="n">wrapped</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> +</span><span id="L-818"><a href="#L-818"><span class="linenos"> 818</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> +</span><span id="L-819"><a href="#L-819"><span class="linenos"> 819</span></a> <span class="p">)</span> +</span><span id="L-820"><a href="#L-820"><span class="linenos"> 820</span></a> +</span><span id="L-821"><a href="#L-821"><span class="linenos"> 821</span></a> <span class="n">indexes</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">"indexes"</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="kc">False</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-822"><a href="#L-822"><span class="linenos"> 822</span></a> <span class="n">indexes</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">indexes</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">indexes</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-823"><a href="#L-823"><span class="linenos"> 823</span></a> <span class="n">index_sql</span> <span class="o">=</span> <span class="n">indexes</span> <span class="o">+</span> <span class="n">postindex_props_sql</span> </span><span id="L-824"><a href="#L-824"><span class="linenos"> 824</span></a> -</span><span id="L-825"><a href="#L-825"><span class="linenos"> 825</span></a> <span class="n">postcreate_props_sql</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="L-826"><a href="#L-826"><span class="linenos"> 826</span></a> <span class="k">if</span> <span class="n">properties_locs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">):</span> -</span><span id="L-827"><a href="#L-827"><span class="linenos"> 827</span></a> <span class="n">postcreate_props_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span> -</span><span id="L-828"><a href="#L-828"><span class="linenos"> 828</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">]),</span> -</span><span id="L-829"><a href="#L-829"><span class="linenos"> 829</span></a> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> -</span><span id="L-830"><a href="#L-830"><span class="linenos"> 830</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> -</span><span id="L-831"><a href="#L-831"><span class="linenos"> 831</span></a> <span class="n">wrapped</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> -</span><span id="L-832"><a href="#L-832"><span class="linenos"> 832</span></a> <span class="p">)</span> -</span><span id="L-833"><a href="#L-833"><span class="linenos"> 833</span></a> -</span><span id="L-834"><a href="#L-834"><span class="linenos"> 834</span></a> <span class="n">modifiers</span> <span class="o">=</span> <span class="s2">""</span><span class="o">.</span><span class="n">join</span><span class="p">((</span><span class="n">replace</span><span class="p">,</span> <span class="n">unique</span><span class="p">,</span> <span class="n">postcreate_props_sql</span><span class="p">))</span> -</span><span id="L-835"><a href="#L-835"><span class="linenos"> 835</span></a> -</span><span id="L-836"><a href="#L-836"><span class="linenos"> 836</span></a> <span class="n">postexpression_props_sql</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="L-837"><a href="#L-837"><span class="linenos"> 837</span></a> <span class="k">if</span> <span class="n">properties_locs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_EXPRESSION</span><span class="p">):</span> -</span><span id="L-838"><a href="#L-838"><span class="linenos"> 838</span></a> <span class="n">postexpression_props_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span> -</span><span id="L-839"><a href="#L-839"><span class="linenos"> 839</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span> -</span><span id="L-840"><a href="#L-840"><span class="linenos"> 840</span></a> <span class="n">expressions</span><span class="o">=</span><span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_EXPRESSION</span><span class="p">]</span> -</span><span id="L-841"><a href="#L-841"><span class="linenos"> 841</span></a> <span class="p">),</span> -</span><span id="L-842"><a href="#L-842"><span class="linenos"> 842</span></a> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> -</span><span id="L-843"><a href="#L-843"><span class="linenos"> 843</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> -</span><span id="L-844"><a href="#L-844"><span class="linenos"> 844</span></a> <span class="n">wrapped</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> -</span><span id="L-845"><a href="#L-845"><span class="linenos"> 845</span></a> <span class="p">)</span> -</span><span id="L-846"><a href="#L-846"><span class="linenos"> 846</span></a> -</span><span id="L-847"><a href="#L-847"><span class="linenos"> 847</span></a> <span class="n">exists_sql</span> <span class="o">=</span> <span class="s2">" IF NOT 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-848"><a href="#L-848"><span class="linenos"> 848</span></a> <span class="n">no_schema_binding</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="L-849"><a href="#L-849"><span class="linenos"> 849</span></a> <span class="s2">" WITH NO SCHEMA BINDING"</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">"no_schema_binding"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-850"><a href="#L-850"><span class="linenos"> 850</span></a> <span class="p">)</span> -</span><span id="L-851"><a href="#L-851"><span class="linenos"> 851</span></a> -</span><span id="L-852"><a href="#L-852"><span class="linenos"> 852</span></a> <span class="n">clone</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"clone"</span><span class="p">)</span> -</span><span id="L-853"><a href="#L-853"><span class="linenos"> 853</span></a> <span class="n">clone</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">clone</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">clone</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-825"><a href="#L-825"><span class="linenos"> 825</span></a> <span class="n">replace</span> <span class="o">=</span> <span class="s2">" OR REPLACE"</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">"replace"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-826"><a href="#L-826"><span class="linenos"> 826</span></a> <span class="n">unique</span> <span class="o">=</span> <span class="s2">" UNIQUE"</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">"unique"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-827"><a href="#L-827"><span class="linenos"> 827</span></a> +</span><span id="L-828"><a href="#L-828"><span class="linenos"> 828</span></a> <span class="n">postcreate_props_sql</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="L-829"><a href="#L-829"><span class="linenos"> 829</span></a> <span class="k">if</span> <span class="n">properties_locs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">):</span> +</span><span id="L-830"><a href="#L-830"><span class="linenos"> 830</span></a> <span class="n">postcreate_props_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span> +</span><span id="L-831"><a href="#L-831"><span class="linenos"> 831</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">]),</span> +</span><span id="L-832"><a href="#L-832"><span class="linenos"> 832</span></a> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> +</span><span id="L-833"><a href="#L-833"><span class="linenos"> 833</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> +</span><span id="L-834"><a href="#L-834"><span class="linenos"> 834</span></a> <span class="n">wrapped</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> +</span><span id="L-835"><a href="#L-835"><span class="linenos"> 835</span></a> <span class="p">)</span> +</span><span id="L-836"><a href="#L-836"><span class="linenos"> 836</span></a> +</span><span id="L-837"><a href="#L-837"><span class="linenos"> 837</span></a> <span class="n">modifiers</span> <span class="o">=</span> <span class="s2">""</span><span class="o">.</span><span class="n">join</span><span class="p">((</span><span class="n">replace</span><span class="p">,</span> <span class="n">unique</span><span class="p">,</span> <span class="n">postcreate_props_sql</span><span class="p">))</span> +</span><span id="L-838"><a href="#L-838"><span class="linenos"> 838</span></a> +</span><span id="L-839"><a href="#L-839"><span class="linenos"> 839</span></a> <span class="n">postexpression_props_sql</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="L-840"><a href="#L-840"><span class="linenos"> 840</span></a> <span class="k">if</span> <span class="n">properties_locs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_EXPRESSION</span><span class="p">):</span> +</span><span id="L-841"><a href="#L-841"><span class="linenos"> 841</span></a> <span class="n">postexpression_props_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span> +</span><span id="L-842"><a href="#L-842"><span class="linenos"> 842</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span> +</span><span id="L-843"><a href="#L-843"><span class="linenos"> 843</span></a> <span class="n">expressions</span><span class="o">=</span><span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_EXPRESSION</span><span class="p">]</span> +</span><span id="L-844"><a href="#L-844"><span class="linenos"> 844</span></a> <span class="p">),</span> +</span><span id="L-845"><a href="#L-845"><span class="linenos"> 845</span></a> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> +</span><span id="L-846"><a href="#L-846"><span class="linenos"> 846</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> +</span><span id="L-847"><a href="#L-847"><span class="linenos"> 847</span></a> <span class="n">wrapped</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> +</span><span id="L-848"><a href="#L-848"><span class="linenos"> 848</span></a> <span class="p">)</span> +</span><span id="L-849"><a href="#L-849"><span class="linenos"> 849</span></a> +</span><span id="L-850"><a href="#L-850"><span class="linenos"> 850</span></a> <span class="n">exists_sql</span> <span class="o">=</span> <span class="s2">" IF NOT 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-851"><a href="#L-851"><span class="linenos"> 851</span></a> <span class="n">no_schema_binding</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="L-852"><a href="#L-852"><span class="linenos"> 852</span></a> <span class="s2">" WITH NO SCHEMA BINDING"</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">"no_schema_binding"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-853"><a href="#L-853"><span class="linenos"> 853</span></a> <span class="p">)</span> </span><span id="L-854"><a href="#L-854"><span class="linenos"> 854</span></a> -</span><span id="L-855"><a href="#L-855"><span class="linenos"> 855</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"CREATE</span><span class="si">{</span><span class="n">modifiers</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">exists_sql</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">properties_sql</span><span class="si">}{</span><span class="n">expression_sql</span><span class="si">}{</span><span class="n">postexpression_props_sql</span><span class="si">}{</span><span class="n">index_sql</span><span class="si">}{</span><span class="n">no_schema_binding</span><span class="si">}{</span><span class="n">clone</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-856"><a href="#L-856"><span class="linenos"> 856</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">expression_sql</span><span class="p">)</span> +</span><span id="L-855"><a href="#L-855"><span class="linenos"> 855</span></a> <span class="n">clone</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"clone"</span><span class="p">)</span> +</span><span id="L-856"><a href="#L-856"><span class="linenos"> 856</span></a> <span class="n">clone</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">clone</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">clone</span> <span class="k">else</span> <span class="s2">""</span> </span><span id="L-857"><a href="#L-857"><span class="linenos"> 857</span></a> -</span><span id="L-858"><a href="#L-858"><span class="linenos"> 858</span></a> <span class="k">def</span> <span class="nf">clone_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Clone</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-859"><a href="#L-859"><span class="linenos"> 859</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-860"><a href="#L-860"><span class="linenos"> 860</span></a> <span class="n">shallow</span> <span class="o">=</span> <span class="s2">"SHALLOW "</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">"shallow"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-861"><a href="#L-861"><span class="linenos"> 861</span></a> <span class="n">keyword</span> <span class="o">=</span> <span class="s2">"COPY"</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">"copy"</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">SUPPORTS_TABLE_COPY</span> <span class="k">else</span> <span class="s2">"CLONE"</span> -</span><span id="L-862"><a href="#L-862"><span class="linenos"> 862</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">shallow</span><span class="si">}{</span><span class="n">keyword</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">"</span> -</span><span id="L-863"><a href="#L-863"><span class="linenos"> 863</span></a> <span class="n">when</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"when"</span><span class="p">)</span> -</span><span id="L-864"><a href="#L-864"><span class="linenos"> 864</span></a> -</span><span id="L-865"><a href="#L-865"><span class="linenos"> 865</span></a> <span class="k">if</span> <span class="n">when</span><span class="p">:</span> -</span><span id="L-866"><a href="#L-866"><span class="linenos"> 866</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-867"><a href="#L-867"><span class="linenos"> 867</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-868"><a href="#L-868"><span class="linenos"> 868</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">when</span><span class="si">}</span><span class="s2"> (</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">expr</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="L-858"><a href="#L-858"><span class="linenos"> 858</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"CREATE</span><span class="si">{</span><span class="n">modifiers</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">exists_sql</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">properties_sql</span><span class="si">}{</span><span class="n">expression_sql</span><span class="si">}{</span><span class="n">postexpression_props_sql</span><span class="si">}{</span><span class="n">index_sql</span><span class="si">}{</span><span class="n">no_schema_binding</span><span class="si">}{</span><span class="n">clone</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-859"><a href="#L-859"><span class="linenos"> 859</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">expression_sql</span><span class="p">)</span> +</span><span id="L-860"><a href="#L-860"><span class="linenos"> 860</span></a> +</span><span id="L-861"><a href="#L-861"><span class="linenos"> 861</span></a> <span class="k">def</span> <span class="nf">clone_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Clone</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-862"><a href="#L-862"><span class="linenos"> 862</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-863"><a href="#L-863"><span class="linenos"> 863</span></a> <span class="n">shallow</span> <span class="o">=</span> <span class="s2">"SHALLOW "</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">"shallow"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-864"><a href="#L-864"><span class="linenos"> 864</span></a> <span class="n">keyword</span> <span class="o">=</span> <span class="s2">"COPY"</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">"copy"</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">SUPPORTS_TABLE_COPY</span> <span class="k">else</span> <span class="s2">"CLONE"</span> +</span><span id="L-865"><a href="#L-865"><span class="linenos"> 865</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">shallow</span><span class="si">}{</span><span class="n">keyword</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">"</span> +</span><span id="L-866"><a href="#L-866"><span class="linenos"> 866</span></a> +</span><span id="L-867"><a href="#L-867"><span class="linenos"> 867</span></a> <span class="k">def</span> <span class="nf">describe_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Describe</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-868"><a href="#L-868"><span class="linenos"> 868</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"DESCRIBE </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-869"><a href="#L-869"><span class="linenos"> 869</span></a> -</span><span id="L-870"><a href="#L-870"><span class="linenos"> 870</span></a> <span class="k">return</span> <span class="n">this</span> -</span><span id="L-871"><a href="#L-871"><span class="linenos"> 871</span></a> -</span><span id="L-872"><a href="#L-872"><span class="linenos"> 872</span></a> <span class="k">def</span> <span class="nf">describe_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Describe</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-873"><a href="#L-873"><span class="linenos"> 873</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"DESCRIBE </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-874"><a href="#L-874"><span class="linenos"> 874</span></a> -</span><span id="L-875"><a href="#L-875"><span class="linenos"> 875</span></a> <span class="k">def</span> <span class="nf">prepend_ctes</span><span class="p">(</span><span class="bp">self</span><span 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">sql</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-876"><a href="#L-876"><span class="linenos"> 876</span></a> <span class="n">with_</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"with"</span><span class="p">)</span> -</span><span id="L-877"><a href="#L-877"><span class="linenos"> 877</span></a> <span class="k">if</span> <span class="n">with_</span><span class="p">:</span> -</span><span id="L-878"><a href="#L-878"><span class="linenos"> 878</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">with_</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="n">sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-879"><a href="#L-879"><span class="linenos"> 879</span></a> <span class="k">return</span> <span class="n">sql</span> -</span><span id="L-880"><a href="#L-880"><span class="linenos"> 880</span></a> -</span><span id="L-881"><a href="#L-881"><span class="linenos"> 881</span></a> <span class="k">def</span> <span class="nf">with_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">With</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-882"><a href="#L-882"><span class="linenos"> 882</span></a> <span class="n">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="kc">True</span><span class="p">)</span> -</span><span id="L-883"><a href="#L-883"><span class="linenos"> 883</span></a> <span class="n">recursive</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="L-884"><a href="#L-884"><span class="linenos"> 884</span></a> <span class="s2">"RECURSIVE "</span> -</span><span id="L-885"><a href="#L-885"><span class="linenos"> 885</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">CTE_RECURSIVE_KEYWORD_REQUIRED</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">"recursive"</span><span class="p">)</span> -</span><span id="L-886"><a href="#L-886"><span class="linenos"> 886</span></a> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-887"><a href="#L-887"><span class="linenos"> 887</span></a> <span class="p">)</span> -</span><span id="L-888"><a href="#L-888"><span class="linenos"> 888</span></a> -</span><span id="L-889"><a href="#L-889"><span class="linenos"> 889</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"WITH </span><span class="si">{</span><span class="n">recursive</span><span class="si">}{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-890"><a href="#L-890"><span class="linenos"> 890</span></a> -</span><span id="L-891"><a href="#L-891"><span class="linenos"> 891</span></a> <span class="k">def</span> <span class="nf">cte_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">CTE</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-892"><a href="#L-892"><span class="linenos"> 892</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-893"><a href="#L-893"><span class="linenos"> 893</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">alias</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">wrap</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-870"><a href="#L-870"><span class="linenos"> 870</span></a> <span class="k">def</span> <span class="nf">prepend_ctes</span><span class="p">(</span><span class="bp">self</span><span 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">sql</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-871"><a href="#L-871"><span class="linenos"> 871</span></a> <span class="n">with_</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"with"</span><span class="p">)</span> +</span><span id="L-872"><a href="#L-872"><span class="linenos"> 872</span></a> <span class="k">if</span> <span class="n">with_</span><span class="p">:</span> +</span><span id="L-873"><a href="#L-873"><span class="linenos"> 873</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">with_</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="n">sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-874"><a href="#L-874"><span class="linenos"> 874</span></a> <span class="k">return</span> <span class="n">sql</span> +</span><span id="L-875"><a href="#L-875"><span class="linenos"> 875</span></a> +</span><span id="L-876"><a href="#L-876"><span class="linenos"> 876</span></a> <span class="k">def</span> <span class="nf">with_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">With</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-877"><a href="#L-877"><span class="linenos"> 877</span></a> <span class="n">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="kc">True</span><span class="p">)</span> +</span><span id="L-878"><a href="#L-878"><span class="linenos"> 878</span></a> <span class="n">recursive</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="L-879"><a href="#L-879"><span class="linenos"> 879</span></a> <span class="s2">"RECURSIVE "</span> +</span><span id="L-880"><a href="#L-880"><span class="linenos"> 880</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">CTE_RECURSIVE_KEYWORD_REQUIRED</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">"recursive"</span><span class="p">)</span> +</span><span id="L-881"><a href="#L-881"><span class="linenos"> 881</span></a> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-882"><a href="#L-882"><span class="linenos"> 882</span></a> <span class="p">)</span> +</span><span id="L-883"><a href="#L-883"><span class="linenos"> 883</span></a> +</span><span id="L-884"><a href="#L-884"><span class="linenos"> 884</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"WITH </span><span class="si">{</span><span class="n">recursive</span><span class="si">}{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-885"><a href="#L-885"><span class="linenos"> 885</span></a> +</span><span id="L-886"><a href="#L-886"><span class="linenos"> 886</span></a> <span class="k">def</span> <span class="nf">cte_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">CTE</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-887"><a href="#L-887"><span class="linenos"> 887</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-888"><a href="#L-888"><span class="linenos"> 888</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">alias</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">wrap</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-889"><a href="#L-889"><span class="linenos"> 889</span></a> +</span><span id="L-890"><a href="#L-890"><span class="linenos"> 890</span></a> <span class="k">def</span> <span class="nf">tablealias_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TableAlias</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-891"><a href="#L-891"><span class="linenos"> 891</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">"this"</span><span class="p">)</span> +</span><span id="L-892"><a href="#L-892"><span class="linenos"> 892</span></a> <span class="n">columns</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">"columns"</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-893"><a href="#L-893"><span class="linenos"> 893</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">columns</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">columns</span> <span class="k">else</span> <span class="s2">""</span> </span><span id="L-894"><a href="#L-894"><span class="linenos"> 894</span></a> -</span><span id="L-895"><a href="#L-895"><span class="linenos"> 895</span></a> <span class="k">def</span> <span class="nf">tablealias_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TableAlias</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-896"><a href="#L-896"><span class="linenos"> 896</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">"this"</span><span class="p">)</span> -</span><span id="L-897"><a href="#L-897"><span class="linenos"> 897</span></a> <span class="n">columns</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">"columns"</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-898"><a href="#L-898"><span class="linenos"> 898</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">columns</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">columns</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-895"><a href="#L-895"><span class="linenos"> 895</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">alias</span> <span class="ow">and</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">UNNEST_COLUMN_ONLY</span><span class="p">:</span> +</span><span id="L-896"><a href="#L-896"><span class="linenos"> 896</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="s2">"_t"</span> +</span><span id="L-897"><a href="#L-897"><span class="linenos"> 897</span></a> +</span><span id="L-898"><a href="#L-898"><span class="linenos"> 898</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">alias</span><span class="si">}{</span><span class="n">columns</span><span class="si">}</span><span class="s2">"</span> </span><span id="L-899"><a href="#L-899"><span class="linenos"> 899</span></a> -</span><span id="L-900"><a href="#L-900"><span class="linenos"> 900</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">alias</span> <span class="ow">and</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">UNNEST_COLUMN_ONLY</span><span class="p">:</span> -</span><span id="L-901"><a href="#L-901"><span class="linenos"> 901</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="s2">"_t"</span> -</span><span id="L-902"><a href="#L-902"><span class="linenos"> 902</span></a> -</span><span id="L-903"><a href="#L-903"><span class="linenos"> 903</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">alias</span><span class="si">}{</span><span class="n">columns</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-904"><a href="#L-904"><span class="linenos"> 904</span></a> -</span><span id="L-905"><a href="#L-905"><span class="linenos"> 905</span></a> <span class="k">def</span> <span class="nf">bitstring_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">BitString</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-906"><a href="#L-906"><span class="linenos"> 906</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-907"><a href="#L-907"><span class="linenos"> 907</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">BIT_START</span><span class="p">:</span> -</span><span id="L-908"><a href="#L-908"><span class="linenos"> 908</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">dialect</span><span class="o">.</span><span class="n">BIT_START</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">BIT_END</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-909"><a href="#L-909"><span class="linenos"> 909</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="nb">int</span><span class="p">(</span><span class="n">this</span><span class="p">,</span><span class="w"> </span><span class="mi">2</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-910"><a href="#L-910"><span class="linenos"> 910</span></a> -</span><span id="L-911"><a href="#L-911"><span class="linenos"> 911</span></a> <span class="k">def</span> <span class="nf">hexstring_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">HexString</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-912"><a href="#L-912"><span class="linenos"> 912</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-913"><a href="#L-913"><span class="linenos"> 913</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">HEX_START</span><span class="p">:</span> -</span><span id="L-914"><a href="#L-914"><span class="linenos"> 914</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">dialect</span><span class="o">.</span><span class="n">HEX_START</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">HEX_END</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-915"><a href="#L-915"><span class="linenos"> 915</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="nb">int</span><span class="p">(</span><span class="n">this</span><span class="p">,</span><span class="w"> </span><span class="mi">16</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-916"><a href="#L-916"><span class="linenos"> 916</span></a> -</span><span id="L-917"><a href="#L-917"><span class="linenos"> 917</span></a> <span class="k">def</span> <span class="nf">bytestring_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ByteString</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-918"><a href="#L-918"><span class="linenos"> 918</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-919"><a href="#L-919"><span class="linenos"> 919</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">BYTE_START</span><span class="p">:</span> -</span><span id="L-920"><a href="#L-920"><span class="linenos"> 920</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">dialect</span><span class="o">.</span><span class="n">BYTE_START</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">BYTE_END</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-921"><a href="#L-921"><span class="linenos"> 921</span></a> <span class="k">return</span> <span class="n">this</span> -</span><span id="L-922"><a href="#L-922"><span class="linenos"> 922</span></a> -</span><span id="L-923"><a href="#L-923"><span class="linenos"> 923</span></a> <span class="k">def</span> <span class="nf">rawstring_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RawString</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-924"><a href="#L-924"><span class="linenos"> 924</span></a> <span class="n">string</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">escape_str</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">"</span><span class="se">\\</span><span class="s2">"</span><span class="p">,</span> <span class="s2">"</span><span class="se">\\\\</span><span class="s2">"</span><span class="p">))</span> -</span><span id="L-925"><a href="#L-925"><span class="linenos"> 925</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">dialect</span><span class="o">.</span><span class="n">QUOTE_START</span><span class="si">}{</span><span class="n">string</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">QUOTE_END</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-926"><a href="#L-926"><span class="linenos"> 926</span></a> -</span><span id="L-927"><a href="#L-927"><span class="linenos"> 927</span></a> <span class="k">def</span> <span class="nf">datatypeparam_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataTypeParam</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-928"><a href="#L-928"><span class="linenos"> 928</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-929"><a href="#L-929"><span class="linenos"> 929</span></a> <span class="n">specifier</span> <span class="o">=</span> <span class="bp">self</span><span 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-930"><a href="#L-930"><span class="linenos"> 930</span></a> <span class="n">specifier</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">specifier</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">specifier</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">DATA_TYPE_SPECIFIERS_ALLOWED</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-931"><a href="#L-931"><span class="linenos"> 931</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">specifier</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-932"><a href="#L-932"><span class="linenos"> 932</span></a> -</span><span id="L-933"><a href="#L-933"><span class="linenos"> 933</span></a> <span class="k">def</span> <span class="nf">datatype_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-934"><a href="#L-934"><span class="linenos"> 934</span></a> <span class="n">type_value</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> -</span><span id="L-935"><a href="#L-935"><span class="linenos"> 935</span></a> -</span><span id="L-936"><a href="#L-936"><span class="linenos"> 936</span></a> <span class="k">if</span> <span class="n">type_value</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">USERDEFINED</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">"kind"</span><span class="p">):</span> -</span><span id="L-937"><a href="#L-937"><span class="linenos"> 937</span></a> <span class="n">type_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">"kind"</span><span class="p">)</span> -</span><span id="L-938"><a href="#L-938"><span class="linenos"> 938</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-939"><a href="#L-939"><span class="linenos"> 939</span></a> <span class="n">type_sql</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="L-940"><a href="#L-940"><span class="linenos"> 940</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">TYPE_MAPPING</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">type_value</span><span class="p">,</span> <span class="n">type_value</span><span class="o">.</span><span class="n">value</span><span class="p">)</span> -</span><span id="L-941"><a href="#L-941"><span class="linenos"> 941</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">type_value</span><span class="p">,</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="p">)</span> -</span><span id="L-942"><a href="#L-942"><span class="linenos"> 942</span></a> <span class="k">else</span> <span class="n">type_value</span> -</span><span id="L-943"><a href="#L-943"><span class="linenos"> 943</span></a> <span class="p">)</span> -</span><span id="L-944"><a href="#L-944"><span class="linenos"> 944</span></a> -</span><span id="L-945"><a href="#L-945"><span class="linenos"> 945</span></a> <span class="n">nested</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="L-946"><a href="#L-946"><span class="linenos"> 946</span></a> <span class="n">interior</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-947"><a href="#L-947"><span class="linenos"> 947</span></a> <span class="n">values</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="L-948"><a href="#L-948"><span class="linenos"> 948</span></a> -</span><span id="L-949"><a href="#L-949"><span class="linenos"> 949</span></a> <span class="k">if</span> <span class="n">interior</span><span class="p">:</span> -</span><span id="L-950"><a href="#L-950"><span class="linenos"> 950</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">"nested"</span><span class="p">):</span> -</span><span id="L-951"><a href="#L-951"><span class="linenos"> 951</span></a> <span class="n">nested</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">STRUCT_DELIMITER</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="si">}{</span><span class="n">interior</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">STRUCT_DELIMITER</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-952"><a href="#L-952"><span class="linenos"> 952</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">"values"</span><span class="p">)</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="L-953"><a href="#L-953"><span class="linenos"> 953</span></a> <span class="n">delimiters</span> <span class="o">=</span> <span class="p">(</span><span class="s2">"["</span><span class="p">,</span> <span class="s2">"]"</span><span class="p">)</span> <span class="k">if</span> <span class="n">type_value</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">ARRAY</span> <span class="k">else</span> <span class="p">(</span><span class="s2">"("</span><span class="p">,</span> <span class="s2">")"</span><span class="p">)</span> -</span><span id="L-954"><a href="#L-954"><span class="linenos"> 954</span></a> <span class="n">values</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">"values"</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-955"><a href="#L-955"><span class="linenos"> 955</span></a> <span class="n">values</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">delimiters</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="si">}{</span><span class="n">values</span><span class="si">}{</span><span class="n">delimiters</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-956"><a href="#L-956"><span class="linenos"> 956</span></a> <span class="k">elif</span> <span class="n">type_value</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">INTERVAL</span><span class="p">:</span> -</span><span id="L-957"><a href="#L-957"><span class="linenos"> 957</span></a> <span class="n">nested</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">interior</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-958"><a href="#L-958"><span class="linenos"> 958</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-959"><a href="#L-959"><span class="linenos"> 959</span></a> <span class="n">nested</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">interior</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="L-960"><a href="#L-960"><span class="linenos"> 960</span></a> -</span><span id="L-961"><a href="#L-961"><span class="linenos"> 961</span></a> <span class="n">type_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">type_sql</span><span class="si">}{</span><span class="n">nested</span><span class="si">}{</span><span class="n">values</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-962"><a href="#L-962"><span class="linenos"> 962</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">TZ_TO_WITH_TIME_ZONE</span> <span class="ow">and</span> <span class="n">type_value</span> <span class="ow">in</span> <span class="p">(</span> -</span><span id="L-963"><a href="#L-963"><span class="linenos"> 963</span></a> <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">TIMETZ</span><span class="p">,</span> -</span><span id="L-964"><a href="#L-964"><span class="linenos"> 964</span></a> <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">TIMESTAMPTZ</span><span class="p">,</span> -</span><span id="L-965"><a href="#L-965"><span class="linenos"> 965</span></a> <span class="p">):</span> -</span><span id="L-966"><a href="#L-966"><span class="linenos"> 966</span></a> <span class="n">type_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">type_sql</span><span class="si">}</span><span class="s2"> WITH TIME ZONE"</span> -</span><span id="L-967"><a href="#L-967"><span class="linenos"> 967</span></a> -</span><span id="L-968"><a href="#L-968"><span class="linenos"> 968</span></a> <span class="k">return</span> <span class="n">type_sql</span> -</span><span id="L-969"><a href="#L-969"><span class="linenos"> 969</span></a> -</span><span id="L-970"><a href="#L-970"><span class="linenos"> 970</span></a> <span class="k">def</span> <span class="nf">directory_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Directory</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-971"><a href="#L-971"><span class="linenos"> 971</span></a> <span class="n">local</span> <span class="o">=</span> <span class="s2">"LOCAL "</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">"local"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-972"><a href="#L-972"><span class="linenos"> 972</span></a> <span class="n">row_format</span> <span class="o">=</span> <span class="bp">self</span><span 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"</span><span class="p">)</span> -</span><span id="L-973"><a href="#L-973"><span class="linenos"> 973</span></a> <span class="n">row_format</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">row_format</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">row_format</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-974"><a href="#L-974"><span class="linenos"> 974</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">local</span><span class="si">}</span><span class="s2">DIRECTORY </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">row_format</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-975"><a href="#L-975"><span class="linenos"> 975</span></a> -</span><span id="L-976"><a href="#L-976"><span class="linenos"> 976</span></a> <span class="k">def</span> <span class="nf">delete_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Delete</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-977"><a href="#L-977"><span class="linenos"> 977</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-978"><a href="#L-978"><span class="linenos"> 978</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" FROM </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-979"><a href="#L-979"><span class="linenos"> 979</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-980"><a href="#L-980"><span class="linenos"> 980</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-981"><a href="#L-981"><span class="linenos"> 981</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-982"><a href="#L-982"><span class="linenos"> 982</span></a> <span class="n">returning</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"returning"</span><span class="p">)</span> -</span><span id="L-983"><a href="#L-983"><span class="linenos"> 983</span></a> <span class="n">limit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"limit"</span><span class="p">)</span> -</span><span id="L-984"><a href="#L-984"><span class="linenos"> 984</span></a> <span class="n">tables</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">"tables"</span><span class="p">)</span> -</span><span id="L-985"><a href="#L-985"><span class="linenos"> 985</span></a> <span class="n">tables</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">tables</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">tables</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-986"><a href="#L-986"><span class="linenos"> 986</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">RETURNING_END</span><span class="p">:</span> -</span><span id="L-987"><a href="#L-987"><span class="linenos"> 987</span></a> <span class="n">expression_sql</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="n">using</span><span class="si">}{</span><span class="n">where</span><span class="si">}{</span><span class="n">returning</span><span class="si">}{</span><span class="n">limit</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-988"><a href="#L-988"><span class="linenos"> 988</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-989"><a href="#L-989"><span class="linenos"> 989</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">returning</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="n">using</span><span class="si">}{</span><span class="n">where</span><span class="si">}{</span><span class="n">limit</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-990"><a href="#L-990"><span class="linenos"> 990</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="sa">f</span><span class="s2">"DELETE</span><span class="si">{</span><span class="n">tables</span><span class="si">}{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="L-991"><a href="#L-991"><span class="linenos"> 991</span></a> -</span><span id="L-992"><a href="#L-992"><span class="linenos"> 992</span></a> <span class="k">def</span> <span class="nf">drop_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Drop</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-993"><a href="#L-993"><span class="linenos"> 993</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-994"><a href="#L-994"><span class="linenos"> 994</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-995"><a href="#L-995"><span class="linenos"> 995</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-996"><a href="#L-996"><span class="linenos"> 996</span></a> <span class="n">temporary</span> <span class="o">=</span> <span class="s2">" TEMPORARY"</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">"temporary"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-997"><a href="#L-997"><span class="linenos"> 997</span></a> <span class="n">materialized</span> <span class="o">=</span> <span class="s2">" MATERIALIZED"</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">"materialized"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-998"><a href="#L-998"><span class="linenos"> 998</span></a> <span class="n">cascade</span> <span class="o">=</span> <span class="s2">" CASCADE"</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">"cascade"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-999"><a href="#L-999"><span class="linenos"> 999</span></a> <span class="n">constraints</span> <span class="o">=</span> <span class="s2">" CONSTRAINTS"</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">"constraints"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1000"><a href="#L-1000"><span class="linenos">1000</span></a> <span class="n">purge</span> <span class="o">=</span> <span class="s2">" PURGE"</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">"purge"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1001"><a href="#L-1001"><span class="linenos">1001</span></a> <span class="k">return</span> <span class="p">(</span> -</span><span id="L-1002"><a href="#L-1002"><span class="linenos">1002</span></a> <span class="sa">f</span><span class="s2">"DROP</span><span class="si">{</span><span class="n">temporary</span><span class="si">}{</span><span class="n">materialized</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">exists_sql</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="n">cascade</span><span class="si">}{</span><span class="n">constraints</span><span class="si">}{</span><span class="n">purge</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1003"><a href="#L-1003"><span class="linenos">1003</span></a> <span class="p">)</span> -</span><span id="L-1004"><a href="#L-1004"><span class="linenos">1004</span></a> -</span><span id="L-1005"><a href="#L-1005"><span class="linenos">1005</span></a> <span class="k">def</span> <span class="nf">except_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Except</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1006"><a href="#L-1006"><span class="linenos">1006</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><span id="L-1007"><a href="#L-1007"><span class="linenos">1007</span></a> <span class="n">expression</span><span class="p">,</span> -</span><span id="L-1008"><a href="#L-1008"><span class="linenos">1008</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">set_operation</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">except_op</span><span class="p">(</span><span class="n">expression</span><span class="p">)),</span> -</span><span id="L-1009"><a href="#L-1009"><span class="linenos">1009</span></a> <span class="p">)</span> -</span><span id="L-1010"><a href="#L-1010"><span class="linenos">1010</span></a> -</span><span id="L-1011"><a href="#L-1011"><span class="linenos">1011</span></a> <span class="k">def</span> <span class="nf">except_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Except</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1012"><a href="#L-1012"><span class="linenos">1012</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"EXCEPT</span><span class="si">{</span><span class="s1">''</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">'distinct'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">' ALL'</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1013"><a href="#L-1013"><span class="linenos">1013</span></a> -</span><span id="L-1014"><a href="#L-1014"><span class="linenos">1014</span></a> <span class="k">def</span> <span class="nf">fetch_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1015"><a href="#L-1015"><span class="linenos">1015</span></a> <span class="n">direction</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">"direction"</span><span class="p">)</span> -</span><span id="L-1016"><a href="#L-1016"><span class="linenos">1016</span></a> <span class="n">direction</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">direction</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">direction</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1017"><a href="#L-1017"><span class="linenos">1017</span></a> <span class="n">count</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">"count"</span><span class="p">)</span> -</span><span id="L-1018"><a href="#L-1018"><span class="linenos">1018</span></a> <span class="n">count</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">count</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">count</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1019"><a href="#L-1019"><span class="linenos">1019</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">"percent"</span><span class="p">):</span> -</span><span id="L-1020"><a href="#L-1020"><span class="linenos">1020</span></a> <span class="n">count</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">count</span><span class="si">}</span><span class="s2"> PERCENT"</span> -</span><span id="L-1021"><a href="#L-1021"><span class="linenos">1021</span></a> <span class="n">with_ties_or_only</span> <span class="o">=</span> <span class="s2">"WITH TIES"</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">"with_ties"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">"ONLY"</span> -</span><span id="L-1022"><a href="#L-1022"><span class="linenos">1022</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="s1">'FETCH'</span><span class="p">)</span><span class="si">}{</span><span class="n">direction</span><span class="si">}{</span><span class="n">count</span><span class="si">}</span><span class="s2"> ROWS </span><span class="si">{</span><span class="n">with_ties_or_only</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1023"><a href="#L-1023"><span class="linenos">1023</span></a> -</span><span id="L-1024"><a href="#L-1024"><span class="linenos">1024</span></a> <span class="k">def</span> <span class="nf">filter_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Filter</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1025"><a href="#L-1025"><span class="linenos">1025</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">AGGREGATE_FILTER_SUPPORTED</span><span class="p">:</span> -</span><span id="L-1026"><a href="#L-1026"><span class="linenos">1026</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-1027"><a href="#L-1027"><span class="linenos">1027</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">"expression"</span><span class="p">)</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> -</span><span id="L-1028"><a href="#L-1028"><span class="linenos">1028</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"> FILTER(</span><span class="si">{</span><span class="n">where</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="L-1029"><a href="#L-1029"><span class="linenos">1029</span></a> -</span><span id="L-1030"><a href="#L-1030"><span class="linenos">1030</span></a> <span class="n">agg</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> -</span><span id="L-1031"><a href="#L-1031"><span class="linenos">1031</span></a> <span class="n">agg_arg</span> <span class="o">=</span> <span class="n">agg</span><span class="o">.</span><span class="n">this</span> -</span><span id="L-1032"><a href="#L-1032"><span class="linenos">1032</span></a> <span class="n">cond</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">this</span> -</span><span id="L-1033"><a href="#L-1033"><span class="linenos">1033</span></a> <span class="n">agg_arg</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">If</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">cond</span><span class="o">.</span><span class="n">copy</span><span class="p">(),</span> <span class="n">true</span><span class="o">=</span><span class="n">agg_arg</span><span class="o">.</span><span class="n">copy</span><span class="p">()))</span> -</span><span id="L-1034"><a href="#L-1034"><span class="linenos">1034</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">agg</span><span class="p">)</span> +</span><span id="L-900"><a href="#L-900"><span class="linenos"> 900</span></a> <span class="k">def</span> <span class="nf">bitstring_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">BitString</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-901"><a href="#L-901"><span class="linenos"> 901</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-902"><a href="#L-902"><span class="linenos"> 902</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">BIT_START</span><span class="p">:</span> +</span><span id="L-903"><a href="#L-903"><span class="linenos"> 903</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">dialect</span><span class="o">.</span><span class="n">BIT_START</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">BIT_END</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-904"><a href="#L-904"><span class="linenos"> 904</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="nb">int</span><span class="p">(</span><span class="n">this</span><span class="p">,</span><span class="w"> </span><span class="mi">2</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-905"><a href="#L-905"><span class="linenos"> 905</span></a> +</span><span id="L-906"><a href="#L-906"><span class="linenos"> 906</span></a> <span class="k">def</span> <span class="nf">hexstring_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">HexString</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-907"><a href="#L-907"><span class="linenos"> 907</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-908"><a href="#L-908"><span class="linenos"> 908</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">HEX_START</span><span class="p">:</span> +</span><span id="L-909"><a href="#L-909"><span class="linenos"> 909</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">dialect</span><span class="o">.</span><span class="n">HEX_START</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">HEX_END</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-910"><a href="#L-910"><span class="linenos"> 910</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="nb">int</span><span class="p">(</span><span class="n">this</span><span class="p">,</span><span class="w"> </span><span class="mi">16</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-911"><a href="#L-911"><span class="linenos"> 911</span></a> +</span><span id="L-912"><a href="#L-912"><span class="linenos"> 912</span></a> <span class="k">def</span> <span class="nf">bytestring_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ByteString</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-913"><a href="#L-913"><span class="linenos"> 913</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-914"><a href="#L-914"><span class="linenos"> 914</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">BYTE_START</span><span class="p">:</span> +</span><span id="L-915"><a href="#L-915"><span class="linenos"> 915</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">dialect</span><span class="o">.</span><span class="n">BYTE_START</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">BYTE_END</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-916"><a href="#L-916"><span class="linenos"> 916</span></a> <span class="k">return</span> <span class="n">this</span> +</span><span id="L-917"><a href="#L-917"><span class="linenos"> 917</span></a> +</span><span id="L-918"><a href="#L-918"><span class="linenos"> 918</span></a> <span class="k">def</span> <span class="nf">rawstring_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RawString</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-919"><a href="#L-919"><span class="linenos"> 919</span></a> <span class="n">string</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">escape_str</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">"</span><span class="se">\\</span><span class="s2">"</span><span class="p">,</span> <span class="s2">"</span><span class="se">\\\\</span><span class="s2">"</span><span class="p">))</span> +</span><span id="L-920"><a href="#L-920"><span class="linenos"> 920</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">dialect</span><span class="o">.</span><span class="n">QUOTE_START</span><span class="si">}{</span><span class="n">string</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">QUOTE_END</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-921"><a href="#L-921"><span class="linenos"> 921</span></a> +</span><span id="L-922"><a href="#L-922"><span class="linenos"> 922</span></a> <span class="k">def</span> <span class="nf">datatypeparam_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataTypeParam</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-923"><a href="#L-923"><span class="linenos"> 923</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-924"><a href="#L-924"><span class="linenos"> 924</span></a> <span class="n">specifier</span> <span class="o">=</span> <span class="bp">self</span><span 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-925"><a href="#L-925"><span class="linenos"> 925</span></a> <span class="n">specifier</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">specifier</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">specifier</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">DATA_TYPE_SPECIFIERS_ALLOWED</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-926"><a href="#L-926"><span class="linenos"> 926</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">specifier</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-927"><a href="#L-927"><span class="linenos"> 927</span></a> +</span><span id="L-928"><a href="#L-928"><span class="linenos"> 928</span></a> <span class="k">def</span> <span class="nf">datatype_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-929"><a href="#L-929"><span class="linenos"> 929</span></a> <span class="n">type_value</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> +</span><span id="L-930"><a href="#L-930"><span class="linenos"> 930</span></a> +</span><span id="L-931"><a href="#L-931"><span class="linenos"> 931</span></a> <span class="k">if</span> <span class="n">type_value</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">USERDEFINED</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">"kind"</span><span class="p">):</span> +</span><span id="L-932"><a href="#L-932"><span class="linenos"> 932</span></a> <span class="n">type_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">"kind"</span><span class="p">)</span> +</span><span id="L-933"><a href="#L-933"><span class="linenos"> 933</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-934"><a href="#L-934"><span class="linenos"> 934</span></a> <span class="n">type_sql</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="L-935"><a href="#L-935"><span class="linenos"> 935</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">TYPE_MAPPING</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">type_value</span><span class="p">,</span> <span class="n">type_value</span><span class="o">.</span><span class="n">value</span><span class="p">)</span> +</span><span id="L-936"><a href="#L-936"><span class="linenos"> 936</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">type_value</span><span class="p">,</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="p">)</span> +</span><span id="L-937"><a href="#L-937"><span class="linenos"> 937</span></a> <span class="k">else</span> <span class="n">type_value</span> +</span><span id="L-938"><a href="#L-938"><span class="linenos"> 938</span></a> <span class="p">)</span> +</span><span id="L-939"><a href="#L-939"><span class="linenos"> 939</span></a> +</span><span id="L-940"><a href="#L-940"><span class="linenos"> 940</span></a> <span class="n">nested</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="L-941"><a href="#L-941"><span class="linenos"> 941</span></a> <span class="n">interior</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-942"><a href="#L-942"><span class="linenos"> 942</span></a> <span class="n">values</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="L-943"><a href="#L-943"><span class="linenos"> 943</span></a> +</span><span id="L-944"><a href="#L-944"><span class="linenos"> 944</span></a> <span class="k">if</span> <span class="n">interior</span><span class="p">:</span> +</span><span id="L-945"><a href="#L-945"><span class="linenos"> 945</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">"nested"</span><span class="p">):</span> +</span><span id="L-946"><a href="#L-946"><span class="linenos"> 946</span></a> <span class="n">nested</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">STRUCT_DELIMITER</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="si">}{</span><span class="n">interior</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">STRUCT_DELIMITER</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-947"><a href="#L-947"><span class="linenos"> 947</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">"values"</span><span class="p">)</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-948"><a href="#L-948"><span class="linenos"> 948</span></a> <span class="n">delimiters</span> <span class="o">=</span> <span class="p">(</span><span class="s2">"["</span><span class="p">,</span> <span class="s2">"]"</span><span class="p">)</span> <span class="k">if</span> <span class="n">type_value</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">ARRAY</span> <span class="k">else</span> <span class="p">(</span><span class="s2">"("</span><span class="p">,</span> <span class="s2">")"</span><span class="p">)</span> +</span><span id="L-949"><a href="#L-949"><span class="linenos"> 949</span></a> <span class="n">values</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">"values"</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-950"><a href="#L-950"><span class="linenos"> 950</span></a> <span class="n">values</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">delimiters</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="si">}{</span><span class="n">values</span><span class="si">}{</span><span class="n">delimiters</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-951"><a href="#L-951"><span class="linenos"> 951</span></a> <span class="k">elif</span> <span class="n">type_value</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">INTERVAL</span><span class="p">:</span> +</span><span id="L-952"><a href="#L-952"><span class="linenos"> 952</span></a> <span class="n">nested</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">interior</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-953"><a href="#L-953"><span class="linenos"> 953</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-954"><a href="#L-954"><span class="linenos"> 954</span></a> <span class="n">nested</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">interior</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="L-955"><a href="#L-955"><span class="linenos"> 955</span></a> +</span><span id="L-956"><a href="#L-956"><span class="linenos"> 956</span></a> <span class="n">type_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">type_sql</span><span class="si">}{</span><span class="n">nested</span><span class="si">}{</span><span class="n">values</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-957"><a href="#L-957"><span class="linenos"> 957</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">TZ_TO_WITH_TIME_ZONE</span> <span class="ow">and</span> <span class="n">type_value</span> <span class="ow">in</span> <span class="p">(</span> +</span><span id="L-958"><a href="#L-958"><span class="linenos"> 958</span></a> <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">TIMETZ</span><span class="p">,</span> +</span><span id="L-959"><a href="#L-959"><span class="linenos"> 959</span></a> <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">TIMESTAMPTZ</span><span class="p">,</span> +</span><span id="L-960"><a href="#L-960"><span class="linenos"> 960</span></a> <span class="p">):</span> +</span><span id="L-961"><a href="#L-961"><span class="linenos"> 961</span></a> <span class="n">type_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">type_sql</span><span class="si">}</span><span class="s2"> WITH TIME ZONE"</span> +</span><span id="L-962"><a href="#L-962"><span class="linenos"> 962</span></a> +</span><span id="L-963"><a href="#L-963"><span class="linenos"> 963</span></a> <span class="k">return</span> <span class="n">type_sql</span> +</span><span id="L-964"><a href="#L-964"><span class="linenos"> 964</span></a> +</span><span id="L-965"><a href="#L-965"><span class="linenos"> 965</span></a> <span class="k">def</span> <span class="nf">directory_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Directory</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-966"><a href="#L-966"><span class="linenos"> 966</span></a> <span class="n">local</span> <span class="o">=</span> <span class="s2">"LOCAL "</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">"local"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-967"><a href="#L-967"><span class="linenos"> 967</span></a> <span class="n">row_format</span> <span class="o">=</span> <span class="bp">self</span><span 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"</span><span class="p">)</span> +</span><span id="L-968"><a href="#L-968"><span class="linenos"> 968</span></a> <span class="n">row_format</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">row_format</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">row_format</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-969"><a href="#L-969"><span class="linenos"> 969</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">local</span><span class="si">}</span><span class="s2">DIRECTORY </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">row_format</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-970"><a href="#L-970"><span class="linenos"> 970</span></a> +</span><span id="L-971"><a href="#L-971"><span class="linenos"> 971</span></a> <span class="k">def</span> <span class="nf">delete_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Delete</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-972"><a href="#L-972"><span class="linenos"> 972</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-973"><a href="#L-973"><span class="linenos"> 973</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" FROM </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-974"><a href="#L-974"><span class="linenos"> 974</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-975"><a href="#L-975"><span class="linenos"> 975</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-976"><a href="#L-976"><span class="linenos"> 976</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-977"><a href="#L-977"><span class="linenos"> 977</span></a> <span class="n">returning</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"returning"</span><span class="p">)</span> +</span><span id="L-978"><a href="#L-978"><span class="linenos"> 978</span></a> <span class="n">limit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"limit"</span><span class="p">)</span> +</span><span id="L-979"><a href="#L-979"><span class="linenos"> 979</span></a> <span class="n">tables</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">"tables"</span><span class="p">)</span> +</span><span id="L-980"><a href="#L-980"><span class="linenos"> 980</span></a> <span class="n">tables</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">tables</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">tables</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-981"><a href="#L-981"><span class="linenos"> 981</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">RETURNING_END</span><span class="p">:</span> +</span><span id="L-982"><a href="#L-982"><span class="linenos"> 982</span></a> <span class="n">expression_sql</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="n">using</span><span class="si">}{</span><span class="n">where</span><span class="si">}{</span><span class="n">returning</span><span class="si">}{</span><span class="n">limit</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-983"><a href="#L-983"><span class="linenos"> 983</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-984"><a href="#L-984"><span class="linenos"> 984</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">returning</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="n">using</span><span class="si">}{</span><span class="n">where</span><span class="si">}{</span><span class="n">limit</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-985"><a href="#L-985"><span class="linenos"> 985</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="sa">f</span><span class="s2">"DELETE</span><span class="si">{</span><span class="n">tables</span><span class="si">}{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="L-986"><a href="#L-986"><span class="linenos"> 986</span></a> +</span><span id="L-987"><a href="#L-987"><span class="linenos"> 987</span></a> <span class="k">def</span> <span class="nf">drop_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Drop</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-988"><a href="#L-988"><span class="linenos"> 988</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-989"><a href="#L-989"><span class="linenos"> 989</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-990"><a href="#L-990"><span class="linenos"> 990</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-991"><a href="#L-991"><span class="linenos"> 991</span></a> <span class="n">temporary</span> <span class="o">=</span> <span class="s2">" TEMPORARY"</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">"temporary"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-992"><a href="#L-992"><span class="linenos"> 992</span></a> <span class="n">materialized</span> <span class="o">=</span> <span class="s2">" MATERIALIZED"</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">"materialized"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-993"><a href="#L-993"><span class="linenos"> 993</span></a> <span class="n">cascade</span> <span class="o">=</span> <span class="s2">" CASCADE"</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">"cascade"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-994"><a href="#L-994"><span class="linenos"> 994</span></a> <span class="n">constraints</span> <span class="o">=</span> <span class="s2">" CONSTRAINTS"</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">"constraints"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-995"><a href="#L-995"><span class="linenos"> 995</span></a> <span class="n">purge</span> <span class="o">=</span> <span class="s2">" PURGE"</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">"purge"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-996"><a href="#L-996"><span class="linenos"> 996</span></a> <span class="k">return</span> <span class="p">(</span> +</span><span id="L-997"><a href="#L-997"><span class="linenos"> 997</span></a> <span class="sa">f</span><span class="s2">"DROP</span><span class="si">{</span><span class="n">temporary</span><span class="si">}{</span><span class="n">materialized</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">exists_sql</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="n">cascade</span><span class="si">}{</span><span class="n">constraints</span><span class="si">}{</span><span class="n">purge</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-998"><a href="#L-998"><span class="linenos"> 998</span></a> <span class="p">)</span> +</span><span id="L-999"><a href="#L-999"><span class="linenos"> 999</span></a> +</span><span id="L-1000"><a href="#L-1000"><span class="linenos">1000</span></a> <span class="k">def</span> <span class="nf">except_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Except</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1001"><a href="#L-1001"><span class="linenos">1001</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><span id="L-1002"><a href="#L-1002"><span class="linenos">1002</span></a> <span class="n">expression</span><span class="p">,</span> +</span><span id="L-1003"><a href="#L-1003"><span class="linenos">1003</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">set_operation</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">except_op</span><span class="p">(</span><span class="n">expression</span><span class="p">)),</span> +</span><span id="L-1004"><a href="#L-1004"><span class="linenos">1004</span></a> <span class="p">)</span> +</span><span id="L-1005"><a href="#L-1005"><span class="linenos">1005</span></a> +</span><span id="L-1006"><a href="#L-1006"><span class="linenos">1006</span></a> <span class="k">def</span> <span class="nf">except_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Except</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1007"><a href="#L-1007"><span class="linenos">1007</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"EXCEPT</span><span class="si">{</span><span class="s1">''</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">'distinct'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">' ALL'</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1008"><a href="#L-1008"><span class="linenos">1008</span></a> +</span><span id="L-1009"><a href="#L-1009"><span class="linenos">1009</span></a> <span class="k">def</span> <span class="nf">fetch_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1010"><a href="#L-1010"><span class="linenos">1010</span></a> <span class="n">direction</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">"direction"</span><span class="p">)</span> +</span><span id="L-1011"><a href="#L-1011"><span class="linenos">1011</span></a> <span class="n">direction</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">direction</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">direction</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1012"><a href="#L-1012"><span class="linenos">1012</span></a> <span class="n">count</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">"count"</span><span class="p">)</span> +</span><span id="L-1013"><a href="#L-1013"><span class="linenos">1013</span></a> <span class="n">count</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">count</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">count</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1014"><a href="#L-1014"><span class="linenos">1014</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">"percent"</span><span class="p">):</span> +</span><span id="L-1015"><a href="#L-1015"><span class="linenos">1015</span></a> <span class="n">count</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">count</span><span class="si">}</span><span class="s2"> PERCENT"</span> +</span><span id="L-1016"><a href="#L-1016"><span class="linenos">1016</span></a> <span class="n">with_ties_or_only</span> <span class="o">=</span> <span class="s2">"WITH TIES"</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">"with_ties"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">"ONLY"</span> +</span><span id="L-1017"><a href="#L-1017"><span class="linenos">1017</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="s1">'FETCH'</span><span class="p">)</span><span class="si">}{</span><span class="n">direction</span><span class="si">}{</span><span class="n">count</span><span class="si">}</span><span class="s2"> ROWS </span><span class="si">{</span><span class="n">with_ties_or_only</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1018"><a href="#L-1018"><span class="linenos">1018</span></a> +</span><span id="L-1019"><a href="#L-1019"><span class="linenos">1019</span></a> <span class="k">def</span> <span class="nf">filter_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Filter</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1020"><a href="#L-1020"><span class="linenos">1020</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">AGGREGATE_FILTER_SUPPORTED</span><span class="p">:</span> +</span><span id="L-1021"><a href="#L-1021"><span class="linenos">1021</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-1022"><a href="#L-1022"><span class="linenos">1022</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">"expression"</span><span class="p">)</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> +</span><span id="L-1023"><a href="#L-1023"><span class="linenos">1023</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"> FILTER(</span><span class="si">{</span><span class="n">where</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="L-1024"><a href="#L-1024"><span class="linenos">1024</span></a> +</span><span id="L-1025"><a href="#L-1025"><span class="linenos">1025</span></a> <span class="n">agg</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> +</span><span id="L-1026"><a href="#L-1026"><span class="linenos">1026</span></a> <span class="n">agg_arg</span> <span class="o">=</span> <span class="n">agg</span><span class="o">.</span><span class="n">this</span> +</span><span id="L-1027"><a href="#L-1027"><span class="linenos">1027</span></a> <span class="n">cond</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">this</span> +</span><span id="L-1028"><a href="#L-1028"><span class="linenos">1028</span></a> <span class="n">agg_arg</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">If</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">cond</span><span class="o">.</span><span class="n">copy</span><span class="p">(),</span> <span class="n">true</span><span class="o">=</span><span class="n">agg_arg</span><span class="o">.</span><span class="n">copy</span><span class="p">()))</span> +</span><span id="L-1029"><a href="#L-1029"><span class="linenos">1029</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">agg</span><span class="p">)</span> +</span><span id="L-1030"><a href="#L-1030"><span class="linenos">1030</span></a> +</span><span id="L-1031"><a href="#L-1031"><span class="linenos">1031</span></a> <span class="k">def</span> <span class="nf">hint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Hint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1032"><a href="#L-1032"><span class="linenos">1032</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">QUERY_HINTS</span><span class="p">:</span> +</span><span id="L-1033"><a href="#L-1033"><span class="linenos">1033</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Hints are not supported"</span><span class="p">)</span> +</span><span id="L-1034"><a href="#L-1034"><span class="linenos">1034</span></a> <span class="k">return</span> <span class="s2">""</span> </span><span id="L-1035"><a href="#L-1035"><span class="linenos">1035</span></a> -</span><span id="L-1036"><a href="#L-1036"><span class="linenos">1036</span></a> <span class="k">def</span> <span class="nf">hint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Hint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1037"><a href="#L-1037"><span class="linenos">1037</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">QUERY_HINTS</span><span class="p">:</span> -</span><span id="L-1038"><a href="#L-1038"><span class="linenos">1038</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Hints are not supported"</span><span class="p">)</span> -</span><span id="L-1039"><a href="#L-1039"><span class="linenos">1039</span></a> <span class="k">return</span> <span class="s2">""</span> -</span><span id="L-1040"><a href="#L-1040"><span class="linenos">1040</span></a> -</span><span id="L-1041"><a href="#L-1041"><span class="linenos">1041</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">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">QUERY_HINT_SEP</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-1042"><a href="#L-1042"><span class="linenos">1042</span></a> -</span><span id="L-1043"><a href="#L-1043"><span class="linenos">1043</span></a> <span class="k">def</span> <span class="nf">index_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Index</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1044"><a href="#L-1044"><span class="linenos">1044</span></a> <span class="n">unique</span> <span class="o">=</span> <span class="s2">"UNIQUE "</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">"unique"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1045"><a href="#L-1045"><span class="linenos">1045</span></a> <span class="n">primary</span> <span class="o">=</span> <span class="s2">"PRIMARY "</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">"primary"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1046"><a href="#L-1046"><span class="linenos">1046</span></a> <span class="n">amp</span> <span class="o">=</span> <span class="s2">"AMP "</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">"amp"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1047"><a href="#L-1047"><span class="linenos">1047</span></a> <span class="n">name</span> <span class="o">=</span> <span class="bp">self</span><span 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-1048"><a href="#L-1048"><span class="linenos">1048</span></a> <span class="n">name</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">name</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">name</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1049"><a href="#L-1049"><span class="linenos">1049</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">"table"</span><span class="p">)</span> -</span><span id="L-1050"><a href="#L-1050"><span class="linenos">1050</span></a> <span class="n">table</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">INDEX_ON</span><span class="si">}</span><span class="s2"> </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="n">table</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1051"><a href="#L-1051"><span class="linenos">1051</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-1052"><a href="#L-1052"><span class="linenos">1052</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-1053"><a href="#L-1053"><span class="linenos">1053</span></a> <span class="n">index</span> <span class="o">=</span> <span class="s2">"INDEX "</span> <span class="k">if</span> <span class="ow">not</span> <span class="n">table</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1054"><a href="#L-1054"><span class="linenos">1054</span></a> <span class="n">columns</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">"columns"</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-1055"><a href="#L-1055"><span class="linenos">1055</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">columns</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">columns</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1056"><a href="#L-1056"><span class="linenos">1056</span></a> <span class="n">partition_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">"partition_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-1057"><a href="#L-1057"><span class="linenos">1057</span></a> <span class="n">partition_by</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" PARTITION BY </span><span class="si">{</span><span class="n">partition_by</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">partition_by</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1058"><a href="#L-1058"><span class="linenos">1058</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-1059"><a href="#L-1059"><span class="linenos">1059</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">unique</span><span class="si">}{</span><span class="n">primary</span><span class="si">}{</span><span class="n">amp</span><span class="si">}{</span><span class="n">index</span><span class="si">}{</span><span class="n">name</span><span class="si">}{</span><span class="n">table</span><span class="si">}{</span><span class="n">using</span><span class="si">}{</span><span class="n">columns</span><span class="si">}{</span><span class="n">partition_by</span><span class="si">}{</span><span class="n">where</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1060"><a href="#L-1060"><span class="linenos">1060</span></a> -</span><span id="L-1061"><a href="#L-1061"><span class="linenos">1061</span></a> <span class="k">def</span> <span class="nf">identifier_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1062"><a href="#L-1062"><span class="linenos">1062</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">name</span> -</span><span id="L-1063"><a href="#L-1063"><span class="linenos">1063</span></a> <span class="n">lower</span> <span class="o">=</span> <span class="n">text</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> -</span><span id="L-1064"><a href="#L-1064"><span class="linenos">1064</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">lower</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">normalize</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">quoted</span> <span class="k">else</span> <span class="n">text</span> -</span><span id="L-1065"><a href="#L-1065"><span class="linenos">1065</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">text</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">IDENTIFIER_END</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_escaped_identifier_end</span><span class="p">)</span> -</span><span id="L-1066"><a href="#L-1066"><span class="linenos">1066</span></a> <span class="k">if</span> <span class="p">(</span> -</span><span id="L-1067"><a href="#L-1067"><span class="linenos">1067</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">quoted</span> -</span><span id="L-1068"><a href="#L-1068"><span class="linenos">1068</span></a> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">can_identify</span><span class="p">(</span><span class="n">text</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">identify</span><span class="p">)</span> -</span><span id="L-1069"><a href="#L-1069"><span class="linenos">1069</span></a> <span class="ow">or</span> <span class="n">lower</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">RESERVED_KEYWORDS</span> -</span><span id="L-1070"><a href="#L-1070"><span class="linenos">1070</span></a> <span class="ow">or</span> <span class="p">(</span><span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">IDENTIFIERS_CAN_START_WITH_DIGIT</span> <span class="ow">and</span> <span class="n">text</span><span class="p">[:</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">isdigit</span><span class="p">())</span> -</span><span id="L-1071"><a href="#L-1071"><span class="linenos">1071</span></a> <span class="p">):</span> -</span><span id="L-1072"><a href="#L-1072"><span class="linenos">1072</span></a> <span class="n">text</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">dialect</span><span class="o">.</span><span class="n">IDENTIFIER_START</span><span class="si">}{</span><span class="n">text</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">IDENTIFIER_END</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1073"><a href="#L-1073"><span class="linenos">1073</span></a> <span class="k">return</span> <span class="n">text</span> -</span><span id="L-1074"><a href="#L-1074"><span class="linenos">1074</span></a> -</span><span id="L-1075"><a href="#L-1075"><span class="linenos">1075</span></a> <span class="k">def</span> <span class="nf">inputoutputformat_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">InputOutputFormat</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1076"><a href="#L-1076"><span class="linenos">1076</span></a> <span class="n">input_format</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"input_format"</span><span class="p">)</span> -</span><span id="L-1077"><a href="#L-1077"><span class="linenos">1077</span></a> <span class="n">input_format</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"INPUTFORMAT </span><span class="si">{</span><span class="n">input_format</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">input_format</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1078"><a href="#L-1078"><span class="linenos">1078</span></a> <span class="n">output_format</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"output_format"</span><span class="p">)</span> -</span><span id="L-1079"><a href="#L-1079"><span class="linenos">1079</span></a> <span class="n">output_format</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"OUTPUTFORMAT </span><span class="si">{</span><span class="n">output_format</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">output_format</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1080"><a href="#L-1080"><span class="linenos">1080</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="o">.</span><span class="n">join</span><span class="p">((</span><span class="n">input_format</span><span class="p">,</span> <span class="n">output_format</span><span class="p">))</span> -</span><span id="L-1081"><a href="#L-1081"><span class="linenos">1081</span></a> -</span><span id="L-1082"><a href="#L-1082"><span class="linenos">1082</span></a> <span class="k">def</span> <span class="nf">national_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">National</span><span class="p">,</span> <span class="n">prefix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"N"</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1083"><a href="#L-1083"><span class="linenos">1083</span></a> <span class="n">string</span> <span class="o">=</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">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="p">))</span> -</span><span id="L-1084"><a href="#L-1084"><span class="linenos">1084</span></a> <span class="k">return</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">string</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1085"><a href="#L-1085"><span class="linenos">1085</span></a> -</span><span id="L-1086"><a href="#L-1086"><span class="linenos">1086</span></a> <span class="k">def</span> <span class="nf">partition_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Partition</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1087"><a href="#L-1087"><span class="linenos">1087</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PARTITION(</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-1088"><a href="#L-1088"><span class="linenos">1088</span></a> -</span><span id="L-1089"><a href="#L-1089"><span class="linenos">1089</span></a> <span class="k">def</span> <span class="nf">properties_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1090"><a href="#L-1090"><span class="linenos">1090</span></a> <span class="n">root_properties</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="L-1091"><a href="#L-1091"><span class="linenos">1091</span></a> <span class="n">with_properties</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="L-1092"><a href="#L-1092"><span class="linenos">1092</span></a> -</span><span id="L-1093"><a href="#L-1093"><span class="linenos">1093</span></a> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> -</span><span id="L-1094"><a href="#L-1094"><span class="linenos">1094</span></a> <span class="n">p_loc</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">PROPERTIES_LOCATION</span><span class="p">[</span><span class="n">p</span><span class="o">.</span><span class="vm">__class__</span><span class="p">]</span> -</span><span id="L-1095"><a href="#L-1095"><span class="linenos">1095</span></a> <span class="k">if</span> <span class="n">p_loc</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">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">:</span> -</span><span id="L-1096"><a href="#L-1096"><span class="linenos">1096</span></a> <span class="n">with_properties</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> -</span><span id="L-1097"><a href="#L-1097"><span class="linenos">1097</span></a> <span class="k">elif</span> <span class="n">p_loc</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">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">:</span> -</span><span id="L-1098"><a href="#L-1098"><span class="linenos">1098</span></a> <span class="n">root_properties</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> -</span><span id="L-1099"><a href="#L-1099"><span class="linenos">1099</span></a> -</span><span id="L-1100"><a href="#L-1100"><span class="linenos">1100</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">root_properties</span><span class="p">(</span> -</span><span id="L-1101"><a href="#L-1101"><span class="linenos">1101</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">root_properties</span><span class="p">)</span> -</span><span id="L-1102"><a href="#L-1102"><span class="linenos">1102</span></a> <span class="p">)</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">with_properties</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">with_properties</span><span class="p">))</span> +</span><span id="L-1036"><a href="#L-1036"><span class="linenos">1036</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">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">QUERY_HINT_SEP</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-1037"><a href="#L-1037"><span class="linenos">1037</span></a> +</span><span id="L-1038"><a href="#L-1038"><span class="linenos">1038</span></a> <span class="k">def</span> <span class="nf">index_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Index</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1039"><a href="#L-1039"><span class="linenos">1039</span></a> <span class="n">unique</span> <span class="o">=</span> <span class="s2">"UNIQUE "</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">"unique"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1040"><a href="#L-1040"><span class="linenos">1040</span></a> <span class="n">primary</span> <span class="o">=</span> <span class="s2">"PRIMARY "</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">"primary"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1041"><a href="#L-1041"><span class="linenos">1041</span></a> <span class="n">amp</span> <span class="o">=</span> <span class="s2">"AMP "</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">"amp"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1042"><a href="#L-1042"><span class="linenos">1042</span></a> <span class="n">name</span> <span class="o">=</span> <span class="bp">self</span><span 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-1043"><a href="#L-1043"><span class="linenos">1043</span></a> <span class="n">name</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">name</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">name</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1044"><a href="#L-1044"><span class="linenos">1044</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">"table"</span><span class="p">)</span> +</span><span id="L-1045"><a href="#L-1045"><span class="linenos">1045</span></a> <span class="n">table</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">INDEX_ON</span><span class="si">}</span><span class="s2"> </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="n">table</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1046"><a href="#L-1046"><span class="linenos">1046</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-1047"><a href="#L-1047"><span class="linenos">1047</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-1048"><a href="#L-1048"><span class="linenos">1048</span></a> <span class="n">index</span> <span class="o">=</span> <span class="s2">"INDEX "</span> <span class="k">if</span> <span class="ow">not</span> <span class="n">table</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1049"><a href="#L-1049"><span class="linenos">1049</span></a> <span class="n">columns</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">"columns"</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-1050"><a href="#L-1050"><span class="linenos">1050</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">columns</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">columns</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1051"><a href="#L-1051"><span class="linenos">1051</span></a> <span class="n">partition_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">"partition_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-1052"><a href="#L-1052"><span class="linenos">1052</span></a> <span class="n">partition_by</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" PARTITION BY </span><span class="si">{</span><span class="n">partition_by</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">partition_by</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1053"><a href="#L-1053"><span class="linenos">1053</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-1054"><a href="#L-1054"><span class="linenos">1054</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">unique</span><span class="si">}{</span><span class="n">primary</span><span class="si">}{</span><span class="n">amp</span><span class="si">}{</span><span class="n">index</span><span class="si">}{</span><span class="n">name</span><span class="si">}{</span><span class="n">table</span><span class="si">}{</span><span class="n">using</span><span class="si">}{</span><span class="n">columns</span><span class="si">}{</span><span class="n">partition_by</span><span class="si">}{</span><span class="n">where</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1055"><a href="#L-1055"><span class="linenos">1055</span></a> +</span><span id="L-1056"><a href="#L-1056"><span class="linenos">1056</span></a> <span class="k">def</span> <span class="nf">identifier_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1057"><a href="#L-1057"><span class="linenos">1057</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">name</span> +</span><span id="L-1058"><a href="#L-1058"><span class="linenos">1058</span></a> <span class="n">lower</span> <span class="o">=</span> <span class="n">text</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> +</span><span id="L-1059"><a href="#L-1059"><span class="linenos">1059</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">lower</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">normalize</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">quoted</span> <span class="k">else</span> <span class="n">text</span> +</span><span id="L-1060"><a href="#L-1060"><span class="linenos">1060</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">text</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">IDENTIFIER_END</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_escaped_identifier_end</span><span class="p">)</span> +</span><span id="L-1061"><a href="#L-1061"><span class="linenos">1061</span></a> <span class="k">if</span> <span class="p">(</span> +</span><span id="L-1062"><a href="#L-1062"><span class="linenos">1062</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">quoted</span> +</span><span id="L-1063"><a href="#L-1063"><span class="linenos">1063</span></a> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">can_identify</span><span class="p">(</span><span class="n">text</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">identify</span><span class="p">)</span> +</span><span id="L-1064"><a href="#L-1064"><span class="linenos">1064</span></a> <span class="ow">or</span> <span class="n">lower</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">RESERVED_KEYWORDS</span> +</span><span id="L-1065"><a href="#L-1065"><span class="linenos">1065</span></a> <span class="ow">or</span> <span class="p">(</span><span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">IDENTIFIERS_CAN_START_WITH_DIGIT</span> <span class="ow">and</span> <span class="n">text</span><span class="p">[:</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">isdigit</span><span class="p">())</span> +</span><span id="L-1066"><a href="#L-1066"><span class="linenos">1066</span></a> <span class="p">):</span> +</span><span id="L-1067"><a href="#L-1067"><span class="linenos">1067</span></a> <span class="n">text</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">dialect</span><span class="o">.</span><span class="n">IDENTIFIER_START</span><span class="si">}{</span><span class="n">text</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">IDENTIFIER_END</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1068"><a href="#L-1068"><span class="linenos">1068</span></a> <span class="k">return</span> <span class="n">text</span> +</span><span id="L-1069"><a href="#L-1069"><span class="linenos">1069</span></a> +</span><span id="L-1070"><a href="#L-1070"><span class="linenos">1070</span></a> <span class="k">def</span> <span class="nf">inputoutputformat_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">InputOutputFormat</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1071"><a href="#L-1071"><span class="linenos">1071</span></a> <span class="n">input_format</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"input_format"</span><span class="p">)</span> +</span><span id="L-1072"><a href="#L-1072"><span class="linenos">1072</span></a> <span class="n">input_format</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"INPUTFORMAT </span><span class="si">{</span><span class="n">input_format</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">input_format</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1073"><a href="#L-1073"><span class="linenos">1073</span></a> <span class="n">output_format</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"output_format"</span><span class="p">)</span> +</span><span id="L-1074"><a href="#L-1074"><span class="linenos">1074</span></a> <span class="n">output_format</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"OUTPUTFORMAT </span><span class="si">{</span><span class="n">output_format</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">output_format</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1075"><a href="#L-1075"><span class="linenos">1075</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="o">.</span><span class="n">join</span><span class="p">((</span><span class="n">input_format</span><span class="p">,</span> <span class="n">output_format</span><span class="p">))</span> +</span><span id="L-1076"><a href="#L-1076"><span class="linenos">1076</span></a> +</span><span id="L-1077"><a href="#L-1077"><span class="linenos">1077</span></a> <span class="k">def</span> <span class="nf">national_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">National</span><span class="p">,</span> <span class="n">prefix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"N"</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1078"><a href="#L-1078"><span class="linenos">1078</span></a> <span class="n">string</span> <span class="o">=</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">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="p">))</span> +</span><span id="L-1079"><a href="#L-1079"><span class="linenos">1079</span></a> <span class="k">return</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">string</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1080"><a href="#L-1080"><span class="linenos">1080</span></a> +</span><span id="L-1081"><a href="#L-1081"><span class="linenos">1081</span></a> <span class="k">def</span> <span class="nf">partition_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Partition</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1082"><a href="#L-1082"><span class="linenos">1082</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PARTITION(</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-1083"><a href="#L-1083"><span class="linenos">1083</span></a> +</span><span id="L-1084"><a href="#L-1084"><span class="linenos">1084</span></a> <span class="k">def</span> <span class="nf">properties_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1085"><a href="#L-1085"><span class="linenos">1085</span></a> <span class="n">root_properties</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="L-1086"><a href="#L-1086"><span class="linenos">1086</span></a> <span class="n">with_properties</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="L-1087"><a href="#L-1087"><span class="linenos">1087</span></a> +</span><span id="L-1088"><a href="#L-1088"><span class="linenos">1088</span></a> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> +</span><span id="L-1089"><a href="#L-1089"><span class="linenos">1089</span></a> <span class="n">p_loc</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">PROPERTIES_LOCATION</span><span class="p">[</span><span class="n">p</span><span class="o">.</span><span class="vm">__class__</span><span class="p">]</span> +</span><span id="L-1090"><a href="#L-1090"><span class="linenos">1090</span></a> <span class="k">if</span> <span class="n">p_loc</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">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">:</span> +</span><span id="L-1091"><a href="#L-1091"><span class="linenos">1091</span></a> <span class="n">with_properties</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> +</span><span id="L-1092"><a href="#L-1092"><span class="linenos">1092</span></a> <span class="k">elif</span> <span class="n">p_loc</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">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">:</span> +</span><span id="L-1093"><a href="#L-1093"><span class="linenos">1093</span></a> <span class="n">root_properties</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> +</span><span id="L-1094"><a href="#L-1094"><span class="linenos">1094</span></a> +</span><span id="L-1095"><a href="#L-1095"><span class="linenos">1095</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">root_properties</span><span class="p">(</span> +</span><span id="L-1096"><a href="#L-1096"><span class="linenos">1096</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">root_properties</span><span class="p">)</span> +</span><span id="L-1097"><a href="#L-1097"><span class="linenos">1097</span></a> <span class="p">)</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">with_properties</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">with_properties</span><span class="p">))</span> +</span><span id="L-1098"><a href="#L-1098"><span class="linenos">1098</span></a> +</span><span id="L-1099"><a href="#L-1099"><span class="linenos">1099</span></a> <span class="k">def</span> <span class="nf">root_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1100"><a href="#L-1100"><span class="linenos">1100</span></a> <span class="k">if</span> <span class="n">properties</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> +</span><span id="L-1101"><a href="#L-1101"><span class="linenos">1101</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</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">properties</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="kc">False</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-1102"><a href="#L-1102"><span class="linenos">1102</span></a> <span class="k">return</span> <span class="s2">""</span> </span><span id="L-1103"><a href="#L-1103"><span class="linenos">1103</span></a> -</span><span id="L-1104"><a href="#L-1104"><span class="linenos">1104</span></a> <span class="k">def</span> <span class="nf">root_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1105"><a href="#L-1105"><span class="linenos">1105</span></a> <span class="k">if</span> <span class="n">properties</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> -</span><span id="L-1106"><a href="#L-1106"><span class="linenos">1106</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</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">properties</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="kc">False</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-1107"><a href="#L-1107"><span class="linenos">1107</span></a> <span class="k">return</span> <span class="s2">""</span> -</span><span id="L-1108"><a href="#L-1108"><span class="linenos">1108</span></a> -</span><span id="L-1109"><a href="#L-1109"><span class="linenos">1109</span></a> <span class="k">def</span> <span class="nf">properties</span><span class="p">(</span> -</span><span id="L-1110"><a href="#L-1110"><span class="linenos">1110</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="L-1111"><a href="#L-1111"><span class="linenos">1111</span></a> <span class="n">properties</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-1112"><a href="#L-1112"><span class="linenos">1112</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-1113"><a href="#L-1113"><span class="linenos">1113</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-1114"><a href="#L-1114"><span class="linenos">1114</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-1115"><a href="#L-1115"><span class="linenos">1115</span></a> <span class="n">wrapped</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-1116"><a href="#L-1116"><span class="linenos">1116</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1117"><a href="#L-1117"><span class="linenos">1117</span></a> <span class="k">if</span> <span class="n">properties</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> -</span><span id="L-1118"><a href="#L-1118"><span class="linenos">1118</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">properties</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="n">sep</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> -</span><span id="L-1119"><a href="#L-1119"><span class="linenos">1119</span></a> <span class="k">if</span> <span class="n">expressions</span><span class="p">:</span> -</span><span id="L-1120"><a href="#L-1120"><span class="linenos">1120</span></a> <span class="n">expressions</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">expressions</span><span class="p">)</span> <span class="k">if</span> <span class="n">wrapped</span> <span class="k">else</span> <span class="n">expressions</span> -</span><span id="L-1121"><a href="#L-1121"><span class="linenos">1121</span></a> <span class="k">return</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="s1">' '</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">prefix</span><span class="o">.</span><span class="n">strip</span><span class="p">()</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</span><span class="si">}{</span><span class="n">suffix</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1122"><a href="#L-1122"><span class="linenos">1122</span></a> <span class="k">return</span> <span class="s2">""</span> -</span><span id="L-1123"><a href="#L-1123"><span class="linenos">1123</span></a> -</span><span id="L-1124"><a href="#L-1124"><span class="linenos">1124</span></a> <span class="k">def</span> <span class="nf">with_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1125"><a href="#L-1125"><span class="linenos">1125</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span><span class="n">properties</span><span class="p">,</span> <span class="n">prefix</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">"WITH"</span><span class="p">))</span> -</span><span id="L-1126"><a href="#L-1126"><span class="linenos">1126</span></a> -</span><span id="L-1127"><a href="#L-1127"><span class="linenos">1127</span></a> <span class="k">def</span> <span class="nf">locate_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">DefaultDict</span><span class="p">:</span> -</span><span id="L-1128"><a href="#L-1128"><span class="linenos">1128</span></a> <span class="n">properties_locs</span> <span class="o">=</span> <span class="n">defaultdict</span><span class="p">(</span><span class="nb">list</span><span class="p">)</span> -</span><span id="L-1129"><a href="#L-1129"><span class="linenos">1129</span></a> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">properties</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> -</span><span id="L-1130"><a href="#L-1130"><span class="linenos">1130</span></a> <span class="n">p_loc</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">PROPERTIES_LOCATION</span><span class="p">[</span><span class="n">p</span><span class="o">.</span><span class="vm">__class__</span><span class="p">]</span> -</span><span id="L-1131"><a href="#L-1131"><span class="linenos">1131</span></a> <span class="k">if</span> <span class="n">p_loc</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">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span><span class="p">:</span> -</span><span id="L-1132"><a href="#L-1132"><span class="linenos">1132</span></a> <span class="n">properties_locs</span><span class="p">[</span><span class="n">p_loc</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> -</span><span id="L-1133"><a href="#L-1133"><span class="linenos">1133</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-1134"><a href="#L-1134"><span class="linenos">1134</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">p</span><span class="o">.</span><span class="n">key</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="L-1135"><a href="#L-1135"><span class="linenos">1135</span></a> -</span><span id="L-1136"><a href="#L-1136"><span class="linenos">1136</span></a> <span class="k">return</span> <span class="n">properties_locs</span> +</span><span id="L-1104"><a href="#L-1104"><span class="linenos">1104</span></a> <span class="k">def</span> <span class="nf">properties</span><span class="p">(</span> +</span><span id="L-1105"><a href="#L-1105"><span class="linenos">1105</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="L-1106"><a href="#L-1106"><span class="linenos">1106</span></a> <span class="n">properties</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-1107"><a href="#L-1107"><span class="linenos">1107</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-1108"><a href="#L-1108"><span class="linenos">1108</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-1109"><a href="#L-1109"><span class="linenos">1109</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-1110"><a href="#L-1110"><span class="linenos">1110</span></a> <span class="n">wrapped</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-1111"><a href="#L-1111"><span class="linenos">1111</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1112"><a href="#L-1112"><span class="linenos">1112</span></a> <span class="k">if</span> <span class="n">properties</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> +</span><span id="L-1113"><a href="#L-1113"><span class="linenos">1113</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">properties</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="n">sep</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</span><span id="L-1114"><a href="#L-1114"><span class="linenos">1114</span></a> <span class="k">if</span> <span class="n">expressions</span><span class="p">:</span> +</span><span id="L-1115"><a href="#L-1115"><span class="linenos">1115</span></a> <span class="n">expressions</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">expressions</span><span class="p">)</span> <span class="k">if</span> <span class="n">wrapped</span> <span class="k">else</span> <span class="n">expressions</span> +</span><span id="L-1116"><a href="#L-1116"><span class="linenos">1116</span></a> <span class="k">return</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="s1">' '</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">prefix</span><span class="o">.</span><span class="n">strip</span><span class="p">()</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</span><span class="si">}{</span><span class="n">suffix</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1117"><a href="#L-1117"><span class="linenos">1117</span></a> <span class="k">return</span> <span class="s2">""</span> +</span><span id="L-1118"><a href="#L-1118"><span class="linenos">1118</span></a> +</span><span id="L-1119"><a href="#L-1119"><span class="linenos">1119</span></a> <span class="k">def</span> <span class="nf">with_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1120"><a href="#L-1120"><span class="linenos">1120</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span><span class="n">properties</span><span class="p">,</span> <span class="n">prefix</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">"WITH"</span><span class="p">))</span> +</span><span id="L-1121"><a href="#L-1121"><span class="linenos">1121</span></a> +</span><span id="L-1122"><a href="#L-1122"><span class="linenos">1122</span></a> <span class="k">def</span> <span class="nf">locate_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">DefaultDict</span><span class="p">:</span> +</span><span id="L-1123"><a href="#L-1123"><span class="linenos">1123</span></a> <span class="n">properties_locs</span> <span class="o">=</span> <span class="n">defaultdict</span><span class="p">(</span><span class="nb">list</span><span class="p">)</span> +</span><span id="L-1124"><a href="#L-1124"><span class="linenos">1124</span></a> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">properties</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> +</span><span id="L-1125"><a href="#L-1125"><span class="linenos">1125</span></a> <span class="n">p_loc</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">PROPERTIES_LOCATION</span><span class="p">[</span><span class="n">p</span><span class="o">.</span><span class="vm">__class__</span><span class="p">]</span> +</span><span id="L-1126"><a href="#L-1126"><span class="linenos">1126</span></a> <span class="k">if</span> <span class="n">p_loc</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">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span><span class="p">:</span> +</span><span id="L-1127"><a href="#L-1127"><span class="linenos">1127</span></a> <span class="n">properties_locs</span><span class="p">[</span><span class="n">p_loc</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> +</span><span id="L-1128"><a href="#L-1128"><span class="linenos">1128</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-1129"><a href="#L-1129"><span class="linenos">1129</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">p</span><span class="o">.</span><span class="n">key</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="L-1130"><a href="#L-1130"><span class="linenos">1130</span></a> +</span><span id="L-1131"><a href="#L-1131"><span class="linenos">1131</span></a> <span class="k">return</span> <span class="n">properties_locs</span> +</span><span id="L-1132"><a href="#L-1132"><span class="linenos">1132</span></a> +</span><span id="L-1133"><a href="#L-1133"><span class="linenos">1133</span></a> <span class="k">def</span> <span class="nf">property_name</span><span class="p">(</span><span class="bp">self</span><span 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="n">string_key</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-1134"><a href="#L-1134"><span class="linenos">1134</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">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Dot</span><span class="p">):</span> +</span><span id="L-1135"><a href="#L-1135"><span class="linenos">1135</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">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="L-1136"><a href="#L-1136"><span class="linenos">1136</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">name</span><span class="si">}</span><span class="s2">'"</span> <span class="k">if</span> <span class="n">string_key</span> <span class="k">else</span> <span class="n">expression</span><span class="o">.</span><span class="n">name</span> </span><span id="L-1137"><a href="#L-1137"><span class="linenos">1137</span></a> -</span><span id="L-1138"><a href="#L-1138"><span class="linenos">1138</span></a> <span class="k">def</span> <span class="nf">property_name</span><span class="p">(</span><span class="bp">self</span><span 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="n">string_key</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-1139"><a href="#L-1139"><span class="linenos">1139</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">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Dot</span><span class="p">):</span> -</span><span id="L-1140"><a href="#L-1140"><span class="linenos">1140</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">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="L-1141"><a href="#L-1141"><span class="linenos">1141</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">name</span><span class="si">}</span><span class="s2">'"</span> <span class="k">if</span> <span class="n">string_key</span> <span class="k">else</span> <span class="n">expression</span><span class="o">.</span><span class="n">name</span> +</span><span id="L-1138"><a href="#L-1138"><span class="linenos">1138</span></a> <span class="k">def</span> <span class="nf">property_sql</span><span class="p">(</span><span class="bp">self</span><span 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-1139"><a href="#L-1139"><span class="linenos">1139</span></a> <span class="n">property_cls</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="vm">__class__</span> +</span><span id="L-1140"><a href="#L-1140"><span class="linenos">1140</span></a> <span class="k">if</span> <span class="n">property_cls</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Property</span><span class="p">:</span> +</span><span id="L-1141"><a href="#L-1141"><span class="linenos">1141</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">property_name</span><span class="p">(</span><span class="n">expression</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-1142"><a href="#L-1142"><span class="linenos">1142</span></a> -</span><span id="L-1143"><a href="#L-1143"><span class="linenos">1143</span></a> <span class="k">def</span> <span class="nf">property_sql</span><span class="p">(</span><span class="bp">self</span><span 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-1144"><a href="#L-1144"><span class="linenos">1144</span></a> <span class="n">property_cls</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="vm">__class__</span> -</span><span id="L-1145"><a href="#L-1145"><span class="linenos">1145</span></a> <span class="k">if</span> <span class="n">property_cls</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Property</span><span class="p">:</span> -</span><span id="L-1146"><a href="#L-1146"><span class="linenos">1146</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">property_name</span><span class="p">(</span><span class="n">expression</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-1147"><a href="#L-1147"><span class="linenos">1147</span></a> -</span><span id="L-1148"><a href="#L-1148"><span class="linenos">1148</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">property_cls</span><span class="p">)</span> -</span><span id="L-1149"><a href="#L-1149"><span class="linenos">1149</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-1150"><a href="#L-1150"><span class="linenos">1150</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="n">key</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="L-1151"><a href="#L-1151"><span class="linenos">1151</span></a> -</span><span id="L-1152"><a href="#L-1152"><span class="linenos">1152</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-1143"><a href="#L-1143"><span class="linenos">1143</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">property_cls</span><span class="p">)</span> +</span><span id="L-1144"><a href="#L-1144"><span class="linenos">1144</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-1145"><a href="#L-1145"><span class="linenos">1145</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="n">key</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="L-1146"><a href="#L-1146"><span class="linenos">1146</span></a> +</span><span id="L-1147"><a href="#L-1147"><span class="linenos">1147</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-1148"><a href="#L-1148"><span class="linenos">1148</span></a> +</span><span id="L-1149"><a href="#L-1149"><span class="linenos">1149</span></a> <span class="k">def</span> <span class="nf">likeproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">LikeProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1150"><a href="#L-1150"><span class="linenos">1150</span></a> <span class="n">options</span> <span class="o">=</span> <span class="s2">" "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">e</span><span class="o">.</span><span class="n">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">e</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 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">expressions</span><span class="p">)</span> +</span><span id="L-1151"><a href="#L-1151"><span class="linenos">1151</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-1152"><a href="#L-1152"><span class="linenos">1152</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"LIKE </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">options</span><span class="si">}</span><span class="s2">"</span> </span><span id="L-1153"><a href="#L-1153"><span class="linenos">1153</span></a> -</span><span id="L-1154"><a href="#L-1154"><span class="linenos">1154</span></a> <span class="k">def</span> <span class="nf">likeproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">LikeProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1155"><a href="#L-1155"><span class="linenos">1155</span></a> <span class="n">options</span> <span class="o">=</span> <span class="s2">" "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">e</span><span class="o">.</span><span class="n">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">e</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 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">expressions</span><span class="p">)</span> -</span><span id="L-1156"><a href="#L-1156"><span class="linenos">1156</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-1157"><a href="#L-1157"><span class="linenos">1157</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"LIKE </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">options</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1154"><a href="#L-1154"><span class="linenos">1154</span></a> <span class="k">def</span> <span class="nf">fallbackproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">FallbackProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1155"><a href="#L-1155"><span class="linenos">1155</span></a> <span class="n">no</span> <span class="o">=</span> <span class="s2">"NO "</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">"no"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1156"><a href="#L-1156"><span class="linenos">1156</span></a> <span class="n">protection</span> <span class="o">=</span> <span class="s2">" PROTECTION"</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">"protection"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1157"><a href="#L-1157"><span class="linenos">1157</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">no</span><span class="si">}</span><span class="s2">FALLBACK</span><span class="si">{</span><span class="n">protection</span><span class="si">}</span><span class="s2">"</span> </span><span id="L-1158"><a href="#L-1158"><span class="linenos">1158</span></a> -</span><span id="L-1159"><a href="#L-1159"><span class="linenos">1159</span></a> <span class="k">def</span> <span class="nf">fallbackproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">FallbackProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1159"><a href="#L-1159"><span class="linenos">1159</span></a> <span class="k">def</span> <span class="nf">journalproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">JournalProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> </span><span id="L-1160"><a href="#L-1160"><span class="linenos">1160</span></a> <span class="n">no</span> <span class="o">=</span> <span class="s2">"NO "</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">"no"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1161"><a href="#L-1161"><span class="linenos">1161</span></a> <span class="n">protection</span> <span class="o">=</span> <span class="s2">" PROTECTION"</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">"protection"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1162"><a href="#L-1162"><span class="linenos">1162</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">no</span><span class="si">}</span><span class="s2">FALLBACK</span><span class="si">{</span><span class="n">protection</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1163"><a href="#L-1163"><span class="linenos">1163</span></a> -</span><span id="L-1164"><a href="#L-1164"><span class="linenos">1164</span></a> <span class="k">def</span> <span class="nf">journalproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">JournalProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1165"><a href="#L-1165"><span class="linenos">1165</span></a> <span class="n">no</span> <span class="o">=</span> <span class="s2">"NO "</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">"no"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1166"><a href="#L-1166"><span class="linenos">1166</span></a> <span class="n">local</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">"local"</span><span class="p">)</span> -</span><span id="L-1167"><a href="#L-1167"><span class="linenos">1167</span></a> <span class="n">local</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">local</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">local</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1168"><a href="#L-1168"><span class="linenos">1168</span></a> <span class="n">dual</span> <span class="o">=</span> <span class="s2">"DUAL "</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">"dual"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1169"><a href="#L-1169"><span class="linenos">1169</span></a> <span class="n">before</span> <span class="o">=</span> <span class="s2">"BEFORE "</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">"before"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1170"><a href="#L-1170"><span class="linenos">1170</span></a> <span class="n">after</span> <span class="o">=</span> <span class="s2">"AFTER "</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">"after"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1171"><a href="#L-1171"><span class="linenos">1171</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">no</span><span class="si">}{</span><span class="n">local</span><span class="si">}{</span><span class="n">dual</span><span class="si">}{</span><span class="n">before</span><span class="si">}{</span><span class="n">after</span><span class="si">}</span><span class="s2">JOURNAL"</span> +</span><span id="L-1161"><a href="#L-1161"><span class="linenos">1161</span></a> <span class="n">local</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">"local"</span><span class="p">)</span> +</span><span id="L-1162"><a href="#L-1162"><span class="linenos">1162</span></a> <span class="n">local</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">local</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">local</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1163"><a href="#L-1163"><span class="linenos">1163</span></a> <span class="n">dual</span> <span class="o">=</span> <span class="s2">"DUAL "</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">"dual"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1164"><a href="#L-1164"><span class="linenos">1164</span></a> <span class="n">before</span> <span class="o">=</span> <span class="s2">"BEFORE "</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">"before"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1165"><a href="#L-1165"><span class="linenos">1165</span></a> <span class="n">after</span> <span class="o">=</span> <span class="s2">"AFTER "</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">"after"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1166"><a href="#L-1166"><span class="linenos">1166</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">no</span><span class="si">}{</span><span class="n">local</span><span class="si">}{</span><span class="n">dual</span><span class="si">}{</span><span class="n">before</span><span class="si">}{</span><span class="n">after</span><span class="si">}</span><span class="s2">JOURNAL"</span> +</span><span id="L-1167"><a href="#L-1167"><span class="linenos">1167</span></a> +</span><span id="L-1168"><a href="#L-1168"><span class="linenos">1168</span></a> <span class="k">def</span> <span class="nf">freespaceproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">FreespaceProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1169"><a href="#L-1169"><span class="linenos">1169</span></a> <span class="n">freespace</span> <span class="o">=</span> <span class="bp">self</span><span 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-1170"><a href="#L-1170"><span class="linenos">1170</span></a> <span class="n">percent</span> <span class="o">=</span> <span class="s2">" PERCENT"</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">"percent"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1171"><a href="#L-1171"><span class="linenos">1171</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"FREESPACE=</span><span class="si">{</span><span class="n">freespace</span><span class="si">}{</span><span class="n">percent</span><span class="si">}</span><span class="s2">"</span> </span><span id="L-1172"><a href="#L-1172"><span class="linenos">1172</span></a> -</span><span id="L-1173"><a href="#L-1173"><span class="linenos">1173</span></a> <span class="k">def</span> <span class="nf">freespaceproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">FreespaceProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1174"><a href="#L-1174"><span class="linenos">1174</span></a> <span class="n">freespace</span> <span class="o">=</span> <span class="bp">self</span><span 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-1175"><a href="#L-1175"><span class="linenos">1175</span></a> <span class="n">percent</span> <span class="o">=</span> <span class="s2">" PERCENT"</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">"percent"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1176"><a href="#L-1176"><span class="linenos">1176</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"FREESPACE=</span><span class="si">{</span><span class="n">freespace</span><span class="si">}{</span><span class="n">percent</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1177"><a href="#L-1177"><span class="linenos">1177</span></a> -</span><span id="L-1178"><a href="#L-1178"><span class="linenos">1178</span></a> <span class="k">def</span> <span class="nf">checksumproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ChecksumProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1179"><a href="#L-1179"><span class="linenos">1179</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">"default"</span><span class="p">):</span> -</span><span id="L-1180"><a href="#L-1180"><span class="linenos">1180</span></a> <span class="nb">property</span> <span class="o">=</span> <span class="s2">"DEFAULT"</span> -</span><span id="L-1181"><a href="#L-1181"><span class="linenos">1181</span></a> <span class="k">elif</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">"on"</span><span class="p">):</span> -</span><span id="L-1182"><a href="#L-1182"><span class="linenos">1182</span></a> <span class="nb">property</span> <span class="o">=</span> <span class="s2">"ON"</span> -</span><span id="L-1183"><a href="#L-1183"><span class="linenos">1183</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-1184"><a href="#L-1184"><span class="linenos">1184</span></a> <span class="nb">property</span> <span class="o">=</span> <span class="s2">"OFF"</span> -</span><span id="L-1185"><a href="#L-1185"><span class="linenos">1185</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CHECKSUM=</span><span class="si">{</span><span class="nb">property</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1186"><a href="#L-1186"><span class="linenos">1186</span></a> -</span><span id="L-1187"><a href="#L-1187"><span class="linenos">1187</span></a> <span class="k">def</span> <span class="nf">mergeblockratioproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">MergeBlockRatioProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1188"><a href="#L-1188"><span class="linenos">1188</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">"no"</span><span class="p">):</span> -</span><span id="L-1189"><a href="#L-1189"><span class="linenos">1189</span></a> <span class="k">return</span> <span class="s2">"NO MERGEBLOCKRATIO"</span> -</span><span id="L-1190"><a href="#L-1190"><span class="linenos">1190</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">"default"</span><span class="p">):</span> -</span><span id="L-1191"><a href="#L-1191"><span class="linenos">1191</span></a> <span class="k">return</span> <span class="s2">"DEFAULT MERGEBLOCKRATIO"</span> -</span><span id="L-1192"><a href="#L-1192"><span class="linenos">1192</span></a> -</span><span id="L-1193"><a href="#L-1193"><span class="linenos">1193</span></a> <span class="n">percent</span> <span class="o">=</span> <span class="s2">" PERCENT"</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">"percent"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1194"><a href="#L-1194"><span class="linenos">1194</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"MERGEBLOCKRATIO=</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">percent</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1195"><a href="#L-1195"><span class="linenos">1195</span></a> -</span><span id="L-1196"><a href="#L-1196"><span class="linenos">1196</span></a> <span class="k">def</span> <span class="nf">datablocksizeproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataBlocksizeProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1197"><a href="#L-1197"><span class="linenos">1197</span></a> <span class="n">default</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">"default"</span><span class="p">)</span> -</span><span id="L-1198"><a href="#L-1198"><span class="linenos">1198</span></a> <span class="n">minimum</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">"minimum"</span><span class="p">)</span> -</span><span id="L-1199"><a href="#L-1199"><span class="linenos">1199</span></a> <span class="n">maximum</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">"maximum"</span><span class="p">)</span> -</span><span id="L-1200"><a href="#L-1200"><span class="linenos">1200</span></a> <span class="k">if</span> <span class="n">default</span> <span class="ow">or</span> <span class="n">minimum</span> <span class="ow">or</span> <span class="n">maximum</span><span class="p">:</span> -</span><span id="L-1201"><a href="#L-1201"><span class="linenos">1201</span></a> <span class="k">if</span> <span class="n">default</span><span class="p">:</span> -</span><span id="L-1202"><a href="#L-1202"><span class="linenos">1202</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"DEFAULT"</span> -</span><span id="L-1203"><a href="#L-1203"><span class="linenos">1203</span></a> <span class="k">elif</span> <span class="n">minimum</span><span class="p">:</span> -</span><span id="L-1204"><a href="#L-1204"><span class="linenos">1204</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"MINIMUM"</span> -</span><span id="L-1205"><a href="#L-1205"><span class="linenos">1205</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-1206"><a href="#L-1206"><span class="linenos">1206</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"MAXIMUM"</span> -</span><span id="L-1207"><a href="#L-1207"><span class="linenos">1207</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">prop</span><span class="si">}</span><span class="s2"> DATABLOCKSIZE"</span> -</span><span id="L-1208"><a href="#L-1208"><span class="linenos">1208</span></a> <span class="n">units</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">"units"</span><span class="p">)</span> -</span><span id="L-1209"><a href="#L-1209"><span class="linenos">1209</span></a> <span class="n">units</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">units</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">units</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1210"><a href="#L-1210"><span class="linenos">1210</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"DATABLOCKSIZE=</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">'size'</span><span class="p">)</span><span class="si">}{</span><span class="n">units</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1211"><a href="#L-1211"><span class="linenos">1211</span></a> -</span><span id="L-1212"><a href="#L-1212"><span class="linenos">1212</span></a> <span class="k">def</span> <span class="nf">blockcompressionproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">BlockCompressionProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1213"><a href="#L-1213"><span class="linenos">1213</span></a> <span class="n">autotemp</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">"autotemp"</span><span class="p">)</span> -</span><span id="L-1214"><a href="#L-1214"><span class="linenos">1214</span></a> <span class="n">always</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">"always"</span><span class="p">)</span> -</span><span id="L-1215"><a href="#L-1215"><span class="linenos">1215</span></a> <span class="n">default</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">"default"</span><span class="p">)</span> -</span><span id="L-1216"><a href="#L-1216"><span class="linenos">1216</span></a> <span class="n">manual</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">"manual"</span><span class="p">)</span> -</span><span id="L-1217"><a href="#L-1217"><span class="linenos">1217</span></a> <span class="n">never</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">"never"</span><span class="p">)</span> -</span><span id="L-1218"><a href="#L-1218"><span class="linenos">1218</span></a> -</span><span id="L-1219"><a href="#L-1219"><span class="linenos">1219</span></a> <span class="k">if</span> <span class="n">autotemp</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="L-1220"><a href="#L-1220"><span class="linenos">1220</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"AUTOTEMP(</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">autotemp</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="L-1221"><a href="#L-1221"><span class="linenos">1221</span></a> <span class="k">elif</span> <span class="n">always</span><span class="p">:</span> -</span><span id="L-1222"><a href="#L-1222"><span class="linenos">1222</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"ALWAYS"</span> -</span><span id="L-1223"><a href="#L-1223"><span class="linenos">1223</span></a> <span class="k">elif</span> <span class="n">default</span><span class="p">:</span> -</span><span id="L-1224"><a href="#L-1224"><span class="linenos">1224</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"DEFAULT"</span> -</span><span id="L-1225"><a href="#L-1225"><span class="linenos">1225</span></a> <span class="k">elif</span> <span class="n">manual</span><span class="p">:</span> -</span><span id="L-1226"><a href="#L-1226"><span class="linenos">1226</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"MANUAL"</span> -</span><span id="L-1227"><a href="#L-1227"><span class="linenos">1227</span></a> <span class="k">elif</span> <span class="n">never</span><span class="p">:</span> -</span><span id="L-1228"><a href="#L-1228"><span class="linenos">1228</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"NEVER"</span> -</span><span id="L-1229"><a href="#L-1229"><span class="linenos">1229</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"BLOCKCOMPRESSION=</span><span class="si">{</span><span class="n">prop</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1230"><a href="#L-1230"><span class="linenos">1230</span></a> -</span><span id="L-1231"><a href="#L-1231"><span class="linenos">1231</span></a> <span class="k">def</span> <span class="nf">isolatedloadingproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">IsolatedLoadingProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1232"><a href="#L-1232"><span class="linenos">1232</span></a> <span class="n">no</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">"no"</span><span class="p">)</span> -</span><span id="L-1233"><a href="#L-1233"><span class="linenos">1233</span></a> <span class="n">no</span> <span class="o">=</span> <span class="s2">" NO"</span> <span class="k">if</span> <span class="n">no</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1234"><a href="#L-1234"><span class="linenos">1234</span></a> <span class="n">concurrent</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">"concurrent"</span><span class="p">)</span> -</span><span id="L-1235"><a href="#L-1235"><span class="linenos">1235</span></a> <span class="n">concurrent</span> <span class="o">=</span> <span class="s2">" CONCURRENT"</span> <span class="k">if</span> <span class="n">concurrent</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1236"><a href="#L-1236"><span class="linenos">1236</span></a> -</span><span id="L-1237"><a href="#L-1237"><span class="linenos">1237</span></a> <span class="n">for_</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="L-1238"><a href="#L-1238"><span class="linenos">1238</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">"for_all"</span><span class="p">):</span> -</span><span id="L-1239"><a href="#L-1239"><span class="linenos">1239</span></a> <span class="n">for_</span> <span class="o">=</span> <span class="s2">" FOR ALL"</span> -</span><span id="L-1240"><a href="#L-1240"><span class="linenos">1240</span></a> <span class="k">elif</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">"for_insert"</span><span class="p">):</span> -</span><span id="L-1241"><a href="#L-1241"><span class="linenos">1241</span></a> <span class="n">for_</span> <span class="o">=</span> <span class="s2">" FOR INSERT"</span> -</span><span id="L-1242"><a href="#L-1242"><span class="linenos">1242</span></a> <span class="k">elif</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">"for_none"</span><span class="p">):</span> -</span><span id="L-1243"><a href="#L-1243"><span class="linenos">1243</span></a> <span class="n">for_</span> <span class="o">=</span> <span class="s2">" FOR NONE"</span> -</span><span id="L-1244"><a href="#L-1244"><span class="linenos">1244</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"WITH</span><span class="si">{</span><span class="n">no</span><span class="si">}{</span><span class="n">concurrent</span><span class="si">}</span><span class="s2"> ISOLATED LOADING</span><span class="si">{</span><span class="n">for_</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1245"><a href="#L-1245"><span class="linenos">1245</span></a> -</span><span id="L-1246"><a href="#L-1246"><span class="linenos">1246</span></a> <span class="k">def</span> <span class="nf">partitionboundspec_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionBoundSpec</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1247"><a href="#L-1247"><span class="linenos">1247</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">this</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span> -</span><span id="L-1248"><a href="#L-1248"><span class="linenos">1248</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"IN (</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">'this'</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-1249"><a href="#L-1249"><span class="linenos">1249</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">:</span> -</span><span id="L-1250"><a href="#L-1250"><span class="linenos">1250</span></a> <span class="n">modulus</span> <span class="o">=</span> <span class="bp">self</span><span 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-1251"><a href="#L-1251"><span class="linenos">1251</span></a> <span class="n">remainder</span> <span class="o">=</span> <span class="bp">self</span><span 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-1252"><a href="#L-1252"><span class="linenos">1252</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"WITH (MODULUS </span><span class="si">{</span><span class="n">modulus</span><span class="si">}</span><span class="s2">, REMAINDER </span><span class="si">{</span><span class="n">remainder</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="L-1253"><a href="#L-1253"><span class="linenos">1253</span></a> -</span><span id="L-1254"><a href="#L-1254"><span class="linenos">1254</span></a> <span class="n">from_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">"from_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-1255"><a href="#L-1255"><span class="linenos">1255</span></a> <span class="n">to_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">"to_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-1256"><a href="#L-1256"><span class="linenos">1256</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"FROM (</span><span class="si">{</span><span class="n">from_expressions</span><span class="si">}</span><span class="s2">) TO (</span><span class="si">{</span><span class="n">to_expressions</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="L-1257"><a href="#L-1257"><span class="linenos">1257</span></a> -</span><span id="L-1258"><a href="#L-1258"><span class="linenos">1258</span></a> <span class="k">def</span> <span class="nf">partitionedofproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionedOfProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1259"><a href="#L-1259"><span class="linenos">1259</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-1260"><a href="#L-1260"><span class="linenos">1260</span></a> -</span><span id="L-1261"><a href="#L-1261"><span class="linenos">1261</span></a> <span class="n">for_values_or_default</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span> -</span><span id="L-1262"><a href="#L-1262"><span class="linenos">1262</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">for_values_or_default</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionBoundSpec</span><span class="p">):</span> -</span><span id="L-1263"><a href="#L-1263"><span class="linenos">1263</span></a> <span class="n">for_values_or_default</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" FOR 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">for_values_or_default</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1264"><a href="#L-1264"><span class="linenos">1264</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-1265"><a href="#L-1265"><span class="linenos">1265</span></a> <span class="n">for_values_or_default</span> <span class="o">=</span> <span class="s2">" DEFAULT"</span> -</span><span id="L-1266"><a href="#L-1266"><span class="linenos">1266</span></a> -</span><span id="L-1267"><a href="#L-1267"><span class="linenos">1267</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PARTITION OF </span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">for_values_or_default</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1268"><a href="#L-1268"><span class="linenos">1268</span></a> -</span><span id="L-1269"><a href="#L-1269"><span class="linenos">1269</span></a> <span class="k">def</span> <span class="nf">lockingproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">LockingProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1270"><a href="#L-1270"><span class="linenos">1270</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="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">)</span> -</span><span id="L-1271"><a href="#L-1271"><span class="linenos">1271</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="bp">self</span><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="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-1272"><a href="#L-1272"><span class="linenos">1272</span></a> <span class="n">for_or_in</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">"for_or_in"</span><span class="p">)</span> -</span><span id="L-1273"><a href="#L-1273"><span class="linenos">1273</span></a> <span class="n">for_or_in</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">for_or_in</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">for_or_in</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1274"><a href="#L-1274"><span class="linenos">1274</span></a> <span class="n">lock_type</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">"lock_type"</span><span class="p">)</span> -</span><span id="L-1275"><a href="#L-1275"><span class="linenos">1275</span></a> <span class="n">override</span> <span class="o">=</span> <span class="s2">" OVERRIDE"</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">"override"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1276"><a href="#L-1276"><span class="linenos">1276</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"LOCKING </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">for_or_in</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">lock_type</span><span class="si">}{</span><span class="n">override</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1277"><a href="#L-1277"><span class="linenos">1277</span></a> -</span><span id="L-1278"><a href="#L-1278"><span class="linenos">1278</span></a> <span class="k">def</span> <span class="nf">withdataproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">WithDataProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1279"><a href="#L-1279"><span class="linenos">1279</span></a> <span class="n">data_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"WITH </span><span class="si">{</span><span class="s1">'NO '</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">'no'</span><span class="p">)</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">DATA"</span> -</span><span id="L-1280"><a href="#L-1280"><span class="linenos">1280</span></a> <span class="n">statistics</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">"statistics"</span><span class="p">)</span> -</span><span id="L-1281"><a href="#L-1281"><span class="linenos">1281</span></a> <span class="n">statistics_sql</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="L-1282"><a href="#L-1282"><span class="linenos">1282</span></a> <span class="k">if</span> <span class="n">statistics</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="L-1283"><a href="#L-1283"><span class="linenos">1283</span></a> <span class="n">statistics_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AND </span><span class="si">{</span><span class="s1">'NO '</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="ow">not</span><span class="w"> </span><span class="n">statistics</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">STATISTICS"</span> -</span><span id="L-1284"><a href="#L-1284"><span class="linenos">1284</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">data_sql</span><span class="si">}{</span><span class="n">statistics_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1285"><a href="#L-1285"><span class="linenos">1285</span></a> -</span><span id="L-1286"><a href="#L-1286"><span class="linenos">1286</span></a> <span class="k">def</span> <span class="nf">withsystemversioningproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">WithSystemVersioningProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1287"><a href="#L-1287"><span class="linenos">1287</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="s2">"WITH(SYSTEM_VERSIONING=ON"</span> -</span><span id="L-1288"><a href="#L-1288"><span class="linenos">1288</span></a> -</span><span id="L-1289"><a href="#L-1289"><span class="linenos">1289</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">:</span> -</span><span id="L-1290"><a href="#L-1290"><span class="linenos">1290</span></a> <span class="n">history_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">"this"</span><span class="p">)</span> -</span><span id="L-1291"><a href="#L-1291"><span class="linenos">1291</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="s2">(HISTORY_TABLE=</span><span class="si">{</span><span class="n">history_table</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1292"><a href="#L-1292"><span class="linenos">1292</span></a> -</span><span id="L-1293"><a href="#L-1293"><span class="linenos">1293</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span><span class="p">:</span> -</span><span id="L-1294"><a href="#L-1294"><span class="linenos">1294</span></a> <span class="n">data_consistency_check</span> <span class="o">=</span> <span class="bp">self</span><span 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-1295"><a href="#L-1295"><span class="linenos">1295</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="s2">, DATA_CONSISTENCY_CHECK=</span><span class="si">{</span><span class="n">data_consistency_check</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1296"><a href="#L-1296"><span class="linenos">1296</span></a> -</span><span id="L-1297"><a href="#L-1297"><span class="linenos">1297</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="s2">)"</span> +</span><span id="L-1173"><a href="#L-1173"><span class="linenos">1173</span></a> <span class="k">def</span> <span class="nf">checksumproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ChecksumProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1174"><a href="#L-1174"><span class="linenos">1174</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">"default"</span><span class="p">):</span> +</span><span id="L-1175"><a href="#L-1175"><span class="linenos">1175</span></a> <span class="nb">property</span> <span class="o">=</span> <span class="s2">"DEFAULT"</span> +</span><span id="L-1176"><a href="#L-1176"><span class="linenos">1176</span></a> <span class="k">elif</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">"on"</span><span class="p">):</span> +</span><span id="L-1177"><a href="#L-1177"><span class="linenos">1177</span></a> <span class="nb">property</span> <span class="o">=</span> <span class="s2">"ON"</span> +</span><span id="L-1178"><a href="#L-1178"><span class="linenos">1178</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-1179"><a href="#L-1179"><span class="linenos">1179</span></a> <span class="nb">property</span> <span class="o">=</span> <span class="s2">"OFF"</span> +</span><span id="L-1180"><a href="#L-1180"><span class="linenos">1180</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CHECKSUM=</span><span class="si">{</span><span class="nb">property</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1181"><a href="#L-1181"><span class="linenos">1181</span></a> +</span><span id="L-1182"><a href="#L-1182"><span class="linenos">1182</span></a> <span class="k">def</span> <span class="nf">mergeblockratioproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">MergeBlockRatioProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1183"><a href="#L-1183"><span class="linenos">1183</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">"no"</span><span class="p">):</span> +</span><span id="L-1184"><a href="#L-1184"><span class="linenos">1184</span></a> <span class="k">return</span> <span class="s2">"NO MERGEBLOCKRATIO"</span> +</span><span id="L-1185"><a href="#L-1185"><span class="linenos">1185</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">"default"</span><span class="p">):</span> +</span><span id="L-1186"><a href="#L-1186"><span class="linenos">1186</span></a> <span class="k">return</span> <span class="s2">"DEFAULT MERGEBLOCKRATIO"</span> +</span><span id="L-1187"><a href="#L-1187"><span class="linenos">1187</span></a> +</span><span id="L-1188"><a href="#L-1188"><span class="linenos">1188</span></a> <span class="n">percent</span> <span class="o">=</span> <span class="s2">" PERCENT"</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">"percent"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1189"><a href="#L-1189"><span class="linenos">1189</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"MERGEBLOCKRATIO=</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">percent</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1190"><a href="#L-1190"><span class="linenos">1190</span></a> +</span><span id="L-1191"><a href="#L-1191"><span class="linenos">1191</span></a> <span class="k">def</span> <span class="nf">datablocksizeproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataBlocksizeProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1192"><a href="#L-1192"><span class="linenos">1192</span></a> <span class="n">default</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">"default"</span><span class="p">)</span> +</span><span id="L-1193"><a href="#L-1193"><span class="linenos">1193</span></a> <span class="n">minimum</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">"minimum"</span><span class="p">)</span> +</span><span id="L-1194"><a href="#L-1194"><span class="linenos">1194</span></a> <span class="n">maximum</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">"maximum"</span><span class="p">)</span> +</span><span id="L-1195"><a href="#L-1195"><span class="linenos">1195</span></a> <span class="k">if</span> <span class="n">default</span> <span class="ow">or</span> <span class="n">minimum</span> <span class="ow">or</span> <span class="n">maximum</span><span class="p">:</span> +</span><span id="L-1196"><a href="#L-1196"><span class="linenos">1196</span></a> <span class="k">if</span> <span class="n">default</span><span class="p">:</span> +</span><span id="L-1197"><a href="#L-1197"><span class="linenos">1197</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"DEFAULT"</span> +</span><span id="L-1198"><a href="#L-1198"><span class="linenos">1198</span></a> <span class="k">elif</span> <span class="n">minimum</span><span class="p">:</span> +</span><span id="L-1199"><a href="#L-1199"><span class="linenos">1199</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"MINIMUM"</span> +</span><span id="L-1200"><a href="#L-1200"><span class="linenos">1200</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-1201"><a href="#L-1201"><span class="linenos">1201</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"MAXIMUM"</span> +</span><span id="L-1202"><a href="#L-1202"><span class="linenos">1202</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">prop</span><span class="si">}</span><span class="s2"> DATABLOCKSIZE"</span> +</span><span id="L-1203"><a href="#L-1203"><span class="linenos">1203</span></a> <span class="n">units</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">"units"</span><span class="p">)</span> +</span><span id="L-1204"><a href="#L-1204"><span class="linenos">1204</span></a> <span class="n">units</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">units</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">units</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1205"><a href="#L-1205"><span class="linenos">1205</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"DATABLOCKSIZE=</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">'size'</span><span class="p">)</span><span class="si">}{</span><span class="n">units</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1206"><a href="#L-1206"><span class="linenos">1206</span></a> +</span><span id="L-1207"><a href="#L-1207"><span class="linenos">1207</span></a> <span class="k">def</span> <span class="nf">blockcompressionproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">BlockCompressionProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1208"><a href="#L-1208"><span class="linenos">1208</span></a> <span class="n">autotemp</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">"autotemp"</span><span class="p">)</span> +</span><span id="L-1209"><a href="#L-1209"><span class="linenos">1209</span></a> <span class="n">always</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">"always"</span><span class="p">)</span> +</span><span id="L-1210"><a href="#L-1210"><span class="linenos">1210</span></a> <span class="n">default</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">"default"</span><span class="p">)</span> +</span><span id="L-1211"><a href="#L-1211"><span class="linenos">1211</span></a> <span class="n">manual</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">"manual"</span><span class="p">)</span> +</span><span id="L-1212"><a href="#L-1212"><span class="linenos">1212</span></a> <span class="n">never</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">"never"</span><span class="p">)</span> +</span><span id="L-1213"><a href="#L-1213"><span class="linenos">1213</span></a> +</span><span id="L-1214"><a href="#L-1214"><span class="linenos">1214</span></a> <span class="k">if</span> <span class="n">autotemp</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-1215"><a href="#L-1215"><span class="linenos">1215</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"AUTOTEMP(</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">autotemp</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="L-1216"><a href="#L-1216"><span class="linenos">1216</span></a> <span class="k">elif</span> <span class="n">always</span><span class="p">:</span> +</span><span id="L-1217"><a href="#L-1217"><span class="linenos">1217</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"ALWAYS"</span> +</span><span id="L-1218"><a href="#L-1218"><span class="linenos">1218</span></a> <span class="k">elif</span> <span class="n">default</span><span class="p">:</span> +</span><span id="L-1219"><a href="#L-1219"><span class="linenos">1219</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"DEFAULT"</span> +</span><span id="L-1220"><a href="#L-1220"><span class="linenos">1220</span></a> <span class="k">elif</span> <span class="n">manual</span><span class="p">:</span> +</span><span id="L-1221"><a href="#L-1221"><span class="linenos">1221</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"MANUAL"</span> +</span><span id="L-1222"><a href="#L-1222"><span class="linenos">1222</span></a> <span class="k">elif</span> <span class="n">never</span><span class="p">:</span> +</span><span id="L-1223"><a href="#L-1223"><span class="linenos">1223</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"NEVER"</span> +</span><span id="L-1224"><a href="#L-1224"><span class="linenos">1224</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"BLOCKCOMPRESSION=</span><span class="si">{</span><span class="n">prop</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1225"><a href="#L-1225"><span class="linenos">1225</span></a> +</span><span id="L-1226"><a href="#L-1226"><span class="linenos">1226</span></a> <span class="k">def</span> <span class="nf">isolatedloadingproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">IsolatedLoadingProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1227"><a href="#L-1227"><span class="linenos">1227</span></a> <span class="n">no</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">"no"</span><span class="p">)</span> +</span><span id="L-1228"><a href="#L-1228"><span class="linenos">1228</span></a> <span class="n">no</span> <span class="o">=</span> <span class="s2">" NO"</span> <span class="k">if</span> <span class="n">no</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1229"><a href="#L-1229"><span class="linenos">1229</span></a> <span class="n">concurrent</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">"concurrent"</span><span class="p">)</span> +</span><span id="L-1230"><a href="#L-1230"><span class="linenos">1230</span></a> <span class="n">concurrent</span> <span class="o">=</span> <span class="s2">" CONCURRENT"</span> <span class="k">if</span> <span class="n">concurrent</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1231"><a href="#L-1231"><span class="linenos">1231</span></a> +</span><span id="L-1232"><a href="#L-1232"><span class="linenos">1232</span></a> <span class="n">for_</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="L-1233"><a href="#L-1233"><span class="linenos">1233</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">"for_all"</span><span class="p">):</span> +</span><span id="L-1234"><a href="#L-1234"><span class="linenos">1234</span></a> <span class="n">for_</span> <span class="o">=</span> <span class="s2">" FOR ALL"</span> +</span><span id="L-1235"><a href="#L-1235"><span class="linenos">1235</span></a> <span class="k">elif</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">"for_insert"</span><span class="p">):</span> +</span><span id="L-1236"><a href="#L-1236"><span class="linenos">1236</span></a> <span class="n">for_</span> <span class="o">=</span> <span class="s2">" FOR INSERT"</span> +</span><span id="L-1237"><a href="#L-1237"><span class="linenos">1237</span></a> <span class="k">elif</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">"for_none"</span><span class="p">):</span> +</span><span id="L-1238"><a href="#L-1238"><span class="linenos">1238</span></a> <span class="n">for_</span> <span class="o">=</span> <span class="s2">" FOR NONE"</span> +</span><span id="L-1239"><a href="#L-1239"><span class="linenos">1239</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"WITH</span><span class="si">{</span><span class="n">no</span><span class="si">}{</span><span class="n">concurrent</span><span class="si">}</span><span class="s2"> ISOLATED LOADING</span><span class="si">{</span><span class="n">for_</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1240"><a href="#L-1240"><span class="linenos">1240</span></a> +</span><span id="L-1241"><a href="#L-1241"><span class="linenos">1241</span></a> <span class="k">def</span> <span class="nf">partitionboundspec_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionBoundSpec</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1242"><a href="#L-1242"><span class="linenos">1242</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">this</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span> +</span><span id="L-1243"><a href="#L-1243"><span class="linenos">1243</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"IN (</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">'this'</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-1244"><a href="#L-1244"><span class="linenos">1244</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">:</span> +</span><span id="L-1245"><a href="#L-1245"><span class="linenos">1245</span></a> <span class="n">modulus</span> <span class="o">=</span> <span class="bp">self</span><span 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-1246"><a href="#L-1246"><span class="linenos">1246</span></a> <span class="n">remainder</span> <span class="o">=</span> <span class="bp">self</span><span 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-1247"><a href="#L-1247"><span class="linenos">1247</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"WITH (MODULUS </span><span class="si">{</span><span class="n">modulus</span><span class="si">}</span><span class="s2">, REMAINDER </span><span class="si">{</span><span class="n">remainder</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="L-1248"><a href="#L-1248"><span class="linenos">1248</span></a> +</span><span id="L-1249"><a href="#L-1249"><span class="linenos">1249</span></a> <span class="n">from_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">"from_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-1250"><a href="#L-1250"><span class="linenos">1250</span></a> <span class="n">to_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">"to_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-1251"><a href="#L-1251"><span class="linenos">1251</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"FROM (</span><span class="si">{</span><span class="n">from_expressions</span><span class="si">}</span><span class="s2">) TO (</span><span class="si">{</span><span class="n">to_expressions</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="L-1252"><a href="#L-1252"><span class="linenos">1252</span></a> +</span><span id="L-1253"><a href="#L-1253"><span class="linenos">1253</span></a> <span class="k">def</span> <span class="nf">partitionedofproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionedOfProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1254"><a href="#L-1254"><span class="linenos">1254</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-1255"><a href="#L-1255"><span class="linenos">1255</span></a> +</span><span id="L-1256"><a href="#L-1256"><span class="linenos">1256</span></a> <span class="n">for_values_or_default</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span> +</span><span id="L-1257"><a href="#L-1257"><span class="linenos">1257</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">for_values_or_default</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionBoundSpec</span><span class="p">):</span> +</span><span id="L-1258"><a href="#L-1258"><span class="linenos">1258</span></a> <span class="n">for_values_or_default</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" FOR 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">for_values_or_default</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1259"><a href="#L-1259"><span class="linenos">1259</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-1260"><a href="#L-1260"><span class="linenos">1260</span></a> <span class="n">for_values_or_default</span> <span class="o">=</span> <span class="s2">" DEFAULT"</span> +</span><span id="L-1261"><a href="#L-1261"><span class="linenos">1261</span></a> +</span><span id="L-1262"><a href="#L-1262"><span class="linenos">1262</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PARTITION OF </span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">for_values_or_default</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1263"><a href="#L-1263"><span class="linenos">1263</span></a> +</span><span id="L-1264"><a href="#L-1264"><span class="linenos">1264</span></a> <span class="k">def</span> <span class="nf">lockingproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">LockingProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1265"><a href="#L-1265"><span class="linenos">1265</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="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">)</span> +</span><span id="L-1266"><a href="#L-1266"><span class="linenos">1266</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="bp">self</span><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="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-1267"><a href="#L-1267"><span class="linenos">1267</span></a> <span class="n">for_or_in</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">"for_or_in"</span><span class="p">)</span> +</span><span id="L-1268"><a href="#L-1268"><span class="linenos">1268</span></a> <span class="n">for_or_in</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">for_or_in</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">for_or_in</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1269"><a href="#L-1269"><span class="linenos">1269</span></a> <span class="n">lock_type</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">"lock_type"</span><span class="p">)</span> +</span><span id="L-1270"><a href="#L-1270"><span class="linenos">1270</span></a> <span class="n">override</span> <span class="o">=</span> <span class="s2">" OVERRIDE"</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">"override"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1271"><a href="#L-1271"><span class="linenos">1271</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"LOCKING </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">for_or_in</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">lock_type</span><span class="si">}{</span><span class="n">override</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1272"><a href="#L-1272"><span class="linenos">1272</span></a> +</span><span id="L-1273"><a href="#L-1273"><span class="linenos">1273</span></a> <span class="k">def</span> <span class="nf">withdataproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">WithDataProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1274"><a href="#L-1274"><span class="linenos">1274</span></a> <span class="n">data_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"WITH </span><span class="si">{</span><span class="s1">'NO '</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">'no'</span><span class="p">)</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">DATA"</span> +</span><span id="L-1275"><a href="#L-1275"><span class="linenos">1275</span></a> <span class="n">statistics</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">"statistics"</span><span class="p">)</span> +</span><span id="L-1276"><a href="#L-1276"><span class="linenos">1276</span></a> <span class="n">statistics_sql</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="L-1277"><a href="#L-1277"><span class="linenos">1277</span></a> <span class="k">if</span> <span class="n">statistics</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-1278"><a href="#L-1278"><span class="linenos">1278</span></a> <span class="n">statistics_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AND </span><span class="si">{</span><span class="s1">'NO '</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="ow">not</span><span class="w"> </span><span class="n">statistics</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">STATISTICS"</span> +</span><span id="L-1279"><a href="#L-1279"><span class="linenos">1279</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">data_sql</span><span class="si">}{</span><span class="n">statistics_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1280"><a href="#L-1280"><span class="linenos">1280</span></a> +</span><span id="L-1281"><a href="#L-1281"><span class="linenos">1281</span></a> <span class="k">def</span> <span class="nf">withsystemversioningproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">WithSystemVersioningProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1282"><a href="#L-1282"><span class="linenos">1282</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="s2">"WITH(SYSTEM_VERSIONING=ON"</span> +</span><span id="L-1283"><a href="#L-1283"><span class="linenos">1283</span></a> +</span><span id="L-1284"><a href="#L-1284"><span class="linenos">1284</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">:</span> +</span><span id="L-1285"><a href="#L-1285"><span class="linenos">1285</span></a> <span class="n">history_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">"this"</span><span class="p">)</span> +</span><span id="L-1286"><a href="#L-1286"><span class="linenos">1286</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="s2">(HISTORY_TABLE=</span><span class="si">{</span><span class="n">history_table</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1287"><a href="#L-1287"><span class="linenos">1287</span></a> +</span><span id="L-1288"><a href="#L-1288"><span class="linenos">1288</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span><span class="p">:</span> +</span><span id="L-1289"><a href="#L-1289"><span class="linenos">1289</span></a> <span class="n">data_consistency_check</span> <span class="o">=</span> <span class="bp">self</span><span 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-1290"><a href="#L-1290"><span class="linenos">1290</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="s2">, DATA_CONSISTENCY_CHECK=</span><span class="si">{</span><span class="n">data_consistency_check</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1291"><a href="#L-1291"><span class="linenos">1291</span></a> +</span><span id="L-1292"><a href="#L-1292"><span class="linenos">1292</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="s2">)"</span> +</span><span id="L-1293"><a href="#L-1293"><span class="linenos">1293</span></a> +</span><span id="L-1294"><a href="#L-1294"><span class="linenos">1294</span></a> <span class="k">return</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="s2">)"</span> +</span><span id="L-1295"><a href="#L-1295"><span class="linenos">1295</span></a> +</span><span id="L-1296"><a href="#L-1296"><span class="linenos">1296</span></a> <span class="k">def</span> <span class="nf">insert_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">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 class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1297"><a href="#L-1297"><span class="linenos">1297</span></a> <span class="n">overwrite</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">"overwrite"</span><span class="p">)</span> </span><span id="L-1298"><a href="#L-1298"><span class="linenos">1298</span></a> -</span><span id="L-1299"><a href="#L-1299"><span class="linenos">1299</span></a> <span class="k">return</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="s2">)"</span> -</span><span id="L-1300"><a href="#L-1300"><span class="linenos">1300</span></a> -</span><span id="L-1301"><a href="#L-1301"><span class="linenos">1301</span></a> <span class="k">def</span> <span class="nf">insert_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">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 class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1302"><a href="#L-1302"><span class="linenos">1302</span></a> <span class="n">overwrite</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">"overwrite"</span><span class="p">)</span> +</span><span id="L-1299"><a href="#L-1299"><span class="linenos">1299</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">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Directory</span><span class="p">):</span> +</span><span id="L-1300"><a href="#L-1300"><span class="linenos">1300</span></a> <span class="n">this</span> <span class="o">=</span> <span class="s2">" OVERWRITE"</span> <span class="k">if</span> <span class="n">overwrite</span> <span class="k">else</span> <span class="s2">" INTO"</span> +</span><span id="L-1301"><a href="#L-1301"><span class="linenos">1301</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-1302"><a href="#L-1302"><span class="linenos">1302</span></a> <span class="n">this</span> <span class="o">=</span> <span class="s2">" OVERWRITE TABLE"</span> <span class="k">if</span> <span class="n">overwrite</span> <span class="k">else</span> <span class="s2">" INTO"</span> </span><span id="L-1303"><a href="#L-1303"><span class="linenos">1303</span></a> -</span><span id="L-1304"><a href="#L-1304"><span class="linenos">1304</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">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Directory</span><span class="p">):</span> -</span><span id="L-1305"><a href="#L-1305"><span class="linenos">1305</span></a> <span class="n">this</span> <span class="o">=</span> <span class="s2">" OVERWRITE"</span> <span class="k">if</span> <span class="n">overwrite</span> <span class="k">else</span> <span class="s2">" INTO"</span> -</span><span id="L-1306"><a href="#L-1306"><span class="linenos">1306</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-1307"><a href="#L-1307"><span class="linenos">1307</span></a> <span class="n">this</span> <span class="o">=</span> <span class="s2">" OVERWRITE TABLE"</span> <span class="k">if</span> <span class="n">overwrite</span> <span class="k">else</span> <span class="s2">" INTO"</span> -</span><span id="L-1308"><a href="#L-1308"><span class="linenos">1308</span></a> -</span><span id="L-1309"><a href="#L-1309"><span class="linenos">1309</span></a> <span class="n">alternative</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">"alternative"</span><span class="p">)</span> -</span><span id="L-1310"><a href="#L-1310"><span class="linenos">1310</span></a> <span class="n">alternative</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" OR </span><span class="si">{</span><span class="n">alternative</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alternative</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1311"><a href="#L-1311"><span class="linenos">1311</span></a> <span class="n">ignore</span> <span class="o">=</span> <span class="s2">" IGNORE"</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">"ignore"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1312"><a href="#L-1312"><span class="linenos">1312</span></a> -</span><span id="L-1313"><a href="#L-1313"><span class="linenos">1313</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="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-1314"><a href="#L-1314"><span class="linenos">1314</span></a> -</span><span id="L-1315"><a href="#L-1315"><span class="linenos">1315</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-1316"><a href="#L-1316"><span class="linenos">1316</span></a> <span class="n">partition_sql</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="L-1317"><a href="#L-1317"><span class="linenos">1317</span></a> <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">'partition'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</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">"partition"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1318"><a href="#L-1318"><span class="linenos">1318</span></a> <span class="p">)</span> -</span><span id="L-1319"><a href="#L-1319"><span class="linenos">1319</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-1320"><a href="#L-1320"><span class="linenos">1320</span></a> <span class="n">where</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="si">}</span><span class="s2">REPLACE WHERE </span><span class="si">{</span><span class="n">where</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">where</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1321"><a href="#L-1321"><span class="linenos">1321</span></a> <span class="n">expression_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">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-1322"><a href="#L-1322"><span class="linenos">1322</span></a> <span class="n">conflict</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"conflict"</span><span class="p">)</span> -</span><span id="L-1323"><a href="#L-1323"><span class="linenos">1323</span></a> <span class="n">by_name</span> <span class="o">=</span> <span class="s2">" BY NAME"</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">"by_name"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1324"><a href="#L-1324"><span class="linenos">1324</span></a> <span class="n">returning</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"returning"</span><span class="p">)</span> +</span><span id="L-1304"><a href="#L-1304"><span class="linenos">1304</span></a> <span class="n">alternative</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">"alternative"</span><span class="p">)</span> +</span><span id="L-1305"><a href="#L-1305"><span class="linenos">1305</span></a> <span class="n">alternative</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" OR </span><span class="si">{</span><span class="n">alternative</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alternative</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1306"><a href="#L-1306"><span class="linenos">1306</span></a> <span class="n">ignore</span> <span class="o">=</span> <span class="s2">" IGNORE"</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">"ignore"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1307"><a href="#L-1307"><span class="linenos">1307</span></a> +</span><span id="L-1308"><a href="#L-1308"><span class="linenos">1308</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="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-1309"><a href="#L-1309"><span class="linenos">1309</span></a> +</span><span id="L-1310"><a href="#L-1310"><span class="linenos">1310</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-1311"><a href="#L-1311"><span class="linenos">1311</span></a> <span class="n">partition_sql</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="L-1312"><a href="#L-1312"><span class="linenos">1312</span></a> <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">'partition'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</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">"partition"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1313"><a href="#L-1313"><span class="linenos">1313</span></a> <span class="p">)</span> +</span><span id="L-1314"><a href="#L-1314"><span class="linenos">1314</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-1315"><a href="#L-1315"><span class="linenos">1315</span></a> <span class="n">where</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="si">}</span><span class="s2">REPLACE WHERE </span><span class="si">{</span><span class="n">where</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">where</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1316"><a href="#L-1316"><span class="linenos">1316</span></a> <span class="n">expression_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">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-1317"><a href="#L-1317"><span class="linenos">1317</span></a> <span class="n">conflict</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"conflict"</span><span class="p">)</span> +</span><span id="L-1318"><a href="#L-1318"><span class="linenos">1318</span></a> <span class="n">by_name</span> <span class="o">=</span> <span class="s2">" BY NAME"</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">"by_name"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1319"><a href="#L-1319"><span class="linenos">1319</span></a> <span class="n">returning</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"returning"</span><span class="p">)</span> +</span><span id="L-1320"><a href="#L-1320"><span class="linenos">1320</span></a> +</span><span id="L-1321"><a href="#L-1321"><span class="linenos">1321</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">RETURNING_END</span><span class="p">:</span> +</span><span id="L-1322"><a href="#L-1322"><span class="linenos">1322</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">expression_sql</span><span class="si">}{</span><span class="n">conflict</span><span class="si">}{</span><span class="n">returning</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1323"><a href="#L-1323"><span class="linenos">1323</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-1324"><a href="#L-1324"><span class="linenos">1324</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">returning</span><span class="si">}{</span><span class="n">expression_sql</span><span class="si">}{</span><span class="n">conflict</span><span class="si">}</span><span class="s2">"</span> </span><span id="L-1325"><a href="#L-1325"><span class="linenos">1325</span></a> -</span><span id="L-1326"><a href="#L-1326"><span class="linenos">1326</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">RETURNING_END</span><span class="p">:</span> -</span><span id="L-1327"><a href="#L-1327"><span class="linenos">1327</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">expression_sql</span><span class="si">}{</span><span class="n">conflict</span><span class="si">}{</span><span class="n">returning</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1328"><a href="#L-1328"><span class="linenos">1328</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-1329"><a href="#L-1329"><span class="linenos">1329</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">returning</span><span class="si">}{</span><span class="n">expression_sql</span><span class="si">}{</span><span class="n">conflict</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1330"><a href="#L-1330"><span class="linenos">1330</span></a> -</span><span id="L-1331"><a href="#L-1331"><span class="linenos">1331</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"INSERT</span><span class="si">{</span><span class="n">alternative</span><span class="si">}{</span><span class="n">ignore</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="n">by_name</span><span class="si">}{</span><span class="n">exists</span><span class="si">}{</span><span class="n">partition_sql</span><span class="si">}{</span><span class="n">where</span><span class="si">}{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1332"><a href="#L-1332"><span class="linenos">1332</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-1333"><a href="#L-1333"><span class="linenos">1333</span></a> -</span><span id="L-1334"><a href="#L-1334"><span class="linenos">1334</span></a> <span class="k">def</span> <span class="nf">intersect_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Intersect</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1335"><a href="#L-1335"><span class="linenos">1335</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><span id="L-1336"><a href="#L-1336"><span class="linenos">1336</span></a> <span class="n">expression</span><span class="p">,</span> -</span><span id="L-1337"><a href="#L-1337"><span class="linenos">1337</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">set_operation</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">intersect_op</span><span class="p">(</span><span class="n">expression</span><span class="p">)),</span> -</span><span id="L-1338"><a href="#L-1338"><span class="linenos">1338</span></a> <span class="p">)</span> -</span><span id="L-1339"><a href="#L-1339"><span class="linenos">1339</span></a> -</span><span id="L-1340"><a href="#L-1340"><span class="linenos">1340</span></a> <span class="k">def</span> <span class="nf">intersect_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Intersect</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1341"><a href="#L-1341"><span class="linenos">1341</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"INTERSECT</span><span class="si">{</span><span class="s1">''</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">'distinct'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">' ALL'</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1342"><a href="#L-1342"><span class="linenos">1342</span></a> -</span><span id="L-1343"><a href="#L-1343"><span class="linenos">1343</span></a> <span class="k">def</span> <span class="nf">introducer_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Introducer</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1344"><a href="#L-1344"><span class="linenos">1344</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-1345"><a href="#L-1345"><span class="linenos">1345</span></a> -</span><span id="L-1346"><a href="#L-1346"><span class="linenos">1346</span></a> <span class="k">def</span> <span class="nf">kill_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Kill</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1347"><a href="#L-1347"><span class="linenos">1347</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-1348"><a href="#L-1348"><span class="linenos">1348</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-1349"><a href="#L-1349"><span class="linenos">1349</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-1350"><a href="#L-1350"><span class="linenos">1350</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-1351"><a href="#L-1351"><span class="linenos">1351</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"KILL</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-1352"><a href="#L-1352"><span class="linenos">1352</span></a> -</span><span id="L-1353"><a href="#L-1353"><span class="linenos">1353</span></a> <span class="k">def</span> <span class="nf">pseudotype_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">PseudoType</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1354"><a href="#L-1354"><span class="linenos">1354</span></a> <span class="k">return</span> <span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> -</span><span id="L-1355"><a href="#L-1355"><span class="linenos">1355</span></a> -</span><span id="L-1356"><a href="#L-1356"><span class="linenos">1356</span></a> <span class="k">def</span> <span class="nf">objectidentifier_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ObjectIdentifier</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1357"><a href="#L-1357"><span class="linenos">1357</span></a> <span class="k">return</span> <span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> -</span><span id="L-1358"><a href="#L-1358"><span class="linenos">1358</span></a> -</span><span id="L-1359"><a href="#L-1359"><span class="linenos">1359</span></a> <span class="k">def</span> <span class="nf">onconflict_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">OnConflict</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1360"><a href="#L-1360"><span class="linenos">1360</span></a> <span class="n">conflict</span> <span class="o">=</span> <span class="s2">"ON DUPLICATE KEY"</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">"duplicate"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">"ON CONFLICT"</span> -</span><span id="L-1361"><a href="#L-1361"><span class="linenos">1361</span></a> <span class="n">constraint</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"constraint"</span><span class="p">)</span> -</span><span id="L-1362"><a href="#L-1362"><span class="linenos">1362</span></a> <span class="k">if</span> <span class="n">constraint</span><span class="p">:</span> -</span><span id="L-1363"><a href="#L-1363"><span class="linenos">1363</span></a> <span class="n">constraint</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"ON CONSTRAINT </span><span class="si">{</span><span class="n">constraint</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1364"><a href="#L-1364"><span class="linenos">1364</span></a> <span class="n">key</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">"key"</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-1365"><a href="#L-1365"><span class="linenos">1365</span></a> <span class="n">do</span> <span class="o">=</span> <span class="s2">""</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">"duplicate"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">" DO "</span> -</span><span id="L-1366"><a href="#L-1366"><span class="linenos">1366</span></a> <span class="n">nothing</span> <span class="o">=</span> <span class="s2">"NOTHING"</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">"nothing"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1367"><a href="#L-1367"><span class="linenos">1367</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-1368"><a href="#L-1368"><span class="linenos">1368</span></a> <span class="n">set_keyword</span> <span class="o">=</span> <span class="s2">"SET "</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">DUPLICATE_KEY_UPDATE_WITH_SET</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1369"><a href="#L-1369"><span class="linenos">1369</span></a> <span class="k">if</span> <span class="n">expressions</span><span class="p">:</span> -</span><span id="L-1370"><a href="#L-1370"><span class="linenos">1370</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"UPDATE </span><span class="si">{</span><span class="n">set_keyword</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1371"><a href="#L-1371"><span class="linenos">1371</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">conflict</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">constraint</span><span class="si">}{</span><span class="n">key</span><span class="si">}{</span><span class="n">do</span><span class="si">}{</span><span class="n">nothing</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1372"><a href="#L-1372"><span class="linenos">1372</span></a> -</span><span id="L-1373"><a href="#L-1373"><span class="linenos">1373</span></a> <span class="k">def</span> <span class="nf">returning_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Returning</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1374"><a href="#L-1374"><span class="linenos">1374</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="s1">'RETURNING'</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">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-1375"><a href="#L-1375"><span class="linenos">1375</span></a> -</span><span id="L-1376"><a href="#L-1376"><span class="linenos">1376</span></a> <span class="k">def</span> <span class="nf">rowformatdelimitedproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RowFormatDelimitedProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1377"><a href="#L-1377"><span class="linenos">1377</span></a> <span class="n">fields</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">"fields"</span><span class="p">)</span> -</span><span id="L-1378"><a href="#L-1378"><span class="linenos">1378</span></a> <span class="n">fields</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" FIELDS TERMINATED BY </span><span class="si">{</span><span class="n">fields</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">fields</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1379"><a href="#L-1379"><span class="linenos">1379</span></a> <span class="n">escaped</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">"escaped"</span><span class="p">)</span> -</span><span id="L-1380"><a href="#L-1380"><span class="linenos">1380</span></a> <span class="n">escaped</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" ESCAPED BY </span><span class="si">{</span><span class="n">escaped</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">escaped</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1381"><a href="#L-1381"><span class="linenos">1381</span></a> <span class="n">items</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">"collection_items"</span><span class="p">)</span> -</span><span id="L-1382"><a href="#L-1382"><span class="linenos">1382</span></a> <span class="n">items</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" COLLECTION ITEMS TERMINATED BY </span><span class="si">{</span><span class="n">items</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">items</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1383"><a href="#L-1383"><span class="linenos">1383</span></a> <span class="n">keys</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">"map_keys"</span><span class="p">)</span> -</span><span id="L-1384"><a href="#L-1384"><span class="linenos">1384</span></a> <span class="n">keys</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" MAP KEYS TERMINATED BY </span><span class="si">{</span><span class="n">keys</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">keys</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1385"><a href="#L-1385"><span class="linenos">1385</span></a> <span class="n">lines</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">"lines"</span><span class="p">)</span> -</span><span id="L-1386"><a href="#L-1386"><span class="linenos">1386</span></a> <span class="n">lines</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" LINES TERMINATED BY </span><span class="si">{</span><span class="n">lines</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">lines</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1387"><a href="#L-1387"><span class="linenos">1387</span></a> <span class="n">null</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">"null"</span><span class="p">)</span> -</span><span id="L-1388"><a href="#L-1388"><span class="linenos">1388</span></a> <span class="n">null</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" NULL DEFINED AS </span><span class="si">{</span><span class="n">null</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">null</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1389"><a href="#L-1389"><span class="linenos">1389</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ROW FORMAT DELIMITED</span><span class="si">{</span><span class="n">fields</span><span class="si">}{</span><span class="n">escaped</span><span class="si">}{</span><span class="n">items</span><span class="si">}{</span><span class="n">keys</span><span class="si">}{</span><span class="n">lines</span><span class="si">}{</span><span class="n">null</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1390"><a href="#L-1390"><span class="linenos">1390</span></a> -</span><span id="L-1391"><a href="#L-1391"><span class="linenos">1391</span></a> <span class="k">def</span> <span class="nf">withtablehint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">WithTableHint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1392"><a href="#L-1392"><span class="linenos">1392</span></a> <span class="k">return</span> <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">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-1393"><a href="#L-1393"><span class="linenos">1393</span></a> -</span><span id="L-1394"><a href="#L-1394"><span class="linenos">1394</span></a> <span class="k">def</span> <span class="nf">indextablehint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">IndexTableHint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1395"><a href="#L-1395"><span class="linenos">1395</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="bp">self</span><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"> INDEX"</span> -</span><span id="L-1396"><a href="#L-1396"><span class="linenos">1396</span></a> <span class="n">target</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"target"</span><span class="p">)</span> -</span><span id="L-1397"><a href="#L-1397"><span class="linenos">1397</span></a> <span class="n">target</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" FOR </span><span class="si">{</span><span class="n">target</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">target</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1398"><a href="#L-1398"><span class="linenos">1398</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">target</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">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-1399"><a href="#L-1399"><span class="linenos">1399</span></a> -</span><span id="L-1400"><a href="#L-1400"><span class="linenos">1400</span></a> <span class="k">def</span> <span class="nf">table_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</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">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">" AS "</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1401"><a href="#L-1401"><span class="linenos">1401</span></a> <span class="n">table</span> <span class="o">=</span> <span class="s2">"."</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> -</span><span id="L-1402"><a href="#L-1402"><span class="linenos">1402</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">part</span><span class="p">)</span> -</span><span id="L-1403"><a href="#L-1403"><span class="linenos">1403</span></a> <span class="k">for</span> <span class="n">part</span> <span class="ow">in</span> <span class="p">(</span> -</span><span id="L-1404"><a href="#L-1404"><span class="linenos">1404</span></a> <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">"catalog"</span><span class="p">),</span> -</span><span id="L-1405"><a href="#L-1405"><span class="linenos">1405</span></a> <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">"db"</span><span class="p">),</span> -</span><span id="L-1406"><a href="#L-1406"><span class="linenos">1406</span></a> <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">"this"</span><span class="p">),</span> -</span><span id="L-1407"><a href="#L-1407"><span class="linenos">1407</span></a> <span class="p">)</span> -</span><span id="L-1408"><a href="#L-1408"><span class="linenos">1408</span></a> <span class="k">if</span> <span class="n">part</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> -</span><span id="L-1409"><a href="#L-1409"><span class="linenos">1409</span></a> <span class="p">)</span> -</span><span id="L-1410"><a href="#L-1410"><span class="linenos">1410</span></a> -</span><span id="L-1411"><a href="#L-1411"><span class="linenos">1411</span></a> <span class="n">version</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"version"</span><span class="p">)</span> -</span><span id="L-1412"><a href="#L-1412"><span class="linenos">1412</span></a> <span class="n">version</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">version</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">version</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1413"><a href="#L-1413"><span class="linenos">1413</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-1414"><a href="#L-1414"><span class="linenos">1414</span></a> <span class="n">alias</span> <span class="o">=</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">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-1415"><a href="#L-1415"><span class="linenos">1415</span></a> <span class="n">hints</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">"hints"</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-1416"><a href="#L-1416"><span class="linenos">1416</span></a> <span class="n">hints</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">hints</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">hints</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">TABLE_HINTS</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1417"><a href="#L-1417"><span class="linenos">1417</span></a> <span class="n">pivots</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">"pivots"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</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-1418"><a href="#L-1418"><span class="linenos">1418</span></a> <span class="n">pivots</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">pivots</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">pivots</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1419"><a href="#L-1419"><span class="linenos">1419</span></a> <span class="n">joins</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">"joins"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</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><span id="L-1420"><a href="#L-1420"><span class="linenos">1420</span></a> <span class="n">laterals</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">"laterals"</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-1421"><a href="#L-1421"><span class="linenos">1421</span></a> -</span><span id="L-1422"><a href="#L-1422"><span class="linenos">1422</span></a> <span class="n">file_format</span> <span class="o">=</span> <span class="bp">self</span><span 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-1423"><a href="#L-1423"><span class="linenos">1423</span></a> <span class="k">if</span> <span class="n">file_format</span><span class="p">:</span> -</span><span id="L-1424"><a href="#L-1424"><span class="linenos">1424</span></a> <span class="n">pattern</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"pattern"</span><span class="p">)</span> -</span><span id="L-1425"><a href="#L-1425"><span class="linenos">1425</span></a> <span class="n">pattern</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">", PATTERN => </span><span class="si">{</span><span class="n">pattern</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">pattern</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1426"><a href="#L-1426"><span class="linenos">1426</span></a> <span class="n">file_format</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" (FILE_FORMAT => </span><span class="si">{</span><span class="n">file_format</span><span class="si">}{</span><span class="n">pattern</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="L-1427"><a href="#L-1427"><span class="linenos">1427</span></a> -</span><span id="L-1428"><a href="#L-1428"><span class="linenos">1428</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span 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"</span><span class="p">)</span> -</span><span id="L-1429"><a href="#L-1429"><span class="linenos">1429</span></a> <span class="n">index</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AT </span><span class="si">{</span><span class="n">index</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">index</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1430"><a href="#L-1430"><span class="linenos">1430</span></a> -</span><span id="L-1431"><a href="#L-1431"><span class="linenos">1431</span></a> <span class="n">ordinality</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">"ordinality"</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">""</span> -</span><span id="L-1432"><a href="#L-1432"><span class="linenos">1432</span></a> <span class="k">if</span> <span class="n">ordinality</span><span class="p">:</span> -</span><span id="L-1433"><a href="#L-1433"><span class="linenos">1433</span></a> <span class="n">ordinality</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" WITH ORDINALITY</span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1434"><a href="#L-1434"><span class="linenos">1434</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="L-1435"><a href="#L-1435"><span class="linenos">1435</span></a> -</span><span id="L-1436"><a href="#L-1436"><span class="linenos">1436</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">table</span><span class="si">}{</span><span class="n">version</span><span class="si">}{</span><span class="n">file_format</span><span class="si">}{</span><span class="n">alias</span><span class="si">}{</span><span class="n">index</span><span class="si">}{</span><span class="n">hints</span><span class="si">}{</span><span class="n">pivots</span><span class="si">}{</span><span class="n">joins</span><span class="si">}{</span><span class="n">laterals</span><span class="si">}{</span><span class="n">ordinality</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1437"><a href="#L-1437"><span class="linenos">1437</span></a> -</span><span id="L-1438"><a href="#L-1438"><span class="linenos">1438</span></a> <span class="k">def</span> <span class="nf">tablesample_sql</span><span class="p">(</span> -</span><span id="L-1439"><a href="#L-1439"><span class="linenos">1439</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TableSample</span><span class="p">,</span> <span class="n">seed_prefix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"SEED"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" AS "</span> -</span><span id="L-1440"><a href="#L-1440"><span class="linenos">1440</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1441"><a href="#L-1441"><span class="linenos">1441</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">ALIAS_POST_TABLESAMPLE</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">alias</span><span class="p">:</span> -</span><span id="L-1442"><a href="#L-1442"><span class="linenos">1442</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 class="o">.</span><span class="n">copy</span><span class="p">()</span> -</span><span id="L-1443"><a href="#L-1443"><span class="linenos">1443</span></a> <span class="n">table</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"alias"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> -</span><span id="L-1444"><a href="#L-1444"><span class="linenos">1444</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-1445"><a href="#L-1445"><span class="linenos">1445</span></a> <span class="n">alias</span> <span class="o">=</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="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="w"> </span><span class="s1">'alias'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1446"><a href="#L-1446"><span class="linenos">1446</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-1447"><a href="#L-1447"><span class="linenos">1447</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-1448"><a href="#L-1448"><span class="linenos">1448</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="L-1449"><a href="#L-1449"><span class="linenos">1449</span></a> -</span><span id="L-1450"><a href="#L-1450"><span class="linenos">1450</span></a> <span class="n">method</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"method"</span><span class="p">)</span> -</span><span id="L-1451"><a href="#L-1451"><span class="linenos">1451</span></a> <span class="n">method</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">method</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">method</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">TABLESAMPLE_WITH_METHOD</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1452"><a href="#L-1452"><span class="linenos">1452</span></a> <span class="n">numerator</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"bucket_numerator"</span><span class="p">)</span> -</span><span id="L-1453"><a href="#L-1453"><span class="linenos">1453</span></a> <span class="n">denominator</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"bucket_denominator"</span><span class="p">)</span> -</span><span id="L-1454"><a href="#L-1454"><span class="linenos">1454</span></a> <span class="n">field</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"bucket_field"</span><span class="p">)</span> -</span><span id="L-1455"><a href="#L-1455"><span class="linenos">1455</span></a> <span class="n">field</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" ON </span><span class="si">{</span><span class="n">field</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">field</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1456"><a href="#L-1456"><span class="linenos">1456</span></a> <span class="n">bucket</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"BUCKET </span><span class="si">{</span><span class="n">numerator</span><span class="si">}</span><span class="s2"> OUT OF </span><span class="si">{</span><span class="n">denominator</span><span class="si">}{</span><span class="n">field</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">numerator</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1457"><a href="#L-1457"><span class="linenos">1457</span></a> <span class="n">percent</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"percent"</span><span class="p">)</span> -</span><span id="L-1458"><a href="#L-1458"><span class="linenos">1458</span></a> <span class="n">percent</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">percent</span><span class="si">}</span><span class="s2"> PERCENT"</span> <span class="k">if</span> <span class="n">percent</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1459"><a href="#L-1459"><span class="linenos">1459</span></a> <span class="n">rows</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"rows"</span><span class="p">)</span> -</span><span id="L-1460"><a href="#L-1460"><span class="linenos">1460</span></a> <span class="n">rows</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">rows</span><span class="si">}</span><span class="s2"> ROWS"</span> <span class="k">if</span> <span class="n">rows</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1461"><a href="#L-1461"><span class="linenos">1461</span></a> -</span><span id="L-1462"><a href="#L-1462"><span class="linenos">1462</span></a> <span class="n">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">"size"</span><span class="p">)</span> -</span><span id="L-1463"><a href="#L-1463"><span class="linenos">1463</span></a> <span class="k">if</span> <span class="n">size</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">TABLESAMPLE_SIZE_IS_PERCENT</span><span class="p">:</span> -</span><span id="L-1464"><a href="#L-1464"><span class="linenos">1464</span></a> <span class="n">size</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">size</span><span class="si">}</span><span class="s2"> PERCENT"</span> -</span><span id="L-1465"><a href="#L-1465"><span class="linenos">1465</span></a> -</span><span id="L-1466"><a href="#L-1466"><span class="linenos">1466</span></a> <span class="n">seed</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"seed"</span><span class="p">)</span> -</span><span id="L-1467"><a href="#L-1467"><span class="linenos">1467</span></a> <span class="n">seed</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">seed_prefix</span><span class="si">}</span><span class="s2"> (</span><span class="si">{</span><span class="n">seed</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">seed</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1468"><a href="#L-1468"><span class="linenos">1468</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="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">,</span> <span class="s2">"TABLESAMPLE"</span><span class="p">)</span> -</span><span id="L-1469"><a href="#L-1469"><span class="linenos">1469</span></a> -</span><span id="L-1470"><a href="#L-1470"><span class="linenos">1470</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">bucket</span><span class="si">}{</span><span class="n">percent</span><span class="si">}{</span><span class="n">rows</span><span class="si">}{</span><span class="n">size</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1471"><a href="#L-1471"><span class="linenos">1471</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">TABLESAMPLE_REQUIRES_PARENS</span><span class="p">:</span> -</span><span id="L-1472"><a href="#L-1472"><span class="linenos">1472</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">expr</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="L-1473"><a href="#L-1473"><span class="linenos">1473</span></a> -</span><span id="L-1474"><a href="#L-1474"><span class="linenos">1474</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="s2"> </span><span class="si">{</span><span class="n">method</span><span class="si">}{</span><span class="n">expr</span><span class="si">}{</span><span class="n">seed</span><span class="si">}{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1475"><a href="#L-1475"><span class="linenos">1475</span></a> -</span><span id="L-1476"><a href="#L-1476"><span class="linenos">1476</span></a> <span class="k">def</span> <span class="nf">pivot_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Pivot</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1477"><a href="#L-1477"><span class="linenos">1477</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-1326"><a href="#L-1326"><span class="linenos">1326</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"INSERT</span><span class="si">{</span><span class="n">alternative</span><span class="si">}{</span><span class="n">ignore</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="n">by_name</span><span class="si">}{</span><span class="n">exists</span><span class="si">}{</span><span class="n">partition_sql</span><span class="si">}{</span><span class="n">where</span><span class="si">}{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1327"><a href="#L-1327"><span class="linenos">1327</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-1328"><a href="#L-1328"><span class="linenos">1328</span></a> +</span><span id="L-1329"><a href="#L-1329"><span class="linenos">1329</span></a> <span class="k">def</span> <span class="nf">intersect_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Intersect</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1330"><a href="#L-1330"><span class="linenos">1330</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><span id="L-1331"><a href="#L-1331"><span class="linenos">1331</span></a> <span class="n">expression</span><span class="p">,</span> +</span><span id="L-1332"><a href="#L-1332"><span class="linenos">1332</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">set_operation</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">intersect_op</span><span class="p">(</span><span class="n">expression</span><span class="p">)),</span> +</span><span id="L-1333"><a href="#L-1333"><span class="linenos">1333</span></a> <span class="p">)</span> +</span><span id="L-1334"><a href="#L-1334"><span class="linenos">1334</span></a> +</span><span id="L-1335"><a href="#L-1335"><span class="linenos">1335</span></a> <span class="k">def</span> <span class="nf">intersect_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Intersect</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1336"><a href="#L-1336"><span class="linenos">1336</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"INTERSECT</span><span class="si">{</span><span class="s1">''</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">'distinct'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">' ALL'</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1337"><a href="#L-1337"><span class="linenos">1337</span></a> +</span><span id="L-1338"><a href="#L-1338"><span class="linenos">1338</span></a> <span class="k">def</span> <span class="nf">introducer_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Introducer</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1339"><a href="#L-1339"><span class="linenos">1339</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-1340"><a href="#L-1340"><span class="linenos">1340</span></a> +</span><span id="L-1341"><a href="#L-1341"><span class="linenos">1341</span></a> <span class="k">def</span> <span class="nf">kill_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Kill</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1342"><a href="#L-1342"><span class="linenos">1342</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-1343"><a href="#L-1343"><span class="linenos">1343</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-1344"><a href="#L-1344"><span class="linenos">1344</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-1345"><a href="#L-1345"><span class="linenos">1345</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-1346"><a href="#L-1346"><span class="linenos">1346</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"KILL</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-1347"><a href="#L-1347"><span class="linenos">1347</span></a> +</span><span id="L-1348"><a href="#L-1348"><span class="linenos">1348</span></a> <span class="k">def</span> <span class="nf">pseudotype_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">PseudoType</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1349"><a href="#L-1349"><span class="linenos">1349</span></a> <span class="k">return</span> <span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> +</span><span id="L-1350"><a href="#L-1350"><span class="linenos">1350</span></a> +</span><span id="L-1351"><a href="#L-1351"><span class="linenos">1351</span></a> <span class="k">def</span> <span class="nf">objectidentifier_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ObjectIdentifier</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1352"><a href="#L-1352"><span class="linenos">1352</span></a> <span class="k">return</span> <span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> +</span><span id="L-1353"><a href="#L-1353"><span class="linenos">1353</span></a> +</span><span id="L-1354"><a href="#L-1354"><span class="linenos">1354</span></a> <span class="k">def</span> <span class="nf">onconflict_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">OnConflict</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1355"><a href="#L-1355"><span class="linenos">1355</span></a> <span class="n">conflict</span> <span class="o">=</span> <span class="s2">"ON DUPLICATE KEY"</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">"duplicate"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">"ON CONFLICT"</span> +</span><span id="L-1356"><a href="#L-1356"><span class="linenos">1356</span></a> <span class="n">constraint</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"constraint"</span><span class="p">)</span> +</span><span id="L-1357"><a href="#L-1357"><span class="linenos">1357</span></a> <span class="k">if</span> <span class="n">constraint</span><span class="p">:</span> +</span><span id="L-1358"><a href="#L-1358"><span class="linenos">1358</span></a> <span class="n">constraint</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"ON CONSTRAINT </span><span class="si">{</span><span class="n">constraint</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1359"><a href="#L-1359"><span class="linenos">1359</span></a> <span class="n">key</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">"key"</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-1360"><a href="#L-1360"><span class="linenos">1360</span></a> <span class="n">do</span> <span class="o">=</span> <span class="s2">""</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">"duplicate"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">" DO "</span> +</span><span id="L-1361"><a href="#L-1361"><span class="linenos">1361</span></a> <span class="n">nothing</span> <span class="o">=</span> <span class="s2">"NOTHING"</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">"nothing"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1362"><a href="#L-1362"><span class="linenos">1362</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-1363"><a href="#L-1363"><span class="linenos">1363</span></a> <span class="n">set_keyword</span> <span class="o">=</span> <span class="s2">"SET "</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">DUPLICATE_KEY_UPDATE_WITH_SET</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1364"><a href="#L-1364"><span class="linenos">1364</span></a> <span class="k">if</span> <span class="n">expressions</span><span class="p">:</span> +</span><span id="L-1365"><a href="#L-1365"><span class="linenos">1365</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"UPDATE </span><span class="si">{</span><span class="n">set_keyword</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1366"><a href="#L-1366"><span class="linenos">1366</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">conflict</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">constraint</span><span class="si">}{</span><span class="n">key</span><span class="si">}{</span><span class="n">do</span><span class="si">}{</span><span class="n">nothing</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1367"><a href="#L-1367"><span class="linenos">1367</span></a> +</span><span id="L-1368"><a href="#L-1368"><span class="linenos">1368</span></a> <span class="k">def</span> <span class="nf">returning_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Returning</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1369"><a href="#L-1369"><span class="linenos">1369</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="s1">'RETURNING'</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">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-1370"><a href="#L-1370"><span class="linenos">1370</span></a> +</span><span id="L-1371"><a href="#L-1371"><span class="linenos">1371</span></a> <span class="k">def</span> <span class="nf">rowformatdelimitedproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RowFormatDelimitedProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1372"><a href="#L-1372"><span class="linenos">1372</span></a> <span class="n">fields</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">"fields"</span><span class="p">)</span> +</span><span id="L-1373"><a href="#L-1373"><span class="linenos">1373</span></a> <span class="n">fields</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" FIELDS TERMINATED BY </span><span class="si">{</span><span class="n">fields</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">fields</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1374"><a href="#L-1374"><span class="linenos">1374</span></a> <span class="n">escaped</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">"escaped"</span><span class="p">)</span> +</span><span id="L-1375"><a href="#L-1375"><span class="linenos">1375</span></a> <span class="n">escaped</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" ESCAPED BY </span><span class="si">{</span><span class="n">escaped</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">escaped</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1376"><a href="#L-1376"><span class="linenos">1376</span></a> <span class="n">items</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">"collection_items"</span><span class="p">)</span> +</span><span id="L-1377"><a href="#L-1377"><span class="linenos">1377</span></a> <span class="n">items</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" COLLECTION ITEMS TERMINATED BY </span><span class="si">{</span><span class="n">items</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">items</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1378"><a href="#L-1378"><span class="linenos">1378</span></a> <span class="n">keys</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">"map_keys"</span><span class="p">)</span> +</span><span id="L-1379"><a href="#L-1379"><span class="linenos">1379</span></a> <span class="n">keys</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" MAP KEYS TERMINATED BY </span><span class="si">{</span><span class="n">keys</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">keys</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1380"><a href="#L-1380"><span class="linenos">1380</span></a> <span class="n">lines</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">"lines"</span><span class="p">)</span> +</span><span id="L-1381"><a href="#L-1381"><span class="linenos">1381</span></a> <span class="n">lines</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" LINES TERMINATED BY </span><span class="si">{</span><span class="n">lines</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">lines</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1382"><a href="#L-1382"><span class="linenos">1382</span></a> <span class="n">null</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">"null"</span><span class="p">)</span> +</span><span id="L-1383"><a href="#L-1383"><span class="linenos">1383</span></a> <span class="n">null</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" NULL DEFINED AS </span><span class="si">{</span><span class="n">null</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">null</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1384"><a href="#L-1384"><span class="linenos">1384</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ROW FORMAT DELIMITED</span><span class="si">{</span><span class="n">fields</span><span class="si">}{</span><span class="n">escaped</span><span class="si">}{</span><span class="n">items</span><span class="si">}{</span><span class="n">keys</span><span class="si">}{</span><span class="n">lines</span><span class="si">}{</span><span class="n">null</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1385"><a href="#L-1385"><span class="linenos">1385</span></a> +</span><span id="L-1386"><a href="#L-1386"><span class="linenos">1386</span></a> <span class="k">def</span> <span class="nf">withtablehint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">WithTableHint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1387"><a href="#L-1387"><span class="linenos">1387</span></a> <span class="k">return</span> <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">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-1388"><a href="#L-1388"><span class="linenos">1388</span></a> +</span><span id="L-1389"><a href="#L-1389"><span class="linenos">1389</span></a> <span class="k">def</span> <span class="nf">indextablehint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">IndexTableHint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1390"><a href="#L-1390"><span class="linenos">1390</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="bp">self</span><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"> INDEX"</span> +</span><span id="L-1391"><a href="#L-1391"><span class="linenos">1391</span></a> <span class="n">target</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"target"</span><span class="p">)</span> +</span><span id="L-1392"><a href="#L-1392"><span class="linenos">1392</span></a> <span class="n">target</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" FOR </span><span class="si">{</span><span class="n">target</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">target</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1393"><a href="#L-1393"><span class="linenos">1393</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">target</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">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-1394"><a href="#L-1394"><span class="linenos">1394</span></a> +</span><span id="L-1395"><a href="#L-1395"><span class="linenos">1395</span></a> <span class="k">def</span> <span class="nf">historicaldata_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">HistoricalData</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1396"><a href="#L-1396"><span class="linenos">1396</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-1397"><a href="#L-1397"><span class="linenos">1397</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-1398"><a href="#L-1398"><span class="linenos">1398</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-1399"><a href="#L-1399"><span class="linenos">1399</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="s2"> => </span><span class="si">{</span><span class="n">expr</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="L-1400"><a href="#L-1400"><span class="linenos">1400</span></a> +</span><span id="L-1401"><a href="#L-1401"><span class="linenos">1401</span></a> <span class="k">def</span> <span class="nf">table_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</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">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">" AS "</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1402"><a href="#L-1402"><span class="linenos">1402</span></a> <span class="n">table</span> <span class="o">=</span> <span class="s2">"."</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> +</span><span id="L-1403"><a href="#L-1403"><span class="linenos">1403</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">part</span><span class="p">)</span> +</span><span id="L-1404"><a href="#L-1404"><span class="linenos">1404</span></a> <span class="k">for</span> <span class="n">part</span> <span class="ow">in</span> <span class="p">(</span> +</span><span id="L-1405"><a href="#L-1405"><span class="linenos">1405</span></a> <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">"catalog"</span><span class="p">),</span> +</span><span id="L-1406"><a href="#L-1406"><span class="linenos">1406</span></a> <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">"db"</span><span class="p">),</span> +</span><span id="L-1407"><a href="#L-1407"><span class="linenos">1407</span></a> <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">"this"</span><span class="p">),</span> +</span><span id="L-1408"><a href="#L-1408"><span class="linenos">1408</span></a> <span class="p">)</span> +</span><span id="L-1409"><a href="#L-1409"><span class="linenos">1409</span></a> <span class="k">if</span> <span class="n">part</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> +</span><span id="L-1410"><a href="#L-1410"><span class="linenos">1410</span></a> <span class="p">)</span> +</span><span id="L-1411"><a href="#L-1411"><span class="linenos">1411</span></a> +</span><span id="L-1412"><a href="#L-1412"><span class="linenos">1412</span></a> <span class="n">version</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"version"</span><span class="p">)</span> +</span><span id="L-1413"><a href="#L-1413"><span class="linenos">1413</span></a> <span class="n">version</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">version</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">version</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1414"><a href="#L-1414"><span class="linenos">1414</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-1415"><a href="#L-1415"><span class="linenos">1415</span></a> <span class="n">alias</span> <span class="o">=</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">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-1416"><a href="#L-1416"><span class="linenos">1416</span></a> <span class="n">hints</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">"hints"</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-1417"><a href="#L-1417"><span class="linenos">1417</span></a> <span class="n">hints</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">hints</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">hints</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">TABLE_HINTS</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1418"><a href="#L-1418"><span class="linenos">1418</span></a> <span class="n">pivots</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">"pivots"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</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-1419"><a href="#L-1419"><span class="linenos">1419</span></a> <span class="n">pivots</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">pivots</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">pivots</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1420"><a href="#L-1420"><span class="linenos">1420</span></a> <span class="n">joins</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">"joins"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</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><span id="L-1421"><a href="#L-1421"><span class="linenos">1421</span></a> <span class="n">laterals</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">"laterals"</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-1422"><a href="#L-1422"><span class="linenos">1422</span></a> +</span><span id="L-1423"><a href="#L-1423"><span class="linenos">1423</span></a> <span class="n">file_format</span> <span class="o">=</span> <span class="bp">self</span><span 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-1424"><a href="#L-1424"><span class="linenos">1424</span></a> <span class="k">if</span> <span class="n">file_format</span><span class="p">:</span> +</span><span id="L-1425"><a href="#L-1425"><span class="linenos">1425</span></a> <span class="n">pattern</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"pattern"</span><span class="p">)</span> +</span><span id="L-1426"><a href="#L-1426"><span class="linenos">1426</span></a> <span class="n">pattern</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">", PATTERN => </span><span class="si">{</span><span class="n">pattern</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">pattern</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1427"><a href="#L-1427"><span class="linenos">1427</span></a> <span class="n">file_format</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" (FILE_FORMAT => </span><span class="si">{</span><span class="n">file_format</span><span class="si">}{</span><span class="n">pattern</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="L-1428"><a href="#L-1428"><span class="linenos">1428</span></a> +</span><span id="L-1429"><a href="#L-1429"><span class="linenos">1429</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span 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"</span><span class="p">)</span> +</span><span id="L-1430"><a href="#L-1430"><span class="linenos">1430</span></a> <span class="n">index</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AT </span><span class="si">{</span><span class="n">index</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">index</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1431"><a href="#L-1431"><span class="linenos">1431</span></a> +</span><span id="L-1432"><a href="#L-1432"><span class="linenos">1432</span></a> <span class="n">ordinality</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">"ordinality"</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">""</span> +</span><span id="L-1433"><a href="#L-1433"><span class="linenos">1433</span></a> <span class="k">if</span> <span class="n">ordinality</span><span class="p">:</span> +</span><span id="L-1434"><a href="#L-1434"><span class="linenos">1434</span></a> <span class="n">ordinality</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" WITH ORDINALITY</span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1435"><a href="#L-1435"><span class="linenos">1435</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="L-1436"><a href="#L-1436"><span class="linenos">1436</span></a> +</span><span id="L-1437"><a href="#L-1437"><span class="linenos">1437</span></a> <span class="n">when</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"when"</span><span class="p">)</span> +</span><span id="L-1438"><a href="#L-1438"><span class="linenos">1438</span></a> <span class="k">if</span> <span class="n">when</span><span class="p">:</span> +</span><span id="L-1439"><a href="#L-1439"><span class="linenos">1439</span></a> <span class="n">table</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">table</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">when</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1440"><a href="#L-1440"><span class="linenos">1440</span></a> +</span><span id="L-1441"><a href="#L-1441"><span class="linenos">1441</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">table</span><span class="si">}{</span><span class="n">version</span><span class="si">}{</span><span class="n">file_format</span><span class="si">}{</span><span class="n">alias</span><span class="si">}{</span><span class="n">index</span><span class="si">}{</span><span class="n">hints</span><span class="si">}{</span><span class="n">pivots</span><span class="si">}{</span><span class="n">joins</span><span class="si">}{</span><span class="n">laterals</span><span class="si">}{</span><span class="n">ordinality</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1442"><a href="#L-1442"><span class="linenos">1442</span></a> +</span><span id="L-1443"><a href="#L-1443"><span class="linenos">1443</span></a> <span class="k">def</span> <span class="nf">tablesample_sql</span><span class="p">(</span> +</span><span id="L-1444"><a href="#L-1444"><span class="linenos">1444</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TableSample</span><span class="p">,</span> <span class="n">seed_prefix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"SEED"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" AS "</span> +</span><span id="L-1445"><a href="#L-1445"><span class="linenos">1445</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1446"><a href="#L-1446"><span class="linenos">1446</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">ALIAS_POST_TABLESAMPLE</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">alias</span><span class="p">:</span> +</span><span id="L-1447"><a href="#L-1447"><span class="linenos">1447</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 class="o">.</span><span class="n">copy</span><span class="p">()</span> +</span><span id="L-1448"><a href="#L-1448"><span class="linenos">1448</span></a> <span class="n">table</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"alias"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> +</span><span id="L-1449"><a href="#L-1449"><span class="linenos">1449</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-1450"><a href="#L-1450"><span class="linenos">1450</span></a> <span class="n">alias</span> <span class="o">=</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="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="w"> </span><span class="s1">'alias'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1451"><a href="#L-1451"><span class="linenos">1451</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-1452"><a href="#L-1452"><span class="linenos">1452</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-1453"><a href="#L-1453"><span class="linenos">1453</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="L-1454"><a href="#L-1454"><span class="linenos">1454</span></a> +</span><span id="L-1455"><a href="#L-1455"><span class="linenos">1455</span></a> <span class="n">method</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"method"</span><span class="p">)</span> +</span><span id="L-1456"><a href="#L-1456"><span class="linenos">1456</span></a> <span class="n">method</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">method</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">method</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">TABLESAMPLE_WITH_METHOD</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1457"><a href="#L-1457"><span class="linenos">1457</span></a> <span class="n">numerator</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"bucket_numerator"</span><span class="p">)</span> +</span><span id="L-1458"><a href="#L-1458"><span class="linenos">1458</span></a> <span class="n">denominator</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"bucket_denominator"</span><span class="p">)</span> +</span><span id="L-1459"><a href="#L-1459"><span class="linenos">1459</span></a> <span class="n">field</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"bucket_field"</span><span class="p">)</span> +</span><span id="L-1460"><a href="#L-1460"><span class="linenos">1460</span></a> <span class="n">field</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" ON </span><span class="si">{</span><span class="n">field</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">field</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1461"><a href="#L-1461"><span class="linenos">1461</span></a> <span class="n">bucket</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"BUCKET </span><span class="si">{</span><span class="n">numerator</span><span class="si">}</span><span class="s2"> OUT OF </span><span class="si">{</span><span class="n">denominator</span><span class="si">}{</span><span class="n">field</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">numerator</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1462"><a href="#L-1462"><span class="linenos">1462</span></a> <span class="n">percent</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"percent"</span><span class="p">)</span> +</span><span id="L-1463"><a href="#L-1463"><span class="linenos">1463</span></a> <span class="n">percent</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">percent</span><span class="si">}</span><span class="s2"> PERCENT"</span> <span class="k">if</span> <span class="n">percent</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1464"><a href="#L-1464"><span class="linenos">1464</span></a> <span class="n">rows</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"rows"</span><span class="p">)</span> +</span><span id="L-1465"><a href="#L-1465"><span class="linenos">1465</span></a> <span class="n">rows</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">rows</span><span class="si">}</span><span class="s2"> ROWS"</span> <span class="k">if</span> <span class="n">rows</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1466"><a href="#L-1466"><span class="linenos">1466</span></a> +</span><span id="L-1467"><a href="#L-1467"><span class="linenos">1467</span></a> <span class="n">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">"size"</span><span class="p">)</span> +</span><span id="L-1468"><a href="#L-1468"><span class="linenos">1468</span></a> <span class="k">if</span> <span class="n">size</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">TABLESAMPLE_SIZE_IS_PERCENT</span><span class="p">:</span> +</span><span id="L-1469"><a href="#L-1469"><span class="linenos">1469</span></a> <span class="n">size</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">size</span><span class="si">}</span><span class="s2"> PERCENT"</span> +</span><span id="L-1470"><a href="#L-1470"><span class="linenos">1470</span></a> +</span><span id="L-1471"><a href="#L-1471"><span class="linenos">1471</span></a> <span class="n">seed</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"seed"</span><span class="p">)</span> +</span><span id="L-1472"><a href="#L-1472"><span class="linenos">1472</span></a> <span class="n">seed</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">seed_prefix</span><span class="si">}</span><span class="s2"> (</span><span class="si">{</span><span class="n">seed</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">seed</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1473"><a href="#L-1473"><span class="linenos">1473</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="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">,</span> <span class="s2">"TABLESAMPLE"</span><span class="p">)</span> +</span><span id="L-1474"><a href="#L-1474"><span class="linenos">1474</span></a> +</span><span id="L-1475"><a href="#L-1475"><span class="linenos">1475</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">bucket</span><span class="si">}{</span><span class="n">percent</span><span class="si">}{</span><span class="n">rows</span><span class="si">}{</span><span class="n">size</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1476"><a href="#L-1476"><span class="linenos">1476</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">TABLESAMPLE_REQUIRES_PARENS</span><span class="p">:</span> +</span><span id="L-1477"><a href="#L-1477"><span class="linenos">1477</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">expr</span><span class="si">}</span><span class="s2">)"</span> </span><span id="L-1478"><a href="#L-1478"><span class="linenos">1478</span></a> -</span><span id="L-1479"><a href="#L-1479"><span class="linenos">1479</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">:</span> -</span><span id="L-1480"><a href="#L-1480"><span class="linenos">1480</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-1481"><a href="#L-1481"><span class="linenos">1481</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-1482"><a href="#L-1482"><span class="linenos">1482</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"UNPIVOT </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1479"><a href="#L-1479"><span class="linenos">1479</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="s2"> </span><span class="si">{</span><span class="n">method</span><span class="si">}{</span><span class="n">expr</span><span class="si">}{</span><span class="n">seed</span><span class="si">}{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1480"><a href="#L-1480"><span class="linenos">1480</span></a> +</span><span id="L-1481"><a href="#L-1481"><span class="linenos">1481</span></a> <span class="k">def</span> <span class="nf">pivot_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Pivot</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1482"><a href="#L-1482"><span class="linenos">1482</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-1483"><a href="#L-1483"><span class="linenos">1483</span></a> -</span><span id="L-1484"><a href="#L-1484"><span class="linenos">1484</span></a> <span class="n">on</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">seg</span><span class="p">(</span><span class="s1">'ON'</span><span class="p">)</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-1485"><a href="#L-1485"><span class="linenos">1485</span></a> <span class="n">using</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">"using"</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-1486"><a href="#L-1486"><span class="linenos">1486</span></a> <span class="n">using</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">seg</span><span class="p">(</span><span class="s1">'USING'</span><span class="p">)</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="k">if</span> <span class="n">using</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1487"><a href="#L-1487"><span class="linenos">1487</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-1488"><a href="#L-1488"><span class="linenos">1488</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PIVOT </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="n">using</span><span class="si">}{</span><span class="n">group</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1489"><a href="#L-1489"><span class="linenos">1489</span></a> -</span><span id="L-1490"><a href="#L-1490"><span class="linenos">1490</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-1491"><a href="#L-1491"><span class="linenos">1491</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-1492"><a href="#L-1492"><span class="linenos">1492</span></a> <span class="n">unpivot</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">"unpivot"</span><span class="p">)</span> -</span><span id="L-1493"><a href="#L-1493"><span class="linenos">1493</span></a> <span class="n">direction</span> <span class="o">=</span> <span class="s2">"UNPIVOT"</span> <span class="k">if</span> <span class="n">unpivot</span> <span class="k">else</span> <span class="s2">"PIVOT"</span> -</span><span id="L-1494"><a href="#L-1494"><span class="linenos">1494</span></a> <span class="n">field</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"field"</span><span class="p">)</span> -</span><span id="L-1495"><a href="#L-1495"><span class="linenos">1495</span></a> <span class="n">include_nulls</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">"include_nulls"</span><span class="p">)</span> -</span><span id="L-1496"><a href="#L-1496"><span class="linenos">1496</span></a> <span class="k">if</span> <span class="n">include_nulls</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="L-1497"><a href="#L-1497"><span class="linenos">1497</span></a> <span class="n">nulls</span> <span class="o">=</span> <span class="s2">" INCLUDE NULLS "</span> <span class="k">if</span> <span class="n">include_nulls</span> <span class="k">else</span> <span class="s2">" EXCLUDE NULLS "</span> -</span><span id="L-1498"><a href="#L-1498"><span class="linenos">1498</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-1499"><a href="#L-1499"><span class="linenos">1499</span></a> <span class="n">nulls</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="L-1500"><a href="#L-1500"><span class="linenos">1500</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">direction</span><span class="si">}{</span><span class="n">nulls</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"> FOR </span><span class="si">{</span><span class="n">field</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1501"><a href="#L-1501"><span class="linenos">1501</span></a> -</span><span id="L-1502"><a href="#L-1502"><span class="linenos">1502</span></a> <span class="k">def</span> <span class="nf">version_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Version</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1503"><a href="#L-1503"><span class="linenos">1503</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"FOR </span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1504"><a href="#L-1504"><span class="linenos">1504</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">)</span> -</span><span id="L-1505"><a href="#L-1505"><span class="linenos">1505</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-1506"><a href="#L-1506"><span class="linenos">1506</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="s2"> </span><span class="si">{</span><span class="n">expr</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1507"><a href="#L-1507"><span class="linenos">1507</span></a> -</span><span id="L-1508"><a href="#L-1508"><span class="linenos">1508</span></a> <span class="k">def</span> <span class="nf">tuple_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Tuple</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1509"><a href="#L-1509"><span class="linenos">1509</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">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-1510"><a href="#L-1510"><span class="linenos">1510</span></a> -</span><span id="L-1511"><a href="#L-1511"><span class="linenos">1511</span></a> <span class="k">def</span> <span class="nf">update_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">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 class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1512"><a href="#L-1512"><span class="linenos">1512</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-1513"><a href="#L-1513"><span class="linenos">1513</span></a> <span class="n">set_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="kc">True</span><span class="p">)</span> -</span><span id="L-1514"><a href="#L-1514"><span class="linenos">1514</span></a> <span class="n">from_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">"from"</span><span class="p">)</span> -</span><span id="L-1515"><a href="#L-1515"><span class="linenos">1515</span></a> <span class="n">where_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">"where"</span><span class="p">)</span> -</span><span id="L-1516"><a href="#L-1516"><span class="linenos">1516</span></a> <span class="n">returning</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"returning"</span><span class="p">)</span> -</span><span id="L-1517"><a href="#L-1517"><span class="linenos">1517</span></a> <span class="n">order</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"order"</span><span class="p">)</span> -</span><span id="L-1518"><a href="#L-1518"><span class="linenos">1518</span></a> <span class="n">limit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"limit"</span><span class="p">)</span> -</span><span id="L-1519"><a href="#L-1519"><span class="linenos">1519</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">RETURNING_END</span><span class="p">:</span> -</span><span id="L-1520"><a href="#L-1520"><span class="linenos">1520</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">from_sql</span><span class="si">}{</span><span class="n">where_sql</span><span class="si">}{</span><span class="n">returning</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1521"><a href="#L-1521"><span class="linenos">1521</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-1522"><a href="#L-1522"><span class="linenos">1522</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">returning</span><span class="si">}{</span><span class="n">from_sql</span><span class="si">}{</span><span class="n">where_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1523"><a href="#L-1523"><span class="linenos">1523</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"UPDATE </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> SET </span><span class="si">{</span><span class="n">set_sql</span><span class="si">}{</span><span class="n">expression_sql</span><span class="si">}{</span><span class="n">order</span><span class="si">}{</span><span class="n">limit</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1524"><a href="#L-1524"><span class="linenos">1524</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-1525"><a href="#L-1525"><span class="linenos">1525</span></a> -</span><span id="L-1526"><a href="#L-1526"><span class="linenos">1526</span></a> <span class="k">def</span> <span class="nf">values_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Values</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1527"><a href="#L-1527"><span class="linenos">1527</span></a> <span class="c1"># The VALUES clause is still valid in an `INSERT INTO ..` statement, for example</span> -</span><span id="L-1528"><a href="#L-1528"><span class="linenos">1528</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">VALUES_AS_TABLE</span> <span class="ow">or</span> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">find_ancestor</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">From</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Join</span><span class="p">):</span> -</span><span id="L-1529"><a href="#L-1529"><span class="linenos">1529</span></a> <span class="n">args</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-1530"><a href="#L-1530"><span class="linenos">1530</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-1531"><a href="#L-1531"><span class="linenos">1531</span></a> <span class="n">values</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">seg</span><span class="p">(</span><span class="s1">''</span><span class="p">)</span><span class="si">}{</span><span class="n">args</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1532"><a href="#L-1532"><span class="linenos">1532</span></a> <span class="n">values</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="L-1533"><a href="#L-1533"><span class="linenos">1533</span></a> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">values</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="L-1534"><a href="#L-1534"><span class="linenos">1534</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">WRAP_DERIVED_VALUES</span> <span class="ow">and</span> <span class="p">(</span><span class="n">alias</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">From</span><span class="p">))</span> -</span><span id="L-1535"><a href="#L-1535"><span class="linenos">1535</span></a> <span class="k">else</span> <span class="n">values</span> -</span><span id="L-1536"><a href="#L-1536"><span class="linenos">1536</span></a> <span class="p">)</span> -</span><span id="L-1537"><a href="#L-1537"><span class="linenos">1537</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">values</span><span class="si">}</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="n">values</span> -</span><span id="L-1538"><a href="#L-1538"><span class="linenos">1538</span></a> -</span><span id="L-1539"><a href="#L-1539"><span class="linenos">1539</span></a> <span class="c1"># Converts `VALUES...` expression into a series of select unions.</span> -</span><span id="L-1540"><a href="#L-1540"><span class="linenos">1540</span></a> <span class="n">alias_node</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">"alias"</span><span class="p">)</span> -</span><span id="L-1541"><a href="#L-1541"><span class="linenos">1541</span></a> <span class="n">column_names</span> <span class="o">=</span> <span class="n">alias_node</span> <span class="ow">and</span> <span class="n">alias_node</span><span class="o">.</span><span class="n">columns</span> -</span><span id="L-1542"><a href="#L-1542"><span class="linenos">1542</span></a> -</span><span id="L-1543"><a href="#L-1543"><span class="linenos">1543</span></a> <span class="n">selects</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Subqueryable</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="L-1544"><a href="#L-1544"><span class="linenos">1544</span></a> -</span><span id="L-1545"><a href="#L-1545"><span class="linenos">1545</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">tup</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">expressions</span><span class="p">):</span> -</span><span id="L-1546"><a href="#L-1546"><span class="linenos">1546</span></a> <span class="n">row</span> <span class="o">=</span> <span class="n">tup</span><span class="o">.</span><span class="n">expressions</span> +</span><span id="L-1484"><a href="#L-1484"><span class="linenos">1484</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">:</span> +</span><span id="L-1485"><a href="#L-1485"><span class="linenos">1485</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-1486"><a href="#L-1486"><span class="linenos">1486</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-1487"><a href="#L-1487"><span class="linenos">1487</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"UNPIVOT </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1488"><a href="#L-1488"><span class="linenos">1488</span></a> +</span><span id="L-1489"><a href="#L-1489"><span class="linenos">1489</span></a> <span class="n">on</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">seg</span><span class="p">(</span><span class="s1">'ON'</span><span class="p">)</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-1490"><a href="#L-1490"><span class="linenos">1490</span></a> <span class="n">using</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">"using"</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-1491"><a href="#L-1491"><span class="linenos">1491</span></a> <span class="n">using</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">seg</span><span class="p">(</span><span class="s1">'USING'</span><span class="p">)</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="k">if</span> <span class="n">using</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1492"><a href="#L-1492"><span class="linenos">1492</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-1493"><a href="#L-1493"><span class="linenos">1493</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PIVOT </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="n">using</span><span class="si">}{</span><span class="n">group</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1494"><a href="#L-1494"><span class="linenos">1494</span></a> +</span><span id="L-1495"><a href="#L-1495"><span class="linenos">1495</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-1496"><a href="#L-1496"><span class="linenos">1496</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-1497"><a href="#L-1497"><span class="linenos">1497</span></a> <span class="n">unpivot</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">"unpivot"</span><span class="p">)</span> +</span><span id="L-1498"><a href="#L-1498"><span class="linenos">1498</span></a> <span class="n">direction</span> <span class="o">=</span> <span class="s2">"UNPIVOT"</span> <span class="k">if</span> <span class="n">unpivot</span> <span class="k">else</span> <span class="s2">"PIVOT"</span> +</span><span id="L-1499"><a href="#L-1499"><span class="linenos">1499</span></a> <span class="n">field</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"field"</span><span class="p">)</span> +</span><span id="L-1500"><a href="#L-1500"><span class="linenos">1500</span></a> <span class="n">include_nulls</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">"include_nulls"</span><span class="p">)</span> +</span><span id="L-1501"><a href="#L-1501"><span class="linenos">1501</span></a> <span class="k">if</span> <span class="n">include_nulls</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-1502"><a href="#L-1502"><span class="linenos">1502</span></a> <span class="n">nulls</span> <span class="o">=</span> <span class="s2">" INCLUDE NULLS "</span> <span class="k">if</span> <span class="n">include_nulls</span> <span class="k">else</span> <span class="s2">" EXCLUDE NULLS "</span> +</span><span id="L-1503"><a href="#L-1503"><span class="linenos">1503</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-1504"><a href="#L-1504"><span class="linenos">1504</span></a> <span class="n">nulls</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="L-1505"><a href="#L-1505"><span class="linenos">1505</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">direction</span><span class="si">}{</span><span class="n">nulls</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"> FOR </span><span class="si">{</span><span class="n">field</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1506"><a href="#L-1506"><span class="linenos">1506</span></a> +</span><span id="L-1507"><a href="#L-1507"><span class="linenos">1507</span></a> <span class="k">def</span> <span class="nf">version_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Version</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1508"><a href="#L-1508"><span class="linenos">1508</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"FOR </span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1509"><a href="#L-1509"><span class="linenos">1509</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">)</span> +</span><span id="L-1510"><a href="#L-1510"><span class="linenos">1510</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-1511"><a href="#L-1511"><span class="linenos">1511</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="s2"> </span><span class="si">{</span><span class="n">expr</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1512"><a href="#L-1512"><span class="linenos">1512</span></a> +</span><span id="L-1513"><a href="#L-1513"><span class="linenos">1513</span></a> <span class="k">def</span> <span class="nf">tuple_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Tuple</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1514"><a href="#L-1514"><span class="linenos">1514</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">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-1515"><a href="#L-1515"><span class="linenos">1515</span></a> +</span><span id="L-1516"><a href="#L-1516"><span class="linenos">1516</span></a> <span class="k">def</span> <span class="nf">update_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">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 class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1517"><a href="#L-1517"><span class="linenos">1517</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-1518"><a href="#L-1518"><span class="linenos">1518</span></a> <span class="n">set_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="kc">True</span><span class="p">)</span> +</span><span id="L-1519"><a href="#L-1519"><span class="linenos">1519</span></a> <span class="n">from_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">"from"</span><span class="p">)</span> +</span><span id="L-1520"><a href="#L-1520"><span class="linenos">1520</span></a> <span class="n">where_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">"where"</span><span class="p">)</span> +</span><span id="L-1521"><a href="#L-1521"><span class="linenos">1521</span></a> <span class="n">returning</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"returning"</span><span class="p">)</span> +</span><span id="L-1522"><a href="#L-1522"><span class="linenos">1522</span></a> <span class="n">order</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"order"</span><span class="p">)</span> +</span><span id="L-1523"><a href="#L-1523"><span class="linenos">1523</span></a> <span class="n">limit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"limit"</span><span class="p">)</span> +</span><span id="L-1524"><a href="#L-1524"><span class="linenos">1524</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">RETURNING_END</span><span class="p">:</span> +</span><span id="L-1525"><a href="#L-1525"><span class="linenos">1525</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">from_sql</span><span class="si">}{</span><span class="n">where_sql</span><span class="si">}{</span><span class="n">returning</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1526"><a href="#L-1526"><span class="linenos">1526</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-1527"><a href="#L-1527"><span class="linenos">1527</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">returning</span><span class="si">}{</span><span class="n">from_sql</span><span class="si">}{</span><span class="n">where_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1528"><a href="#L-1528"><span class="linenos">1528</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"UPDATE </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> SET </span><span class="si">{</span><span class="n">set_sql</span><span class="si">}{</span><span class="n">expression_sql</span><span class="si">}{</span><span class="n">order</span><span class="si">}{</span><span class="n">limit</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1529"><a href="#L-1529"><span class="linenos">1529</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-1530"><a href="#L-1530"><span class="linenos">1530</span></a> +</span><span id="L-1531"><a href="#L-1531"><span class="linenos">1531</span></a> <span class="k">def</span> <span class="nf">values_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Values</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1532"><a href="#L-1532"><span class="linenos">1532</span></a> <span class="c1"># The VALUES clause is still valid in an `INSERT INTO ..` statement, for example</span> +</span><span id="L-1533"><a href="#L-1533"><span class="linenos">1533</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">VALUES_AS_TABLE</span> <span class="ow">or</span> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">find_ancestor</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">From</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Join</span><span class="p">):</span> +</span><span id="L-1534"><a href="#L-1534"><span class="linenos">1534</span></a> <span class="n">args</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-1535"><a href="#L-1535"><span class="linenos">1535</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-1536"><a href="#L-1536"><span class="linenos">1536</span></a> <span class="n">values</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">seg</span><span class="p">(</span><span class="s1">''</span><span class="p">)</span><span class="si">}{</span><span class="n">args</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1537"><a href="#L-1537"><span class="linenos">1537</span></a> <span class="n">values</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="L-1538"><a href="#L-1538"><span class="linenos">1538</span></a> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">values</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="L-1539"><a href="#L-1539"><span class="linenos">1539</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">WRAP_DERIVED_VALUES</span> <span class="ow">and</span> <span class="p">(</span><span class="n">alias</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">From</span><span class="p">))</span> +</span><span id="L-1540"><a href="#L-1540"><span class="linenos">1540</span></a> <span class="k">else</span> <span class="n">values</span> +</span><span id="L-1541"><a href="#L-1541"><span class="linenos">1541</span></a> <span class="p">)</span> +</span><span id="L-1542"><a href="#L-1542"><span class="linenos">1542</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">values</span><span class="si">}</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="n">values</span> +</span><span id="L-1543"><a href="#L-1543"><span class="linenos">1543</span></a> +</span><span id="L-1544"><a href="#L-1544"><span class="linenos">1544</span></a> <span class="c1"># Converts `VALUES...` expression into a series of select unions.</span> +</span><span id="L-1545"><a href="#L-1545"><span class="linenos">1545</span></a> <span class="n">alias_node</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">"alias"</span><span class="p">)</span> +</span><span id="L-1546"><a href="#L-1546"><span class="linenos">1546</span></a> <span class="n">column_names</span> <span class="o">=</span> <span class="n">alias_node</span> <span class="ow">and</span> <span class="n">alias_node</span><span class="o">.</span><span class="n">columns</span> </span><span id="L-1547"><a href="#L-1547"><span class="linenos">1547</span></a> -</span><span id="L-1548"><a href="#L-1548"><span class="linenos">1548</span></a> <span class="k">if</span> <span class="n">i</span> <span class="o">==</span> <span class="mi">0</span> <span class="ow">and</span> <span class="n">column_names</span><span class="p">:</span> -</span><span id="L-1549"><a href="#L-1549"><span class="linenos">1549</span></a> <span class="n">row</span> <span class="o">=</span> <span class="p">[</span> -</span><span id="L-1550"><a href="#L-1550"><span class="linenos">1550</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">alias_</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">column_name</span><span class="p">)</span> <span class="k">for</span> <span class="n">value</span><span class="p">,</span> <span class="n">column_name</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">row</span><span class="p">,</span> <span class="n">column_names</span><span class="p">)</span> -</span><span id="L-1551"><a href="#L-1551"><span class="linenos">1551</span></a> <span class="p">]</span> +</span><span id="L-1548"><a href="#L-1548"><span class="linenos">1548</span></a> <span class="n">selects</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Subqueryable</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="L-1549"><a href="#L-1549"><span class="linenos">1549</span></a> +</span><span id="L-1550"><a href="#L-1550"><span class="linenos">1550</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">tup</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">expressions</span><span class="p">):</span> +</span><span id="L-1551"><a href="#L-1551"><span class="linenos">1551</span></a> <span class="n">row</span> <span class="o">=</span> <span class="n">tup</span><span class="o">.</span><span class="n">expressions</span> </span><span id="L-1552"><a href="#L-1552"><span class="linenos">1552</span></a> -</span><span id="L-1553"><a href="#L-1553"><span class="linenos">1553</span></a> <span class="n">selects</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">row</span><span class="p">))</span> -</span><span id="L-1554"><a href="#L-1554"><span class="linenos">1554</span></a> -</span><span id="L-1555"><a href="#L-1555"><span class="linenos">1555</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-1556"><a href="#L-1556"><span class="linenos">1556</span></a> <span class="c1"># This may result in poor performance for large-cardinality `VALUES` tables, due to</span> -</span><span id="L-1557"><a href="#L-1557"><span class="linenos">1557</span></a> <span class="c1"># the deep nesting of the resulting exp.Unions. If this is a problem, either increase</span> -</span><span id="L-1558"><a href="#L-1558"><span class="linenos">1558</span></a> <span class="c1"># `sys.setrecursionlimit` to avoid RecursionErrors, or don't set `pretty`.</span> -</span><span id="L-1559"><a href="#L-1559"><span class="linenos">1559</span></a> <span class="n">subqueryable</span> <span class="o">=</span> <span class="n">reduce</span><span class="p">(</span><span class="k">lambda</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">union</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">distinct</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">),</span> <span class="n">selects</span><span class="p">)</span> -</span><span id="L-1560"><a href="#L-1560"><span class="linenos">1560</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">subquery_sql</span><span class="p">(</span> -</span><span id="L-1561"><a href="#L-1561"><span class="linenos">1561</span></a> <span class="n">subqueryable</span><span class="o">.</span><span class="n">subquery</span><span class="p">(</span><span class="n">alias_node</span> <span class="ow">and</span> <span class="n">alias_node</span><span class="o">.</span><span class="n">this</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-1562"><a href="#L-1562"><span class="linenos">1562</span></a> <span class="p">)</span> -</span><span id="L-1563"><a href="#L-1563"><span class="linenos">1563</span></a> -</span><span id="L-1564"><a href="#L-1564"><span class="linenos">1564</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="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">alias_node</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="k">if</span> <span class="n">alias_node</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1565"><a href="#L-1565"><span class="linenos">1565</span></a> <span class="n">unions</span> <span class="o">=</span> <span class="s2">" UNION ALL "</span><span class="o">.</span><span class="n">join</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">select</span><span class="p">)</span> <span class="k">for</span> <span class="n">select</span> <span class="ow">in</span> <span class="n">selects</span><span class="p">)</span> -</span><span id="L-1566"><a href="#L-1566"><span class="linenos">1566</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">unions</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1567"><a href="#L-1567"><span class="linenos">1567</span></a> -</span><span id="L-1568"><a href="#L-1568"><span class="linenos">1568</span></a> <span class="k">def</span> <span class="nf">var_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Var</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1569"><a href="#L-1569"><span class="linenos">1569</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">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="L-1570"><a href="#L-1570"><span class="linenos">1570</span></a> -</span><span id="L-1571"><a href="#L-1571"><span class="linenos">1571</span></a> <span class="k">def</span> <span class="nf">into_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Into</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1572"><a href="#L-1572"><span class="linenos">1572</span></a> <span class="n">temporary</span> <span class="o">=</span> <span class="s2">" TEMPORARY"</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">"temporary"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1573"><a href="#L-1573"><span class="linenos">1573</span></a> <span class="n">unlogged</span> <span class="o">=</span> <span class="s2">" UNLOGGED"</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">"unlogged"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1574"><a href="#L-1574"><span class="linenos">1574</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="s1">'INTO'</span><span class="p">)</span><span class="si">}{</span><span class="n">temporary</span><span class="w"> </span><span class="ow">or</span><span class="w"> </span><span class="n">unlogged</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-1553"><a href="#L-1553"><span class="linenos">1553</span></a> <span class="k">if</span> <span class="n">i</span> <span class="o">==</span> <span class="mi">0</span> <span class="ow">and</span> <span class="n">column_names</span><span class="p">:</span> +</span><span id="L-1554"><a href="#L-1554"><span class="linenos">1554</span></a> <span class="n">row</span> <span class="o">=</span> <span class="p">[</span> +</span><span id="L-1555"><a href="#L-1555"><span class="linenos">1555</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">alias_</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">column_name</span><span class="p">)</span> <span class="k">for</span> <span class="n">value</span><span class="p">,</span> <span class="n">column_name</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">row</span><span class="p">,</span> <span class="n">column_names</span><span class="p">)</span> +</span><span id="L-1556"><a href="#L-1556"><span class="linenos">1556</span></a> <span class="p">]</span> +</span><span id="L-1557"><a href="#L-1557"><span class="linenos">1557</span></a> +</span><span id="L-1558"><a href="#L-1558"><span class="linenos">1558</span></a> <span class="n">selects</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">row</span><span class="p">))</span> +</span><span id="L-1559"><a href="#L-1559"><span class="linenos">1559</span></a> +</span><span id="L-1560"><a href="#L-1560"><span class="linenos">1560</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-1561"><a href="#L-1561"><span class="linenos">1561</span></a> <span class="c1"># This may result in poor performance for large-cardinality `VALUES` tables, due to</span> +</span><span id="L-1562"><a href="#L-1562"><span class="linenos">1562</span></a> <span class="c1"># the deep nesting of the resulting exp.Unions. If this is a problem, either increase</span> +</span><span id="L-1563"><a href="#L-1563"><span class="linenos">1563</span></a> <span class="c1"># `sys.setrecursionlimit` to avoid RecursionErrors, or don't set `pretty`.</span> +</span><span id="L-1564"><a href="#L-1564"><span class="linenos">1564</span></a> <span class="n">subqueryable</span> <span class="o">=</span> <span class="n">reduce</span><span class="p">(</span><span class="k">lambda</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">union</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">distinct</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">),</span> <span class="n">selects</span><span class="p">)</span> +</span><span id="L-1565"><a href="#L-1565"><span class="linenos">1565</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">subquery_sql</span><span class="p">(</span> +</span><span id="L-1566"><a href="#L-1566"><span class="linenos">1566</span></a> <span class="n">subqueryable</span><span class="o">.</span><span class="n">subquery</span><span class="p">(</span><span class="n">alias_node</span> <span class="ow">and</span> <span class="n">alias_node</span><span class="o">.</span><span class="n">this</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-1567"><a href="#L-1567"><span class="linenos">1567</span></a> <span class="p">)</span> +</span><span id="L-1568"><a href="#L-1568"><span class="linenos">1568</span></a> +</span><span id="L-1569"><a href="#L-1569"><span class="linenos">1569</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="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">alias_node</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="k">if</span> <span class="n">alias_node</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1570"><a href="#L-1570"><span class="linenos">1570</span></a> <span class="n">unions</span> <span class="o">=</span> <span class="s2">" UNION ALL "</span><span class="o">.</span><span class="n">join</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">select</span><span class="p">)</span> <span class="k">for</span> <span class="n">select</span> <span class="ow">in</span> <span class="n">selects</span><span class="p">)</span> +</span><span id="L-1571"><a href="#L-1571"><span class="linenos">1571</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">unions</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1572"><a href="#L-1572"><span class="linenos">1572</span></a> +</span><span id="L-1573"><a href="#L-1573"><span class="linenos">1573</span></a> <span class="k">def</span> <span class="nf">var_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Var</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1574"><a href="#L-1574"><span class="linenos">1574</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">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> </span><span id="L-1575"><a href="#L-1575"><span class="linenos">1575</span></a> -</span><span id="L-1576"><a href="#L-1576"><span class="linenos">1576</span></a> <span class="k">def</span> <span class="nf">from_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">From</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1577"><a href="#L-1577"><span class="linenos">1577</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="s1">'FROM'</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">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1578"><a href="#L-1578"><span class="linenos">1578</span></a> -</span><span id="L-1579"><a href="#L-1579"><span class="linenos">1579</span></a> <span class="k">def</span> <span class="nf">group_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Group</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1580"><a href="#L-1580"><span class="linenos">1580</span></a> <span class="n">group_by</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">op_expressions</span><span class="p">(</span><span class="s2">"GROUP BY"</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> -</span><span id="L-1581"><a href="#L-1581"><span class="linenos">1581</span></a> -</span><span id="L-1582"><a href="#L-1582"><span class="linenos">1582</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">"all"</span><span class="p">):</span> -</span><span id="L-1583"><a href="#L-1583"><span class="linenos">1583</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">group_by</span><span class="si">}</span><span class="s2"> ALL"</span> -</span><span id="L-1584"><a href="#L-1584"><span class="linenos">1584</span></a> -</span><span id="L-1585"><a href="#L-1585"><span class="linenos">1585</span></a> <span class="n">grouping_sets</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">"grouping_sets"</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> -</span><span id="L-1586"><a href="#L-1586"><span class="linenos">1586</span></a> <span class="n">grouping_sets</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="L-1587"><a href="#L-1587"><span class="linenos">1587</span></a> <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="s1">'GROUPING SETS'</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">wrap</span><span class="p">(</span><span class="n">grouping_sets</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">grouping_sets</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1588"><a href="#L-1588"><span class="linenos">1588</span></a> <span class="p">)</span> +</span><span id="L-1576"><a href="#L-1576"><span class="linenos">1576</span></a> <span class="k">def</span> <span class="nf">into_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Into</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1577"><a href="#L-1577"><span class="linenos">1577</span></a> <span class="n">temporary</span> <span class="o">=</span> <span class="s2">" TEMPORARY"</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">"temporary"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1578"><a href="#L-1578"><span class="linenos">1578</span></a> <span class="n">unlogged</span> <span class="o">=</span> <span class="s2">" UNLOGGED"</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">"unlogged"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1579"><a href="#L-1579"><span class="linenos">1579</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="s1">'INTO'</span><span class="p">)</span><span class="si">}{</span><span class="n">temporary</span><span class="w"> </span><span class="ow">or</span><span class="w"> </span><span class="n">unlogged</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-1580"><a href="#L-1580"><span class="linenos">1580</span></a> +</span><span id="L-1581"><a href="#L-1581"><span class="linenos">1581</span></a> <span class="k">def</span> <span class="nf">from_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">From</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1582"><a href="#L-1582"><span class="linenos">1582</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="s1">'FROM'</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">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1583"><a href="#L-1583"><span class="linenos">1583</span></a> +</span><span id="L-1584"><a href="#L-1584"><span class="linenos">1584</span></a> <span class="k">def</span> <span class="nf">group_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Group</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1585"><a href="#L-1585"><span class="linenos">1585</span></a> <span class="n">group_by</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">op_expressions</span><span class="p">(</span><span class="s2">"GROUP BY"</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> +</span><span id="L-1586"><a href="#L-1586"><span class="linenos">1586</span></a> +</span><span id="L-1587"><a href="#L-1587"><span class="linenos">1587</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">"all"</span><span class="p">):</span> +</span><span id="L-1588"><a href="#L-1588"><span class="linenos">1588</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">group_by</span><span class="si">}</span><span class="s2"> ALL"</span> </span><span id="L-1589"><a href="#L-1589"><span class="linenos">1589</span></a> -</span><span id="L-1590"><a href="#L-1590"><span class="linenos">1590</span></a> <span class="n">cube</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">"cube"</span><span class="p">,</span> <span class="p">[])</span> -</span><span id="L-1591"><a href="#L-1591"><span class="linenos">1591</span></a> <span class="k">if</span> <span class="n">seq_get</span><span class="p">(</span><span class="n">cube</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> <span class="ow">is</span> <span class="kc">True</span><span class="p">:</span> -</span><span id="L-1592"><a href="#L-1592"><span class="linenos">1592</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">group_by</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">'WITH CUBE'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1593"><a href="#L-1593"><span class="linenos">1593</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-1594"><a href="#L-1594"><span class="linenos">1594</span></a> <span class="n">cube_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">"cube"</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> -</span><span id="L-1595"><a href="#L-1595"><span class="linenos">1595</span></a> <span class="n">cube_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">seg</span><span class="p">(</span><span class="s1">'CUBE'</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">wrap</span><span class="p">(</span><span class="n">cube_sql</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">cube_sql</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1596"><a href="#L-1596"><span class="linenos">1596</span></a> -</span><span id="L-1597"><a href="#L-1597"><span class="linenos">1597</span></a> <span class="n">rollup</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">"rollup"</span><span class="p">,</span> <span class="p">[])</span> -</span><span id="L-1598"><a href="#L-1598"><span class="linenos">1598</span></a> <span class="k">if</span> <span class="n">seq_get</span><span class="p">(</span><span class="n">rollup</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> <span class="ow">is</span> <span class="kc">True</span><span class="p">:</span> -</span><span id="L-1599"><a href="#L-1599"><span class="linenos">1599</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">group_by</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">'WITH ROLLUP'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1600"><a href="#L-1600"><span class="linenos">1600</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-1601"><a href="#L-1601"><span class="linenos">1601</span></a> <span class="n">rollup_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">"rollup"</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> -</span><span id="L-1602"><a href="#L-1602"><span class="linenos">1602</span></a> <span class="n">rollup_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">seg</span><span class="p">(</span><span class="s1">'ROLLUP'</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">wrap</span><span class="p">(</span><span class="n">rollup_sql</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">rollup_sql</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1603"><a href="#L-1603"><span class="linenos">1603</span></a> -</span><span id="L-1604"><a href="#L-1604"><span class="linenos">1604</span></a> <span class="n">groupings</span> <span class="o">=</span> <span class="n">csv</span><span class="p">(</span> -</span><span id="L-1605"><a href="#L-1605"><span class="linenos">1605</span></a> <span class="n">grouping_sets</span><span class="p">,</span> -</span><span id="L-1606"><a href="#L-1606"><span class="linenos">1606</span></a> <span class="n">cube_sql</span><span class="p">,</span> -</span><span id="L-1607"><a href="#L-1607"><span class="linenos">1607</span></a> <span class="n">rollup_sql</span><span class="p">,</span> -</span><span id="L-1608"><a href="#L-1608"><span class="linenos">1608</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s2">"WITH TOTALS"</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">"totals"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span><span class="p">,</span> -</span><span id="L-1609"><a href="#L-1609"><span class="linenos">1609</span></a> <span class="n">sep</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">GROUPINGS_SEP</span><span class="p">,</span> -</span><span id="L-1610"><a href="#L-1610"><span class="linenos">1610</span></a> <span class="p">)</span> -</span><span id="L-1611"><a href="#L-1611"><span class="linenos">1611</span></a> -</span><span id="L-1612"><a href="#L-1612"><span class="linenos">1612</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">"expressions"</span><span class="p">)</span> <span class="ow">and</span> <span class="n">groupings</span><span class="p">:</span> -</span><span id="L-1613"><a href="#L-1613"><span class="linenos">1613</span></a> <span class="n">group_by</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">group_by</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">GROUPINGS_SEP</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1614"><a href="#L-1614"><span class="linenos">1614</span></a> -</span><span id="L-1615"><a href="#L-1615"><span class="linenos">1615</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">group_by</span><span class="si">}{</span><span class="n">groupings</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1590"><a href="#L-1590"><span class="linenos">1590</span></a> <span class="n">grouping_sets</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">"grouping_sets"</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</span><span id="L-1591"><a href="#L-1591"><span class="linenos">1591</span></a> <span class="n">grouping_sets</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="L-1592"><a href="#L-1592"><span class="linenos">1592</span></a> <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="s1">'GROUPING SETS'</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">wrap</span><span class="p">(</span><span class="n">grouping_sets</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">grouping_sets</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1593"><a href="#L-1593"><span class="linenos">1593</span></a> <span class="p">)</span> +</span><span id="L-1594"><a href="#L-1594"><span class="linenos">1594</span></a> +</span><span id="L-1595"><a href="#L-1595"><span class="linenos">1595</span></a> <span class="n">cube</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">"cube"</span><span class="p">,</span> <span class="p">[])</span> +</span><span id="L-1596"><a href="#L-1596"><span class="linenos">1596</span></a> <span class="k">if</span> <span class="n">seq_get</span><span class="p">(</span><span class="n">cube</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> <span class="ow">is</span> <span class="kc">True</span><span class="p">:</span> +</span><span id="L-1597"><a href="#L-1597"><span class="linenos">1597</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">group_by</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">'WITH CUBE'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1598"><a href="#L-1598"><span class="linenos">1598</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-1599"><a href="#L-1599"><span class="linenos">1599</span></a> <span class="n">cube_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">"cube"</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</span><span id="L-1600"><a href="#L-1600"><span class="linenos">1600</span></a> <span class="n">cube_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">seg</span><span class="p">(</span><span class="s1">'CUBE'</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">wrap</span><span class="p">(</span><span class="n">cube_sql</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">cube_sql</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1601"><a href="#L-1601"><span class="linenos">1601</span></a> +</span><span id="L-1602"><a href="#L-1602"><span class="linenos">1602</span></a> <span class="n">rollup</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">"rollup"</span><span class="p">,</span> <span class="p">[])</span> +</span><span id="L-1603"><a href="#L-1603"><span class="linenos">1603</span></a> <span class="k">if</span> <span class="n">seq_get</span><span class="p">(</span><span class="n">rollup</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> <span class="ow">is</span> <span class="kc">True</span><span class="p">:</span> +</span><span id="L-1604"><a href="#L-1604"><span class="linenos">1604</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">group_by</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">'WITH ROLLUP'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1605"><a href="#L-1605"><span class="linenos">1605</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-1606"><a href="#L-1606"><span class="linenos">1606</span></a> <span class="n">rollup_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">"rollup"</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</span><span id="L-1607"><a href="#L-1607"><span class="linenos">1607</span></a> <span class="n">rollup_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">seg</span><span class="p">(</span><span class="s1">'ROLLUP'</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">wrap</span><span class="p">(</span><span class="n">rollup_sql</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">rollup_sql</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1608"><a href="#L-1608"><span class="linenos">1608</span></a> +</span><span id="L-1609"><a href="#L-1609"><span class="linenos">1609</span></a> <span class="n">groupings</span> <span class="o">=</span> <span class="n">csv</span><span class="p">(</span> +</span><span id="L-1610"><a href="#L-1610"><span class="linenos">1610</span></a> <span class="n">grouping_sets</span><span class="p">,</span> +</span><span id="L-1611"><a href="#L-1611"><span class="linenos">1611</span></a> <span class="n">cube_sql</span><span class="p">,</span> +</span><span id="L-1612"><a href="#L-1612"><span class="linenos">1612</span></a> <span class="n">rollup_sql</span><span class="p">,</span> +</span><span id="L-1613"><a href="#L-1613"><span class="linenos">1613</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s2">"WITH TOTALS"</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">"totals"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span><span class="p">,</span> +</span><span id="L-1614"><a href="#L-1614"><span class="linenos">1614</span></a> <span class="n">sep</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">GROUPINGS_SEP</span><span class="p">,</span> +</span><span id="L-1615"><a href="#L-1615"><span class="linenos">1615</span></a> <span class="p">)</span> </span><span id="L-1616"><a href="#L-1616"><span class="linenos">1616</span></a> -</span><span id="L-1617"><a href="#L-1617"><span class="linenos">1617</span></a> <span class="k">def</span> <span class="nf">having_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Having</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1618"><a href="#L-1618"><span class="linenos">1618</span></a> <span class="n">this</span> <span class="o">=</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><span id="L-1619"><a href="#L-1619"><span class="linenos">1619</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="s1">'HAVING'</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="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1620"><a href="#L-1620"><span class="linenos">1620</span></a> -</span><span id="L-1621"><a href="#L-1621"><span class="linenos">1621</span></a> <span class="k">def</span> <span class="nf">connect_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Connect</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1622"><a href="#L-1622"><span class="linenos">1622</span></a> <span class="n">start</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"start"</span><span class="p">)</span> -</span><span id="L-1623"><a href="#L-1623"><span class="linenos">1623</span></a> <span class="n">start</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="sa">f</span><span class="s2">"START WITH </span><span class="si">{</span><span class="n">start</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> <span class="k">if</span> <span class="n">start</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1624"><a href="#L-1624"><span class="linenos">1624</span></a> <span class="n">connect</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"connect"</span><span class="p">)</span> -</span><span id="L-1625"><a href="#L-1625"><span class="linenos">1625</span></a> <span class="n">connect</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="sa">f</span><span class="s2">"CONNECT BY </span><span class="si">{</span><span class="n">connect</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="L-1626"><a href="#L-1626"><span class="linenos">1626</span></a> <span class="k">return</span> <span class="n">start</span> <span class="o">+</span> <span class="n">connect</span> -</span><span id="L-1627"><a href="#L-1627"><span class="linenos">1627</span></a> -</span><span id="L-1628"><a href="#L-1628"><span class="linenos">1628</span></a> <span class="k">def</span> <span class="nf">prior_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Prior</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1629"><a href="#L-1629"><span class="linenos">1629</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PRIOR </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-1630"><a href="#L-1630"><span class="linenos">1630</span></a> -</span><span id="L-1631"><a href="#L-1631"><span class="linenos">1631</span></a> <span class="k">def</span> <span class="nf">join_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Join</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1632"><a href="#L-1632"><span class="linenos">1632</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">SEMI_ANTI_JOIN_WITH_SIDE</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">kind</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">"SEMI"</span><span class="p">,</span> <span class="s2">"ANTI"</span><span class="p">):</span> -</span><span id="L-1633"><a href="#L-1633"><span class="linenos">1633</span></a> <span class="n">side</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-1634"><a href="#L-1634"><span class="linenos">1634</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-1635"><a href="#L-1635"><span class="linenos">1635</span></a> <span class="n">side</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">side</span> -</span><span id="L-1636"><a href="#L-1636"><span class="linenos">1636</span></a> -</span><span id="L-1637"><a href="#L-1637"><span class="linenos">1637</span></a> <span class="n">op_sql</span> <span class="o">=</span> <span class="s2">" "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> -</span><span id="L-1638"><a href="#L-1638"><span class="linenos">1638</span></a> <span class="n">op</span> -</span><span id="L-1639"><a href="#L-1639"><span class="linenos">1639</span></a> <span class="k">for</span> <span class="n">op</span> <span class="ow">in</span> <span class="p">(</span> -</span><span id="L-1640"><a href="#L-1640"><span class="linenos">1640</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">method</span><span class="p">,</span> -</span><span id="L-1641"><a href="#L-1641"><span class="linenos">1641</span></a> <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">"global"</span><span class="p">)</span> <span class="k">else</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-1642"><a href="#L-1642"><span class="linenos">1642</span></a> <span class="n">side</span><span class="p">,</span> -</span><span id="L-1643"><a href="#L-1643"><span class="linenos">1643</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">kind</span><span class="p">,</span> -</span><span id="L-1644"><a href="#L-1644"><span class="linenos">1644</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">hint</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">JOIN_HINTS</span> <span class="k">else</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-1645"><a href="#L-1645"><span class="linenos">1645</span></a> <span class="p">)</span> -</span><span id="L-1646"><a href="#L-1646"><span class="linenos">1646</span></a> <span class="k">if</span> <span class="n">op</span> -</span><span id="L-1647"><a href="#L-1647"><span class="linenos">1647</span></a> <span class="p">)</span> -</span><span id="L-1648"><a href="#L-1648"><span class="linenos">1648</span></a> <span class="n">on_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">"on"</span><span class="p">)</span> -</span><span id="L-1649"><a href="#L-1649"><span class="linenos">1649</span></a> <span class="n">using</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">"using"</span><span class="p">)</span> -</span><span id="L-1650"><a href="#L-1650"><span class="linenos">1650</span></a> -</span><span id="L-1651"><a href="#L-1651"><span class="linenos">1651</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">on_sql</span> <span class="ow">and</span> <span class="n">using</span><span class="p">:</span> -</span><span id="L-1652"><a href="#L-1652"><span class="linenos">1652</span></a> <span class="n">on_sql</span> <span class="o">=</span> <span class="n">csv</span><span class="p">(</span><span class="o">*</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">column</span><span class="p">)</span> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">using</span><span class="p">))</span> -</span><span id="L-1653"><a href="#L-1653"><span class="linenos">1653</span></a> -</span><span id="L-1654"><a href="#L-1654"><span class="linenos">1654</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-1617"><a href="#L-1617"><span class="linenos">1617</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">"expressions"</span><span class="p">)</span> <span class="ow">and</span> <span class="n">groupings</span><span class="p">:</span> +</span><span id="L-1618"><a href="#L-1618"><span class="linenos">1618</span></a> <span class="n">group_by</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">group_by</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">GROUPINGS_SEP</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1619"><a href="#L-1619"><span class="linenos">1619</span></a> +</span><span id="L-1620"><a href="#L-1620"><span class="linenos">1620</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">group_by</span><span class="si">}{</span><span class="n">groupings</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1621"><a href="#L-1621"><span class="linenos">1621</span></a> +</span><span id="L-1622"><a href="#L-1622"><span class="linenos">1622</span></a> <span class="k">def</span> <span class="nf">having_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Having</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1623"><a href="#L-1623"><span class="linenos">1623</span></a> <span class="n">this</span> <span class="o">=</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><span id="L-1624"><a href="#L-1624"><span class="linenos">1624</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="s1">'HAVING'</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="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1625"><a href="#L-1625"><span class="linenos">1625</span></a> +</span><span id="L-1626"><a href="#L-1626"><span class="linenos">1626</span></a> <span class="k">def</span> <span class="nf">connect_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Connect</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1627"><a href="#L-1627"><span class="linenos">1627</span></a> <span class="n">start</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"start"</span><span class="p">)</span> +</span><span id="L-1628"><a href="#L-1628"><span class="linenos">1628</span></a> <span class="n">start</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="sa">f</span><span class="s2">"START WITH </span><span class="si">{</span><span class="n">start</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> <span class="k">if</span> <span class="n">start</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1629"><a href="#L-1629"><span class="linenos">1629</span></a> <span class="n">connect</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"connect"</span><span class="p">)</span> +</span><span id="L-1630"><a href="#L-1630"><span class="linenos">1630</span></a> <span class="n">connect</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="sa">f</span><span class="s2">"CONNECT BY </span><span class="si">{</span><span class="n">connect</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="L-1631"><a href="#L-1631"><span class="linenos">1631</span></a> <span class="k">return</span> <span class="n">start</span> <span class="o">+</span> <span class="n">connect</span> +</span><span id="L-1632"><a href="#L-1632"><span class="linenos">1632</span></a> +</span><span id="L-1633"><a href="#L-1633"><span class="linenos">1633</span></a> <span class="k">def</span> <span class="nf">prior_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Prior</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1634"><a href="#L-1634"><span class="linenos">1634</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PRIOR </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-1635"><a href="#L-1635"><span class="linenos">1635</span></a> +</span><span id="L-1636"><a href="#L-1636"><span class="linenos">1636</span></a> <span class="k">def</span> <span class="nf">join_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Join</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1637"><a href="#L-1637"><span class="linenos">1637</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">SEMI_ANTI_JOIN_WITH_SIDE</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">kind</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">"SEMI"</span><span class="p">,</span> <span class="s2">"ANTI"</span><span class="p">):</span> +</span><span id="L-1638"><a href="#L-1638"><span class="linenos">1638</span></a> <span class="n">side</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-1639"><a href="#L-1639"><span class="linenos">1639</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-1640"><a href="#L-1640"><span class="linenos">1640</span></a> <span class="n">side</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">side</span> +</span><span id="L-1641"><a href="#L-1641"><span class="linenos">1641</span></a> +</span><span id="L-1642"><a href="#L-1642"><span class="linenos">1642</span></a> <span class="n">op_sql</span> <span class="o">=</span> <span class="s2">" "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> +</span><span id="L-1643"><a href="#L-1643"><span class="linenos">1643</span></a> <span class="n">op</span> +</span><span id="L-1644"><a href="#L-1644"><span class="linenos">1644</span></a> <span class="k">for</span> <span class="n">op</span> <span class="ow">in</span> <span class="p">(</span> +</span><span id="L-1645"><a href="#L-1645"><span class="linenos">1645</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">method</span><span class="p">,</span> +</span><span id="L-1646"><a href="#L-1646"><span class="linenos">1646</span></a> <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">"global"</span><span class="p">)</span> <span class="k">else</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-1647"><a href="#L-1647"><span class="linenos">1647</span></a> <span class="n">side</span><span class="p">,</span> +</span><span id="L-1648"><a href="#L-1648"><span class="linenos">1648</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">kind</span><span class="p">,</span> +</span><span id="L-1649"><a href="#L-1649"><span class="linenos">1649</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">hint</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">JOIN_HINTS</span> <span class="k">else</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-1650"><a href="#L-1650"><span class="linenos">1650</span></a> <span class="p">)</span> +</span><span id="L-1651"><a href="#L-1651"><span class="linenos">1651</span></a> <span class="k">if</span> <span class="n">op</span> +</span><span id="L-1652"><a href="#L-1652"><span class="linenos">1652</span></a> <span class="p">)</span> +</span><span id="L-1653"><a href="#L-1653"><span class="linenos">1653</span></a> <span class="n">on_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">"on"</span><span class="p">)</span> +</span><span id="L-1654"><a href="#L-1654"><span class="linenos">1654</span></a> <span class="n">using</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">"using"</span><span class="p">)</span> </span><span id="L-1655"><a href="#L-1655"><span class="linenos">1655</span></a> -</span><span id="L-1656"><a href="#L-1656"><span class="linenos">1656</span></a> <span class="k">if</span> <span class="n">on_sql</span><span class="p">:</span> -</span><span id="L-1657"><a href="#L-1657"><span class="linenos">1657</span></a> <span class="n">on_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="n">on_sql</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><span id="L-1658"><a href="#L-1658"><span class="linenos">1658</span></a> <span class="n">space</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">" "</span> <span class="o">*</span> <span class="bp">self</span><span class="o">.</span><span class="n">pad</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><span id="L-1659"><a href="#L-1659"><span class="linenos">1659</span></a> <span class="k">if</span> <span class="n">using</span><span class="p">:</span> -</span><span id="L-1660"><a href="#L-1660"><span class="linenos">1660</span></a> <span class="n">on_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">space</span><span class="si">}</span><span class="s2">USING (</span><span class="si">{</span><span class="n">on_sql</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="L-1661"><a href="#L-1661"><span class="linenos">1661</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-1662"><a href="#L-1662"><span class="linenos">1662</span></a> <span class="n">on_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">space</span><span class="si">}</span><span class="s2">ON </span><span class="si">{</span><span class="n">on_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1663"><a href="#L-1663"><span class="linenos">1663</span></a> <span class="k">elif</span> <span class="ow">not</span> <span class="n">op_sql</span><span class="p">:</span> -</span><span id="L-1664"><a href="#L-1664"><span class="linenos">1664</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">", </span><span class="si">{</span><span class="n">this_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1665"><a href="#L-1665"><span class="linenos">1665</span></a> -</span><span id="L-1666"><a href="#L-1666"><span class="linenos">1666</span></a> <span class="n">op_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">op_sql</span><span class="si">}</span><span class="s2"> JOIN"</span> <span class="k">if</span> <span class="n">op_sql</span> <span class="k">else</span> <span class="s2">"JOIN"</span> -</span><span id="L-1667"><a href="#L-1667"><span class="linenos">1667</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_sql</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">this_sql</span><span class="si">}{</span><span class="n">on_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1668"><a href="#L-1668"><span class="linenos">1668</span></a> -</span><span id="L-1669"><a href="#L-1669"><span class="linenos">1669</span></a> <span class="k">def</span> <span class="nf">lambda_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Lambda</span><span class="p">,</span> <span class="n">arrow_sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"->"</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1670"><a href="#L-1670"><span class="linenos">1670</span></a> <span class="n">args</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-1671"><a href="#L-1671"><span class="linenos">1671</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="n">args</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">args</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">","</span><span class="p">))</span> <span class="o">></span> <span class="mi">1</span> <span class="k">else</span> <span class="n">args</span> -</span><span id="L-1672"><a href="#L-1672"><span class="linenos">1672</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">args</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">arrow_sep</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-1656"><a href="#L-1656"><span class="linenos">1656</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">on_sql</span> <span class="ow">and</span> <span class="n">using</span><span class="p">:</span> +</span><span id="L-1657"><a href="#L-1657"><span class="linenos">1657</span></a> <span class="n">on_sql</span> <span class="o">=</span> <span class="n">csv</span><span class="p">(</span><span class="o">*</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">column</span><span class="p">)</span> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">using</span><span class="p">))</span> +</span><span id="L-1658"><a href="#L-1658"><span class="linenos">1658</span></a> +</span><span id="L-1659"><a href="#L-1659"><span class="linenos">1659</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-1660"><a href="#L-1660"><span class="linenos">1660</span></a> +</span><span id="L-1661"><a href="#L-1661"><span class="linenos">1661</span></a> <span class="k">if</span> <span class="n">on_sql</span><span class="p">:</span> +</span><span id="L-1662"><a href="#L-1662"><span class="linenos">1662</span></a> <span class="n">on_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="n">on_sql</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><span id="L-1663"><a href="#L-1663"><span class="linenos">1663</span></a> <span class="n">space</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">" "</span> <span class="o">*</span> <span class="bp">self</span><span class="o">.</span><span class="n">pad</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><span id="L-1664"><a href="#L-1664"><span class="linenos">1664</span></a> <span class="k">if</span> <span class="n">using</span><span class="p">:</span> +</span><span id="L-1665"><a href="#L-1665"><span class="linenos">1665</span></a> <span class="n">on_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">space</span><span class="si">}</span><span class="s2">USING (</span><span class="si">{</span><span class="n">on_sql</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="L-1666"><a href="#L-1666"><span class="linenos">1666</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-1667"><a href="#L-1667"><span class="linenos">1667</span></a> <span class="n">on_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">space</span><span class="si">}</span><span class="s2">ON </span><span class="si">{</span><span class="n">on_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1668"><a href="#L-1668"><span class="linenos">1668</span></a> <span class="k">elif</span> <span class="ow">not</span> <span class="n">op_sql</span><span class="p">:</span> +</span><span id="L-1669"><a href="#L-1669"><span class="linenos">1669</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">", </span><span class="si">{</span><span class="n">this_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1670"><a href="#L-1670"><span class="linenos">1670</span></a> +</span><span id="L-1671"><a href="#L-1671"><span class="linenos">1671</span></a> <span class="n">op_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">op_sql</span><span class="si">}</span><span class="s2"> JOIN"</span> <span class="k">if</span> <span class="n">op_sql</span> <span class="k">else</span> <span class="s2">"JOIN"</span> +</span><span id="L-1672"><a href="#L-1672"><span class="linenos">1672</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_sql</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">this_sql</span><span class="si">}{</span><span class="n">on_sql</span><span class="si">}</span><span class="s2">"</span> </span><span id="L-1673"><a href="#L-1673"><span class="linenos">1673</span></a> -</span><span id="L-1674"><a href="#L-1674"><span class="linenos">1674</span></a> <span class="k">def</span> <span class="nf">lateral_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Lateral</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1675"><a href="#L-1675"><span class="linenos">1675</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-1676"><a href="#L-1676"><span class="linenos">1676</span></a> -</span><span id="L-1677"><a href="#L-1677"><span class="linenos">1677</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">"view"</span><span class="p">):</span> -</span><span id="L-1678"><a href="#L-1678"><span class="linenos">1678</span></a> <span class="n">alias</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">"alias"</span><span class="p">]</span> -</span><span id="L-1679"><a href="#L-1679"><span class="linenos">1679</span></a> <span class="n">columns</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">alias</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"columns"</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-1680"><a href="#L-1680"><span class="linenos">1680</span></a> <span class="n">table</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">alias</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alias</span><span class="o">.</span><span class="n">name</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1681"><a href="#L-1681"><span class="linenos">1681</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="n">columns</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">columns</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1682"><a href="#L-1682"><span class="linenos">1682</span></a> <span class="n">op_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="sa">f</span><span class="s2">"LATERAL VIEW</span><span class="si">{</span><span class="s1">' OUTER'</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">'outer'</span><span class="p">)</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-1683"><a href="#L-1683"><span class="linenos">1683</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">op_sql</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="n">this</span><span class="si">}{</span><span class="n">table</span><span class="si">}{</span><span class="n">columns</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1684"><a href="#L-1684"><span class="linenos">1684</span></a> -</span><span id="L-1685"><a href="#L-1685"><span class="linenos">1685</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-1686"><a href="#L-1686"><span class="linenos">1686</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-1687"><a href="#L-1687"><span class="linenos">1687</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"LATERAL </span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1688"><a href="#L-1688"><span class="linenos">1688</span></a> -</span><span id="L-1689"><a href="#L-1689"><span class="linenos">1689</span></a> <span class="k">def</span> <span class="nf">limit_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">,</span> <span class="n">top</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-1690"><a href="#L-1690"><span class="linenos">1690</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-1691"><a href="#L-1691"><span class="linenos">1691</span></a> -</span><span id="L-1692"><a href="#L-1692"><span class="linenos">1692</span></a> <span class="n">args</span> <span class="o">=</span> <span class="p">[</span> -</span><span id="L-1693"><a href="#L-1693"><span class="linenos">1693</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_simplify_unless_literal</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">LIMIT_ONLY_LITERALS</span> <span class="k">else</span> <span class="n">e</span> -</span><span id="L-1694"><a href="#L-1694"><span class="linenos">1694</span></a> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</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">get</span><span class="p">(</span><span class="n">k</span><span class="p">)</span> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">"offset"</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">))</span> -</span><span id="L-1695"><a href="#L-1695"><span class="linenos">1695</span></a> <span class="k">if</span> <span class="n">e</span> -</span><span id="L-1696"><a href="#L-1696"><span class="linenos">1696</span></a> <span class="p">]</span> -</span><span id="L-1697"><a href="#L-1697"><span class="linenos">1697</span></a> -</span><span id="L-1698"><a href="#L-1698"><span class="linenos">1698</span></a> <span class="n">args_sql</span> <span class="o">=</span> <span class="s2">", "</span><span class="o">.</span><span class="n">join</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">args</span><span class="p">)</span> -</span><span id="L-1699"><a href="#L-1699"><span class="linenos">1699</span></a> <span class="n">args_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">args_sql</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="nb">any</span><span class="p">(</span><span class="n">top</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">e</span><span class="o">.</span><span class="n">is_number</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">args</span><span class="p">)</span> <span class="k">else</span> <span class="n">args_sql</span> -</span><span id="L-1700"><a href="#L-1700"><span class="linenos">1700</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="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'TOP'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">top</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">'LIMIT'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">args_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1701"><a href="#L-1701"><span class="linenos">1701</span></a> -</span><span id="L-1702"><a href="#L-1702"><span class="linenos">1702</span></a> <span class="k">def</span> <span class="nf">offset_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Offset</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1703"><a href="#L-1703"><span class="linenos">1703</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-1704"><a href="#L-1704"><span class="linenos">1704</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span> -</span><span id="L-1705"><a href="#L-1705"><span class="linenos">1705</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="L-1706"><a href="#L-1706"><span class="linenos">1706</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_simplify_unless_literal</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">LIMIT_ONLY_LITERALS</span> <span class="k">else</span> <span class="n">expression</span> -</span><span id="L-1707"><a href="#L-1707"><span class="linenos">1707</span></a> <span class="p">)</span> -</span><span id="L-1708"><a href="#L-1708"><span class="linenos">1708</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="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'OFFSET'</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="si">}</span><span class="s2">"</span> -</span><span id="L-1709"><a href="#L-1709"><span class="linenos">1709</span></a> -</span><span id="L-1710"><a href="#L-1710"><span class="linenos">1710</span></a> <span class="k">def</span> <span class="nf">setitem_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SetItem</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1711"><a href="#L-1711"><span class="linenos">1711</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-1712"><a href="#L-1712"><span class="linenos">1712</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-1713"><a href="#L-1713"><span class="linenos">1713</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-1714"><a href="#L-1714"><span class="linenos">1714</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-1715"><a href="#L-1715"><span class="linenos">1715</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-1716"><a href="#L-1716"><span class="linenos">1716</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-1717"><a href="#L-1717"><span class="linenos">1717</span></a> <span class="n">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">"global"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1718"><a href="#L-1718"><span class="linenos">1718</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">global_</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">expressions</span><span class="si">}{</span><span class="n">collate</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1719"><a href="#L-1719"><span class="linenos">1719</span></a> -</span><span id="L-1720"><a href="#L-1720"><span class="linenos">1720</span></a> <span class="k">def</span> <span class="nf">set_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Set</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1721"><a href="#L-1721"><span class="linenos">1721</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="L-1722"><a href="#L-1722"><span class="linenos">1722</span></a> <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 class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1723"><a href="#L-1723"><span class="linenos">1723</span></a> <span class="p">)</span> -</span><span id="L-1724"><a href="#L-1724"><span class="linenos">1724</span></a> <span class="n">tag</span> <span class="o">=</span> <span class="s2">" TAG"</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">"tag"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1725"><a href="#L-1725"><span class="linenos">1725</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="s1">'UNSET'</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">'unset'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">'SET'</span><span class="si">}{</span><span class="n">tag</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1726"><a href="#L-1726"><span class="linenos">1726</span></a> -</span><span id="L-1727"><a href="#L-1727"><span class="linenos">1727</span></a> <span class="k">def</span> <span class="nf">pragma_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Pragma</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1728"><a href="#L-1728"><span class="linenos">1728</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PRAGMA </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-1729"><a href="#L-1729"><span class="linenos">1729</span></a> -</span><span id="L-1730"><a href="#L-1730"><span class="linenos">1730</span></a> <span class="k">def</span> <span class="nf">lock_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Lock</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1731"><a href="#L-1731"><span class="linenos">1731</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">LOCKING_READS_SUPPORTED</span><span class="p">:</span> -</span><span id="L-1732"><a href="#L-1732"><span class="linenos">1732</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Locking reads using 'FOR UPDATE/SHARE' are not supported"</span><span class="p">)</span> -</span><span id="L-1733"><a href="#L-1733"><span class="linenos">1733</span></a> <span class="k">return</span> <span class="s2">""</span> +</span><span id="L-1674"><a href="#L-1674"><span class="linenos">1674</span></a> <span class="k">def</span> <span class="nf">lambda_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Lambda</span><span class="p">,</span> <span class="n">arrow_sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"->"</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1675"><a href="#L-1675"><span class="linenos">1675</span></a> <span class="n">args</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-1676"><a href="#L-1676"><span class="linenos">1676</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="n">args</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">args</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">","</span><span class="p">))</span> <span class="o">></span> <span class="mi">1</span> <span class="k">else</span> <span class="n">args</span> +</span><span id="L-1677"><a href="#L-1677"><span class="linenos">1677</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">args</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">arrow_sep</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-1678"><a href="#L-1678"><span class="linenos">1678</span></a> +</span><span id="L-1679"><a href="#L-1679"><span class="linenos">1679</span></a> <span class="k">def</span> <span class="nf">lateral_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Lateral</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1680"><a href="#L-1680"><span class="linenos">1680</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-1681"><a href="#L-1681"><span class="linenos">1681</span></a> +</span><span id="L-1682"><a href="#L-1682"><span class="linenos">1682</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">"view"</span><span class="p">):</span> +</span><span id="L-1683"><a href="#L-1683"><span class="linenos">1683</span></a> <span class="n">alias</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">"alias"</span><span class="p">]</span> +</span><span id="L-1684"><a href="#L-1684"><span class="linenos">1684</span></a> <span class="n">columns</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">alias</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"columns"</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-1685"><a href="#L-1685"><span class="linenos">1685</span></a> <span class="n">table</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">alias</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alias</span><span class="o">.</span><span class="n">name</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1686"><a href="#L-1686"><span class="linenos">1686</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="n">columns</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">columns</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1687"><a href="#L-1687"><span class="linenos">1687</span></a> <span class="n">op_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="sa">f</span><span class="s2">"LATERAL VIEW</span><span class="si">{</span><span class="s1">' OUTER'</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">'outer'</span><span class="p">)</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-1688"><a href="#L-1688"><span class="linenos">1688</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">op_sql</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="n">this</span><span class="si">}{</span><span class="n">table</span><span class="si">}{</span><span class="n">columns</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1689"><a href="#L-1689"><span class="linenos">1689</span></a> +</span><span id="L-1690"><a href="#L-1690"><span class="linenos">1690</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-1691"><a href="#L-1691"><span class="linenos">1691</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-1692"><a href="#L-1692"><span class="linenos">1692</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"LATERAL </span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1693"><a href="#L-1693"><span class="linenos">1693</span></a> +</span><span id="L-1694"><a href="#L-1694"><span class="linenos">1694</span></a> <span class="k">def</span> <span class="nf">limit_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">,</span> <span class="n">top</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-1695"><a href="#L-1695"><span class="linenos">1695</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-1696"><a href="#L-1696"><span class="linenos">1696</span></a> +</span><span id="L-1697"><a href="#L-1697"><span class="linenos">1697</span></a> <span class="n">args</span> <span class="o">=</span> <span class="p">[</span> +</span><span id="L-1698"><a href="#L-1698"><span class="linenos">1698</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_simplify_unless_literal</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">LIMIT_ONLY_LITERALS</span> <span class="k">else</span> <span class="n">e</span> +</span><span id="L-1699"><a href="#L-1699"><span class="linenos">1699</span></a> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</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">get</span><span class="p">(</span><span class="n">k</span><span class="p">)</span> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">"offset"</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">))</span> +</span><span id="L-1700"><a href="#L-1700"><span class="linenos">1700</span></a> <span class="k">if</span> <span class="n">e</span> +</span><span id="L-1701"><a href="#L-1701"><span class="linenos">1701</span></a> <span class="p">]</span> +</span><span id="L-1702"><a href="#L-1702"><span class="linenos">1702</span></a> +</span><span id="L-1703"><a href="#L-1703"><span class="linenos">1703</span></a> <span class="n">args_sql</span> <span class="o">=</span> <span class="s2">", "</span><span class="o">.</span><span class="n">join</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">args</span><span class="p">)</span> +</span><span id="L-1704"><a href="#L-1704"><span class="linenos">1704</span></a> <span class="n">args_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">args_sql</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="nb">any</span><span class="p">(</span><span class="n">top</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">e</span><span class="o">.</span><span class="n">is_number</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">args</span><span class="p">)</span> <span class="k">else</span> <span class="n">args_sql</span> +</span><span id="L-1705"><a href="#L-1705"><span class="linenos">1705</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="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'TOP'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">top</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">'LIMIT'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">args_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1706"><a href="#L-1706"><span class="linenos">1706</span></a> +</span><span id="L-1707"><a href="#L-1707"><span class="linenos">1707</span></a> <span class="k">def</span> <span class="nf">offset_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Offset</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1708"><a href="#L-1708"><span class="linenos">1708</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-1709"><a href="#L-1709"><span class="linenos">1709</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span> +</span><span id="L-1710"><a href="#L-1710"><span class="linenos">1710</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="L-1711"><a href="#L-1711"><span class="linenos">1711</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_simplify_unless_literal</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">LIMIT_ONLY_LITERALS</span> <span class="k">else</span> <span class="n">expression</span> +</span><span id="L-1712"><a href="#L-1712"><span class="linenos">1712</span></a> <span class="p">)</span> +</span><span id="L-1713"><a href="#L-1713"><span class="linenos">1713</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="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'OFFSET'</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="si">}</span><span class="s2">"</span> +</span><span id="L-1714"><a href="#L-1714"><span class="linenos">1714</span></a> +</span><span id="L-1715"><a href="#L-1715"><span class="linenos">1715</span></a> <span class="k">def</span> <span class="nf">setitem_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SetItem</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1716"><a href="#L-1716"><span class="linenos">1716</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-1717"><a href="#L-1717"><span class="linenos">1717</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-1718"><a href="#L-1718"><span class="linenos">1718</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-1719"><a href="#L-1719"><span class="linenos">1719</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-1720"><a href="#L-1720"><span class="linenos">1720</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-1721"><a href="#L-1721"><span class="linenos">1721</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-1722"><a href="#L-1722"><span class="linenos">1722</span></a> <span class="n">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">"global"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1723"><a href="#L-1723"><span class="linenos">1723</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">global_</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">expressions</span><span class="si">}{</span><span class="n">collate</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1724"><a href="#L-1724"><span class="linenos">1724</span></a> +</span><span id="L-1725"><a href="#L-1725"><span class="linenos">1725</span></a> <span class="k">def</span> <span class="nf">set_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Set</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1726"><a href="#L-1726"><span class="linenos">1726</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="L-1727"><a href="#L-1727"><span class="linenos">1727</span></a> <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 class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1728"><a href="#L-1728"><span class="linenos">1728</span></a> <span class="p">)</span> +</span><span id="L-1729"><a href="#L-1729"><span class="linenos">1729</span></a> <span class="n">tag</span> <span class="o">=</span> <span class="s2">" TAG"</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">"tag"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1730"><a href="#L-1730"><span class="linenos">1730</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="s1">'UNSET'</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">'unset'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">'SET'</span><span class="si">}{</span><span class="n">tag</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1731"><a href="#L-1731"><span class="linenos">1731</span></a> +</span><span id="L-1732"><a href="#L-1732"><span class="linenos">1732</span></a> <span class="k">def</span> <span class="nf">pragma_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Pragma</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1733"><a href="#L-1733"><span class="linenos">1733</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PRAGMA </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-1734"><a href="#L-1734"><span class="linenos">1734</span></a> -</span><span id="L-1735"><a href="#L-1735"><span class="linenos">1735</span></a> <span class="n">lock_type</span> <span class="o">=</span> <span class="s2">"FOR UPDATE"</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">"update"</span><span class="p">]</span> <span class="k">else</span> <span class="s2">"FOR SHARE"</span> -</span><span id="L-1736"><a href="#L-1736"><span class="linenos">1736</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-1737"><a href="#L-1737"><span class="linenos">1737</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" OF </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-1738"><a href="#L-1738"><span class="linenos">1738</span></a> <span class="n">wait</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">"wait"</span><span class="p">)</span> +</span><span id="L-1735"><a href="#L-1735"><span class="linenos">1735</span></a> <span class="k">def</span> <span class="nf">lock_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Lock</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1736"><a href="#L-1736"><span class="linenos">1736</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">LOCKING_READS_SUPPORTED</span><span class="p">:</span> +</span><span id="L-1737"><a href="#L-1737"><span class="linenos">1737</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Locking reads using 'FOR UPDATE/SHARE' are not supported"</span><span class="p">)</span> +</span><span id="L-1738"><a href="#L-1738"><span class="linenos">1738</span></a> <span class="k">return</span> <span class="s2">""</span> </span><span id="L-1739"><a href="#L-1739"><span class="linenos">1739</span></a> -</span><span id="L-1740"><a href="#L-1740"><span class="linenos">1740</span></a> <span class="k">if</span> <span class="n">wait</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="L-1741"><a href="#L-1741"><span class="linenos">1741</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">wait</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="p">):</span> -</span><span id="L-1742"><a href="#L-1742"><span class="linenos">1742</span></a> <span class="n">wait</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" WAIT </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">wait</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1743"><a href="#L-1743"><span class="linenos">1743</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-1744"><a href="#L-1744"><span class="linenos">1744</span></a> <span class="n">wait</span> <span class="o">=</span> <span class="s2">" NOWAIT"</span> <span class="k">if</span> <span class="n">wait</span> <span class="k">else</span> <span class="s2">" SKIP LOCKED"</span> -</span><span id="L-1745"><a href="#L-1745"><span class="linenos">1745</span></a> -</span><span id="L-1746"><a href="#L-1746"><span class="linenos">1746</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">lock_type</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}{</span><span class="n">wait</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-1747"><a href="#L-1747"><span class="linenos">1747</span></a> -</span><span id="L-1748"><a href="#L-1748"><span class="linenos">1748</span></a> <span class="k">def</span> <span class="nf">literal_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1749"><a href="#L-1749"><span class="linenos">1749</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="ow">or</span> <span class="s2">""</span> -</span><span id="L-1750"><a href="#L-1750"><span class="linenos">1750</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">is_string</span><span class="p">:</span> -</span><span id="L-1751"><a href="#L-1751"><span class="linenos">1751</span></a> <span class="n">text</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">dialect</span><span class="o">.</span><span class="n">QUOTE_START</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">escape_str</span><span class="p">(</span><span class="n">text</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">QUOTE_END</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1752"><a href="#L-1752"><span class="linenos">1752</span></a> <span class="k">return</span> <span class="n">text</span> -</span><span id="L-1753"><a href="#L-1753"><span class="linenos">1753</span></a> -</span><span id="L-1754"><a href="#L-1754"><span class="linenos">1754</span></a> <span class="k">def</span> <span class="nf">escape_str</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">text</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-1755"><a href="#L-1755"><span class="linenos">1755</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">text</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">QUOTE_END</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_escaped_quote_end</span><span class="p">)</span> -</span><span id="L-1756"><a href="#L-1756"><span class="linenos">1756</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">INVERSE_ESCAPE_SEQUENCES</span><span class="p">:</span> -</span><span id="L-1757"><a href="#L-1757"><span class="linenos">1757</span></a> <span class="n">text</span> <span class="o">=</span> <span class="s2">""</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">INVERSE_ESCAPE_SEQUENCES</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">ch</span><span class="p">,</span> <span class="n">ch</span><span class="p">)</span> <span class="k">for</span> <span class="n">ch</span> <span class="ow">in</span> <span class="n">text</span><span class="p">)</span> -</span><span id="L-1758"><a href="#L-1758"><span class="linenos">1758</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span><span class="p">:</span> -</span><span id="L-1759"><a href="#L-1759"><span class="linenos">1759</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">text</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">SENTINEL_LINE_BREAK</span><span class="p">)</span> -</span><span id="L-1760"><a href="#L-1760"><span class="linenos">1760</span></a> <span class="k">return</span> <span class="n">text</span> -</span><span id="L-1761"><a href="#L-1761"><span class="linenos">1761</span></a> -</span><span id="L-1762"><a href="#L-1762"><span class="linenos">1762</span></a> <span class="k">def</span> <span class="nf">loaddata_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">LoadData</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1763"><a href="#L-1763"><span class="linenos">1763</span></a> <span class="n">local</span> <span class="o">=</span> <span class="s2">" LOCAL"</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">"local"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1764"><a href="#L-1764"><span class="linenos">1764</span></a> <span class="n">inpath</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" INPATH </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">'inpath'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1765"><a href="#L-1765"><span class="linenos">1765</span></a> <span class="n">overwrite</span> <span class="o">=</span> <span class="s2">" OVERWRITE"</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">"overwrite"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1766"><a href="#L-1766"><span class="linenos">1766</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" INTO TABLE </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-1767"><a href="#L-1767"><span class="linenos">1767</span></a> <span class="n">partition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"partition"</span><span class="p">)</span> -</span><span id="L-1768"><a href="#L-1768"><span class="linenos">1768</span></a> <span class="n">partition</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">partition</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">partition</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1769"><a href="#L-1769"><span class="linenos">1769</span></a> <span class="n">input_format</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"input_format"</span><span class="p">)</span> -</span><span id="L-1770"><a href="#L-1770"><span class="linenos">1770</span></a> <span class="n">input_format</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" INPUTFORMAT </span><span class="si">{</span><span class="n">input_format</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">input_format</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1771"><a href="#L-1771"><span class="linenos">1771</span></a> <span class="n">serde</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"serde"</span><span class="p">)</span> -</span><span id="L-1772"><a href="#L-1772"><span class="linenos">1772</span></a> <span class="n">serde</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" SERDE </span><span class="si">{</span><span class="n">serde</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">serde</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1773"><a href="#L-1773"><span class="linenos">1773</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"LOAD DATA</span><span class="si">{</span><span class="n">local</span><span class="si">}{</span><span class="n">inpath</span><span class="si">}{</span><span class="n">overwrite</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="n">partition</span><span class="si">}{</span><span class="n">input_format</span><span class="si">}{</span><span class="n">serde</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1774"><a href="#L-1774"><span class="linenos">1774</span></a> -</span><span id="L-1775"><a href="#L-1775"><span class="linenos">1775</span></a> <span class="k">def</span> <span class="nf">null_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">_</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1776"><a href="#L-1776"><span class="linenos">1776</span></a> <span class="k">return</span> <span class="s2">"NULL"</span> -</span><span id="L-1777"><a href="#L-1777"><span class="linenos">1777</span></a> -</span><span id="L-1778"><a href="#L-1778"><span class="linenos">1778</span></a> <span class="k">def</span> <span class="nf">boolean_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</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 class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1779"><a href="#L-1779"><span class="linenos">1779</span></a> <span class="k">return</span> <span class="s2">"TRUE"</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">"FALSE"</span> -</span><span id="L-1780"><a href="#L-1780"><span class="linenos">1780</span></a> -</span><span id="L-1781"><a href="#L-1781"><span class="linenos">1781</span></a> <span class="k">def</span> <span class="nf">order_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Order</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-1782"><a href="#L-1782"><span class="linenos">1782</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-1783"><a href="#L-1783"><span class="linenos">1783</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="n">this</span> -</span><span id="L-1784"><a href="#L-1784"><span class="linenos">1784</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">op_expressions</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="s2">ORDER BY"</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">this</span> <span class="ow">or</span> <span class="n">flat</span><span class="p">)</span> <span class="c1"># type: ignore</span> +</span><span id="L-1740"><a href="#L-1740"><span class="linenos">1740</span></a> <span class="n">lock_type</span> <span class="o">=</span> <span class="s2">"FOR UPDATE"</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">"update"</span><span class="p">]</span> <span class="k">else</span> <span class="s2">"FOR SHARE"</span> +</span><span id="L-1741"><a href="#L-1741"><span class="linenos">1741</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-1742"><a href="#L-1742"><span class="linenos">1742</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" OF </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-1743"><a href="#L-1743"><span class="linenos">1743</span></a> <span class="n">wait</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">"wait"</span><span class="p">)</span> +</span><span id="L-1744"><a href="#L-1744"><span class="linenos">1744</span></a> +</span><span id="L-1745"><a href="#L-1745"><span class="linenos">1745</span></a> <span class="k">if</span> <span class="n">wait</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-1746"><a href="#L-1746"><span class="linenos">1746</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">wait</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="p">):</span> +</span><span id="L-1747"><a href="#L-1747"><span class="linenos">1747</span></a> <span class="n">wait</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" WAIT </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">wait</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1748"><a href="#L-1748"><span class="linenos">1748</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-1749"><a href="#L-1749"><span class="linenos">1749</span></a> <span class="n">wait</span> <span class="o">=</span> <span class="s2">" NOWAIT"</span> <span class="k">if</span> <span class="n">wait</span> <span class="k">else</span> <span class="s2">" SKIP LOCKED"</span> +</span><span id="L-1750"><a href="#L-1750"><span class="linenos">1750</span></a> +</span><span id="L-1751"><a href="#L-1751"><span class="linenos">1751</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">lock_type</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}{</span><span class="n">wait</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-1752"><a href="#L-1752"><span class="linenos">1752</span></a> +</span><span id="L-1753"><a href="#L-1753"><span class="linenos">1753</span></a> <span class="k">def</span> <span class="nf">literal_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1754"><a href="#L-1754"><span class="linenos">1754</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="ow">or</span> <span class="s2">""</span> +</span><span id="L-1755"><a href="#L-1755"><span class="linenos">1755</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">is_string</span><span class="p">:</span> +</span><span id="L-1756"><a href="#L-1756"><span class="linenos">1756</span></a> <span class="n">text</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">dialect</span><span class="o">.</span><span class="n">QUOTE_START</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">escape_str</span><span class="p">(</span><span class="n">text</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">QUOTE_END</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1757"><a href="#L-1757"><span class="linenos">1757</span></a> <span class="k">return</span> <span class="n">text</span> +</span><span id="L-1758"><a href="#L-1758"><span class="linenos">1758</span></a> +</span><span id="L-1759"><a href="#L-1759"><span class="linenos">1759</span></a> <span class="k">def</span> <span class="nf">escape_str</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">text</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-1760"><a href="#L-1760"><span class="linenos">1760</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">text</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">QUOTE_END</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_escaped_quote_end</span><span class="p">)</span> +</span><span id="L-1761"><a href="#L-1761"><span class="linenos">1761</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">INVERSE_ESCAPE_SEQUENCES</span><span class="p">:</span> +</span><span id="L-1762"><a href="#L-1762"><span class="linenos">1762</span></a> <span class="n">text</span> <span class="o">=</span> <span class="s2">""</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">INVERSE_ESCAPE_SEQUENCES</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">ch</span><span class="p">,</span> <span class="n">ch</span><span class="p">)</span> <span class="k">for</span> <span class="n">ch</span> <span class="ow">in</span> <span class="n">text</span><span class="p">)</span> +</span><span id="L-1763"><a href="#L-1763"><span class="linenos">1763</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span><span class="p">:</span> +</span><span id="L-1764"><a href="#L-1764"><span class="linenos">1764</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">text</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">SENTINEL_LINE_BREAK</span><span class="p">)</span> +</span><span id="L-1765"><a href="#L-1765"><span class="linenos">1765</span></a> <span class="k">return</span> <span class="n">text</span> +</span><span id="L-1766"><a href="#L-1766"><span class="linenos">1766</span></a> +</span><span id="L-1767"><a href="#L-1767"><span class="linenos">1767</span></a> <span class="k">def</span> <span class="nf">loaddata_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">LoadData</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1768"><a href="#L-1768"><span class="linenos">1768</span></a> <span class="n">local</span> <span class="o">=</span> <span class="s2">" LOCAL"</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">"local"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1769"><a href="#L-1769"><span class="linenos">1769</span></a> <span class="n">inpath</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" INPATH </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">'inpath'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1770"><a href="#L-1770"><span class="linenos">1770</span></a> <span class="n">overwrite</span> <span class="o">=</span> <span class="s2">" OVERWRITE"</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">"overwrite"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1771"><a href="#L-1771"><span class="linenos">1771</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" INTO TABLE </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-1772"><a href="#L-1772"><span class="linenos">1772</span></a> <span class="n">partition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"partition"</span><span class="p">)</span> +</span><span id="L-1773"><a href="#L-1773"><span class="linenos">1773</span></a> <span class="n">partition</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">partition</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">partition</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1774"><a href="#L-1774"><span class="linenos">1774</span></a> <span class="n">input_format</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"input_format"</span><span class="p">)</span> +</span><span id="L-1775"><a href="#L-1775"><span class="linenos">1775</span></a> <span class="n">input_format</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" INPUTFORMAT </span><span class="si">{</span><span class="n">input_format</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">input_format</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1776"><a href="#L-1776"><span class="linenos">1776</span></a> <span class="n">serde</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"serde"</span><span class="p">)</span> +</span><span id="L-1777"><a href="#L-1777"><span class="linenos">1777</span></a> <span class="n">serde</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" SERDE </span><span class="si">{</span><span class="n">serde</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">serde</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1778"><a href="#L-1778"><span class="linenos">1778</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"LOAD DATA</span><span class="si">{</span><span class="n">local</span><span class="si">}{</span><span class="n">inpath</span><span class="si">}{</span><span class="n">overwrite</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="n">partition</span><span class="si">}{</span><span class="n">input_format</span><span class="si">}{</span><span class="n">serde</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1779"><a href="#L-1779"><span class="linenos">1779</span></a> +</span><span id="L-1780"><a href="#L-1780"><span class="linenos">1780</span></a> <span class="k">def</span> <span class="nf">null_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">_</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1781"><a href="#L-1781"><span class="linenos">1781</span></a> <span class="k">return</span> <span class="s2">"NULL"</span> +</span><span id="L-1782"><a href="#L-1782"><span class="linenos">1782</span></a> +</span><span id="L-1783"><a href="#L-1783"><span class="linenos">1783</span></a> <span class="k">def</span> <span class="nf">boolean_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</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 class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1784"><a href="#L-1784"><span class="linenos">1784</span></a> <span class="k">return</span> <span class="s2">"TRUE"</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">"FALSE"</span> </span><span id="L-1785"><a href="#L-1785"><span class="linenos">1785</span></a> -</span><span id="L-1786"><a href="#L-1786"><span class="linenos">1786</span></a> <span class="k">def</span> <span class="nf">cluster_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cluster</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1787"><a href="#L-1787"><span class="linenos">1787</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">op_expressions</span><span class="p">(</span><span class="s2">"CLUSTER BY"</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> -</span><span id="L-1788"><a href="#L-1788"><span class="linenos">1788</span></a> -</span><span id="L-1789"><a href="#L-1789"><span class="linenos">1789</span></a> <span class="k">def</span> <span class="nf">distribute_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Distribute</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1790"><a href="#L-1790"><span class="linenos">1790</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">op_expressions</span><span class="p">(</span><span class="s2">"DISTRIBUTE BY"</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> -</span><span id="L-1791"><a href="#L-1791"><span class="linenos">1791</span></a> -</span><span id="L-1792"><a href="#L-1792"><span class="linenos">1792</span></a> <span class="k">def</span> <span class="nf">sort_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Sort</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1793"><a href="#L-1793"><span class="linenos">1793</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">op_expressions</span><span class="p">(</span><span class="s2">"SORT BY"</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> -</span><span id="L-1794"><a href="#L-1794"><span class="linenos">1794</span></a> -</span><span id="L-1795"><a href="#L-1795"><span class="linenos">1795</span></a> <span class="k">def</span> <span class="nf">ordered_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Ordered</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1796"><a href="#L-1796"><span class="linenos">1796</span></a> <span class="n">desc</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">"desc"</span><span class="p">)</span> -</span><span id="L-1797"><a href="#L-1797"><span class="linenos">1797</span></a> <span class="n">asc</span> <span class="o">=</span> <span class="ow">not</span> <span class="n">desc</span> -</span><span id="L-1798"><a href="#L-1798"><span class="linenos">1798</span></a> -</span><span id="L-1799"><a href="#L-1799"><span class="linenos">1799</span></a> <span class="n">nulls_first</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">"nulls_first"</span><span class="p">)</span> -</span><span id="L-1800"><a href="#L-1800"><span class="linenos">1800</span></a> <span class="n">nulls_last</span> <span class="o">=</span> <span class="ow">not</span> <span class="n">nulls_first</span> -</span><span id="L-1801"><a href="#L-1801"><span class="linenos">1801</span></a> <span class="n">nulls_are_large</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">NULL_ORDERING</span> <span class="o">==</span> <span class="s2">"nulls_are_large"</span> -</span><span id="L-1802"><a href="#L-1802"><span class="linenos">1802</span></a> <span class="n">nulls_are_small</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">NULL_ORDERING</span> <span class="o">==</span> <span class="s2">"nulls_are_small"</span> -</span><span id="L-1803"><a href="#L-1803"><span class="linenos">1803</span></a> <span class="n">nulls_are_last</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">NULL_ORDERING</span> <span class="o">==</span> <span class="s2">"nulls_are_last"</span> -</span><span id="L-1804"><a href="#L-1804"><span class="linenos">1804</span></a> -</span><span id="L-1805"><a href="#L-1805"><span class="linenos">1805</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-1806"><a href="#L-1806"><span class="linenos">1806</span></a> -</span><span id="L-1807"><a href="#L-1807"><span class="linenos">1807</span></a> <span class="n">sort_order</span> <span class="o">=</span> <span class="s2">" DESC"</span> <span class="k">if</span> <span class="n">desc</span> <span class="k">else</span> <span class="p">(</span><span class="s2">" ASC"</span> <span class="k">if</span> <span class="n">desc</span> <span class="ow">is</span> <span class="kc">False</span> <span class="k">else</span> <span class="s2">""</span><span class="p">)</span> -</span><span id="L-1808"><a href="#L-1808"><span class="linenos">1808</span></a> <span class="n">nulls_sort_change</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="L-1809"><a href="#L-1809"><span class="linenos">1809</span></a> <span class="k">if</span> <span class="n">nulls_first</span> <span class="ow">and</span> <span class="p">(</span> -</span><span id="L-1810"><a href="#L-1810"><span class="linenos">1810</span></a> <span class="p">(</span><span class="n">asc</span> <span class="ow">and</span> <span class="n">nulls_are_large</span><span class="p">)</span> <span class="ow">or</span> <span class="p">(</span><span class="n">desc</span> <span class="ow">and</span> <span class="n">nulls_are_small</span><span class="p">)</span> <span class="ow">or</span> <span class="n">nulls_are_last</span> -</span><span id="L-1811"><a href="#L-1811"><span class="linenos">1811</span></a> <span class="p">):</span> -</span><span id="L-1812"><a href="#L-1812"><span class="linenos">1812</span></a> <span class="n">nulls_sort_change</span> <span class="o">=</span> <span class="s2">" NULLS FIRST"</span> -</span><span id="L-1813"><a href="#L-1813"><span class="linenos">1813</span></a> <span class="k">elif</span> <span class="p">(</span> -</span><span id="L-1814"><a href="#L-1814"><span class="linenos">1814</span></a> <span class="n">nulls_last</span> -</span><span id="L-1815"><a href="#L-1815"><span class="linenos">1815</span></a> <span class="ow">and</span> <span class="p">((</span><span class="n">asc</span> <span class="ow">and</span> <span class="n">nulls_are_small</span><span class="p">)</span> <span class="ow">or</span> <span class="p">(</span><span class="n">desc</span> <span class="ow">and</span> <span class="n">nulls_are_large</span><span class="p">))</span> -</span><span id="L-1816"><a href="#L-1816"><span class="linenos">1816</span></a> <span class="ow">and</span> <span class="ow">not</span> <span class="n">nulls_are_last</span> -</span><span id="L-1817"><a href="#L-1817"><span class="linenos">1817</span></a> <span class="p">):</span> -</span><span id="L-1818"><a href="#L-1818"><span class="linenos">1818</span></a> <span class="n">nulls_sort_change</span> <span class="o">=</span> <span class="s2">" NULLS LAST"</span> -</span><span id="L-1819"><a href="#L-1819"><span class="linenos">1819</span></a> -</span><span id="L-1820"><a href="#L-1820"><span class="linenos">1820</span></a> <span class="c1"># If the NULLS FIRST/LAST clause is unsupported, we add another sort key to simulate it</span> -</span><span id="L-1821"><a href="#L-1821"><span class="linenos">1821</span></a> <span class="k">if</span> <span class="n">nulls_sort_change</span> <span class="ow">and</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">NULL_ORDERING_SUPPORTED</span><span class="p">:</span> -</span><span id="L-1822"><a href="#L-1822"><span class="linenos">1822</span></a> <span class="n">null_sort_order</span> <span class="o">=</span> <span class="s2">" DESC"</span> <span class="k">if</span> <span class="n">nulls_sort_change</span> <span class="o">==</span> <span class="s2">" NULLS FIRST"</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1823"><a href="#L-1823"><span class="linenos">1823</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"CASE WHEN </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> IS NULL THEN 1 ELSE 0 END</span><span class="si">{</span><span class="n">null_sort_order</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">"</span> -</span><span id="L-1824"><a href="#L-1824"><span class="linenos">1824</span></a> <span class="n">nulls_sort_change</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="L-1825"><a href="#L-1825"><span class="linenos">1825</span></a> -</span><span id="L-1826"><a href="#L-1826"><span class="linenos">1826</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">sort_order</span><span class="si">}{</span><span class="n">nulls_sort_change</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1827"><a href="#L-1827"><span class="linenos">1827</span></a> -</span><span id="L-1828"><a href="#L-1828"><span class="linenos">1828</span></a> <span class="k">def</span> <span class="nf">matchrecognize_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">MatchRecognize</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1829"><a href="#L-1829"><span class="linenos">1829</span></a> <span class="n">partition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">partition_by_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="L-1830"><a href="#L-1830"><span class="linenos">1830</span></a> <span class="n">order</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"order"</span><span class="p">)</span> -</span><span id="L-1831"><a href="#L-1831"><span class="linenos">1831</span></a> <span class="n">measures</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">"measures"</span><span class="p">)</span> -</span><span id="L-1832"><a href="#L-1832"><span class="linenos">1832</span></a> <span class="n">measures</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="sa">f</span><span class="s2">"MEASURES</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">measures</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> <span class="k">if</span> <span class="n">measures</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1833"><a href="#L-1833"><span class="linenos">1833</span></a> <span class="n">rows</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"rows"</span><span class="p">)</span> -</span><span id="L-1834"><a href="#L-1834"><span class="linenos">1834</span></a> <span class="n">rows</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">rows</span><span class="p">)</span> <span class="k">if</span> <span class="n">rows</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1835"><a href="#L-1835"><span class="linenos">1835</span></a> <span class="n">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">"after"</span><span class="p">)</span> -</span><span id="L-1836"><a href="#L-1836"><span class="linenos">1836</span></a> <span class="n">after</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">after</span><span class="p">)</span> <span class="k">if</span> <span class="n">after</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1837"><a href="#L-1837"><span class="linenos">1837</span></a> <span class="n">pattern</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"pattern"</span><span class="p">)</span> -</span><span id="L-1838"><a href="#L-1838"><span class="linenos">1838</span></a> <span class="n">pattern</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="sa">f</span><span class="s2">"PATTERN (</span><span class="si">{</span><span class="n">pattern</span><span class="si">}</span><span class="s2">)"</span><span class="p">)</span> <span class="k">if</span> <span class="n">pattern</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1839"><a href="#L-1839"><span class="linenos">1839</span></a> <span class="n">definition_sqls</span> <span class="o">=</span> <span class="p">[</span> -</span><span id="L-1840"><a href="#L-1840"><span class="linenos">1840</span></a> <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">definition</span><span class="p">,</span><span class="w"> </span><span class="s1">'alias'</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">definition</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-1841"><a href="#L-1841"><span class="linenos">1841</span></a> <span class="k">for</span> <span class="n">definition</span> <span class="ow">in</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">"define"</span><span class="p">,</span> <span class="p">[])</span> -</span><span id="L-1842"><a href="#L-1842"><span class="linenos">1842</span></a> <span class="p">]</span> -</span><span id="L-1843"><a href="#L-1843"><span class="linenos">1843</span></a> <span class="n">definitions</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">sqls</span><span class="o">=</span><span class="n">definition_sqls</span><span class="p">)</span> -</span><span id="L-1844"><a href="#L-1844"><span class="linenos">1844</span></a> <span class="n">define</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="sa">f</span><span class="s2">"DEFINE</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">definitions</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> <span class="k">if</span> <span class="n">definitions</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1845"><a href="#L-1845"><span class="linenos">1845</span></a> <span class="n">body</span> <span class="o">=</span> <span class="s2">""</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> -</span><span id="L-1846"><a href="#L-1846"><span class="linenos">1846</span></a> <span class="p">(</span> -</span><span id="L-1847"><a href="#L-1847"><span class="linenos">1847</span></a> <span class="n">partition</span><span class="p">,</span> -</span><span id="L-1848"><a href="#L-1848"><span class="linenos">1848</span></a> <span class="n">order</span><span class="p">,</span> -</span><span id="L-1849"><a href="#L-1849"><span class="linenos">1849</span></a> <span class="n">measures</span><span class="p">,</span> -</span><span id="L-1850"><a href="#L-1850"><span class="linenos">1850</span></a> <span class="n">rows</span><span class="p">,</span> -</span><span id="L-1851"><a href="#L-1851"><span class="linenos">1851</span></a> <span class="n">after</span><span class="p">,</span> -</span><span id="L-1852"><a href="#L-1852"><span class="linenos">1852</span></a> <span class="n">pattern</span><span class="p">,</span> -</span><span id="L-1853"><a href="#L-1853"><span class="linenos">1853</span></a> <span class="n">define</span><span class="p">,</span> -</span><span id="L-1854"><a href="#L-1854"><span class="linenos">1854</span></a> <span class="p">)</span> -</span><span id="L-1855"><a href="#L-1855"><span class="linenos">1855</span></a> <span class="p">)</span> -</span><span id="L-1856"><a href="#L-1856"><span class="linenos">1856</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-1857"><a href="#L-1857"><span class="linenos">1857</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </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-1858"><a href="#L-1858"><span class="linenos">1858</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="s1">'MATCH_RECOGNIZE'</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">wrap</span><span class="p">(</span><span class="n">body</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-1859"><a href="#L-1859"><span class="linenos">1859</span></a> -</span><span id="L-1860"><a href="#L-1860"><span class="linenos">1860</span></a> <span class="k">def</span> <span class="nf">query_modifiers</span><span class="p">(</span><span class="bp">self</span><span 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">sqls</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-1861"><a href="#L-1861"><span class="linenos">1861</span></a> <span class="n">limit</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">Fetch</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">]</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">"limit"</span><span class="p">)</span> -</span><span id="L-1862"><a href="#L-1862"><span class="linenos">1862</span></a> -</span><span id="L-1863"><a href="#L-1863"><span class="linenos">1863</span></a> <span class="c1"># If the limit is generated as TOP, we need to ensure it's not generated twice</span> -</span><span id="L-1864"><a href="#L-1864"><span class="linenos">1864</span></a> <span class="n">with_offset_limit_modifiers</span> <span class="o">=</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">limit</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">)</span> <span class="ow">or</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">LIMIT_IS_TOP</span> -</span><span id="L-1865"><a href="#L-1865"><span class="linenos">1865</span></a> -</span><span id="L-1866"><a href="#L-1866"><span class="linenos">1866</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">LIMIT_FETCH</span> <span class="o">==</span> <span class="s2">"LIMIT"</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">limit</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span><span class="p">):</span> -</span><span id="L-1867"><a href="#L-1867"><span class="linenos">1867</span></a> <span class="n">limit</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">(</span><span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">maybe_copy</span><span class="p">(</span><span class="n">limit</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">"count"</span><span class="p">)))</span> -</span><span id="L-1868"><a href="#L-1868"><span class="linenos">1868</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">LIMIT_FETCH</span> <span class="o">==</span> <span class="s2">"FETCH"</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">limit</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">):</span> -</span><span id="L-1869"><a href="#L-1869"><span class="linenos">1869</span></a> <span class="n">limit</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span><span class="p">(</span><span class="n">direction</span><span class="o">=</span><span class="s2">"FIRST"</span><span class="p">,</span> <span class="n">count</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">maybe_copy</span><span class="p">(</span><span class="n">limit</span><span class="o">.</span><span class="n">expression</span><span class="p">))</span> +</span><span id="L-1786"><a href="#L-1786"><span class="linenos">1786</span></a> <span class="k">def</span> <span class="nf">order_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Order</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-1787"><a href="#L-1787"><span class="linenos">1787</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-1788"><a href="#L-1788"><span class="linenos">1788</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="n">this</span> +</span><span id="L-1789"><a href="#L-1789"><span class="linenos">1789</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">op_expressions</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="s2">ORDER BY"</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">this</span> <span class="ow">or</span> <span class="n">flat</span><span class="p">)</span> <span class="c1"># type: ignore</span> +</span><span id="L-1790"><a href="#L-1790"><span class="linenos">1790</span></a> +</span><span id="L-1791"><a href="#L-1791"><span class="linenos">1791</span></a> <span class="k">def</span> <span class="nf">cluster_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cluster</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1792"><a href="#L-1792"><span class="linenos">1792</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">op_expressions</span><span class="p">(</span><span class="s2">"CLUSTER BY"</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> +</span><span id="L-1793"><a href="#L-1793"><span class="linenos">1793</span></a> +</span><span id="L-1794"><a href="#L-1794"><span class="linenos">1794</span></a> <span class="k">def</span> <span class="nf">distribute_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Distribute</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1795"><a href="#L-1795"><span class="linenos">1795</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">op_expressions</span><span class="p">(</span><span class="s2">"DISTRIBUTE BY"</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> +</span><span id="L-1796"><a href="#L-1796"><span class="linenos">1796</span></a> +</span><span id="L-1797"><a href="#L-1797"><span class="linenos">1797</span></a> <span class="k">def</span> <span class="nf">sort_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Sort</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1798"><a href="#L-1798"><span class="linenos">1798</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">op_expressions</span><span class="p">(</span><span class="s2">"SORT BY"</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> +</span><span id="L-1799"><a href="#L-1799"><span class="linenos">1799</span></a> +</span><span id="L-1800"><a href="#L-1800"><span class="linenos">1800</span></a> <span class="k">def</span> <span class="nf">ordered_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Ordered</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1801"><a href="#L-1801"><span class="linenos">1801</span></a> <span class="n">desc</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">"desc"</span><span class="p">)</span> +</span><span id="L-1802"><a href="#L-1802"><span class="linenos">1802</span></a> <span class="n">asc</span> <span class="o">=</span> <span class="ow">not</span> <span class="n">desc</span> +</span><span id="L-1803"><a href="#L-1803"><span class="linenos">1803</span></a> +</span><span id="L-1804"><a href="#L-1804"><span class="linenos">1804</span></a> <span class="n">nulls_first</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">"nulls_first"</span><span class="p">)</span> +</span><span id="L-1805"><a href="#L-1805"><span class="linenos">1805</span></a> <span class="n">nulls_last</span> <span class="o">=</span> <span class="ow">not</span> <span class="n">nulls_first</span> +</span><span id="L-1806"><a href="#L-1806"><span class="linenos">1806</span></a> <span class="n">nulls_are_large</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">NULL_ORDERING</span> <span class="o">==</span> <span class="s2">"nulls_are_large"</span> +</span><span id="L-1807"><a href="#L-1807"><span class="linenos">1807</span></a> <span class="n">nulls_are_small</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">NULL_ORDERING</span> <span class="o">==</span> <span class="s2">"nulls_are_small"</span> +</span><span id="L-1808"><a href="#L-1808"><span class="linenos">1808</span></a> <span class="n">nulls_are_last</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">NULL_ORDERING</span> <span class="o">==</span> <span class="s2">"nulls_are_last"</span> +</span><span id="L-1809"><a href="#L-1809"><span class="linenos">1809</span></a> +</span><span id="L-1810"><a href="#L-1810"><span class="linenos">1810</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-1811"><a href="#L-1811"><span class="linenos">1811</span></a> +</span><span id="L-1812"><a href="#L-1812"><span class="linenos">1812</span></a> <span class="n">sort_order</span> <span class="o">=</span> <span class="s2">" DESC"</span> <span class="k">if</span> <span class="n">desc</span> <span class="k">else</span> <span class="p">(</span><span class="s2">" ASC"</span> <span class="k">if</span> <span class="n">desc</span> <span class="ow">is</span> <span class="kc">False</span> <span class="k">else</span> <span class="s2">""</span><span class="p">)</span> +</span><span id="L-1813"><a href="#L-1813"><span class="linenos">1813</span></a> <span class="n">nulls_sort_change</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="L-1814"><a href="#L-1814"><span class="linenos">1814</span></a> <span class="k">if</span> <span class="n">nulls_first</span> <span class="ow">and</span> <span class="p">(</span> +</span><span id="L-1815"><a href="#L-1815"><span class="linenos">1815</span></a> <span class="p">(</span><span class="n">asc</span> <span class="ow">and</span> <span class="n">nulls_are_large</span><span class="p">)</span> <span class="ow">or</span> <span class="p">(</span><span class="n">desc</span> <span class="ow">and</span> <span class="n">nulls_are_small</span><span class="p">)</span> <span class="ow">or</span> <span class="n">nulls_are_last</span> +</span><span id="L-1816"><a href="#L-1816"><span class="linenos">1816</span></a> <span class="p">):</span> +</span><span id="L-1817"><a href="#L-1817"><span class="linenos">1817</span></a> <span class="n">nulls_sort_change</span> <span class="o">=</span> <span class="s2">" NULLS FIRST"</span> +</span><span id="L-1818"><a href="#L-1818"><span class="linenos">1818</span></a> <span class="k">elif</span> <span class="p">(</span> +</span><span id="L-1819"><a href="#L-1819"><span class="linenos">1819</span></a> <span class="n">nulls_last</span> +</span><span id="L-1820"><a href="#L-1820"><span class="linenos">1820</span></a> <span class="ow">and</span> <span class="p">((</span><span class="n">asc</span> <span class="ow">and</span> <span class="n">nulls_are_small</span><span class="p">)</span> <span class="ow">or</span> <span class="p">(</span><span class="n">desc</span> <span class="ow">and</span> <span class="n">nulls_are_large</span><span class="p">))</span> +</span><span id="L-1821"><a href="#L-1821"><span class="linenos">1821</span></a> <span class="ow">and</span> <span class="ow">not</span> <span class="n">nulls_are_last</span> +</span><span id="L-1822"><a href="#L-1822"><span class="linenos">1822</span></a> <span class="p">):</span> +</span><span id="L-1823"><a href="#L-1823"><span class="linenos">1823</span></a> <span class="n">nulls_sort_change</span> <span class="o">=</span> <span class="s2">" NULLS LAST"</span> +</span><span id="L-1824"><a href="#L-1824"><span class="linenos">1824</span></a> +</span><span id="L-1825"><a href="#L-1825"><span class="linenos">1825</span></a> <span class="c1"># If the NULLS FIRST/LAST clause is unsupported, we add another sort key to simulate it</span> +</span><span id="L-1826"><a href="#L-1826"><span class="linenos">1826</span></a> <span class="k">if</span> <span class="n">nulls_sort_change</span> <span class="ow">and</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">NULL_ORDERING_SUPPORTED</span><span class="p">:</span> +</span><span id="L-1827"><a href="#L-1827"><span class="linenos">1827</span></a> <span class="n">null_sort_order</span> <span class="o">=</span> <span class="s2">" DESC"</span> <span class="k">if</span> <span class="n">nulls_sort_change</span> <span class="o">==</span> <span class="s2">" NULLS FIRST"</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1828"><a href="#L-1828"><span class="linenos">1828</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"CASE WHEN </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> IS NULL THEN 1 ELSE 0 END</span><span class="si">{</span><span class="n">null_sort_order</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">"</span> +</span><span id="L-1829"><a href="#L-1829"><span class="linenos">1829</span></a> <span class="n">nulls_sort_change</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="L-1830"><a href="#L-1830"><span class="linenos">1830</span></a> +</span><span id="L-1831"><a href="#L-1831"><span class="linenos">1831</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">sort_order</span><span class="si">}{</span><span class="n">nulls_sort_change</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1832"><a href="#L-1832"><span class="linenos">1832</span></a> +</span><span id="L-1833"><a href="#L-1833"><span class="linenos">1833</span></a> <span class="k">def</span> <span class="nf">matchrecognize_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">MatchRecognize</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1834"><a href="#L-1834"><span class="linenos">1834</span></a> <span class="n">partition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">partition_by_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-1835"><a href="#L-1835"><span class="linenos">1835</span></a> <span class="n">order</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"order"</span><span class="p">)</span> +</span><span id="L-1836"><a href="#L-1836"><span class="linenos">1836</span></a> <span class="n">measures</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">"measures"</span><span class="p">)</span> +</span><span id="L-1837"><a href="#L-1837"><span class="linenos">1837</span></a> <span class="n">measures</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="sa">f</span><span class="s2">"MEASURES</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">measures</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> <span class="k">if</span> <span class="n">measures</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1838"><a href="#L-1838"><span class="linenos">1838</span></a> <span class="n">rows</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"rows"</span><span class="p">)</span> +</span><span id="L-1839"><a href="#L-1839"><span class="linenos">1839</span></a> <span class="n">rows</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">rows</span><span class="p">)</span> <span class="k">if</span> <span class="n">rows</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1840"><a href="#L-1840"><span class="linenos">1840</span></a> <span class="n">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">"after"</span><span class="p">)</span> +</span><span id="L-1841"><a href="#L-1841"><span class="linenos">1841</span></a> <span class="n">after</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">after</span><span class="p">)</span> <span class="k">if</span> <span class="n">after</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1842"><a href="#L-1842"><span class="linenos">1842</span></a> <span class="n">pattern</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"pattern"</span><span class="p">)</span> +</span><span id="L-1843"><a href="#L-1843"><span class="linenos">1843</span></a> <span class="n">pattern</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="sa">f</span><span class="s2">"PATTERN (</span><span class="si">{</span><span class="n">pattern</span><span class="si">}</span><span class="s2">)"</span><span class="p">)</span> <span class="k">if</span> <span class="n">pattern</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1844"><a href="#L-1844"><span class="linenos">1844</span></a> <span class="n">definition_sqls</span> <span class="o">=</span> <span class="p">[</span> +</span><span id="L-1845"><a href="#L-1845"><span class="linenos">1845</span></a> <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">definition</span><span class="p">,</span><span class="w"> </span><span class="s1">'alias'</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">definition</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-1846"><a href="#L-1846"><span class="linenos">1846</span></a> <span class="k">for</span> <span class="n">definition</span> <span class="ow">in</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">"define"</span><span class="p">,</span> <span class="p">[])</span> +</span><span id="L-1847"><a href="#L-1847"><span class="linenos">1847</span></a> <span class="p">]</span> +</span><span id="L-1848"><a href="#L-1848"><span class="linenos">1848</span></a> <span class="n">definitions</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">sqls</span><span class="o">=</span><span class="n">definition_sqls</span><span class="p">)</span> +</span><span id="L-1849"><a href="#L-1849"><span class="linenos">1849</span></a> <span class="n">define</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="sa">f</span><span class="s2">"DEFINE</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">definitions</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> <span class="k">if</span> <span class="n">definitions</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1850"><a href="#L-1850"><span class="linenos">1850</span></a> <span class="n">body</span> <span class="o">=</span> <span class="s2">""</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> +</span><span id="L-1851"><a href="#L-1851"><span class="linenos">1851</span></a> <span class="p">(</span> +</span><span id="L-1852"><a href="#L-1852"><span class="linenos">1852</span></a> <span class="n">partition</span><span class="p">,</span> +</span><span id="L-1853"><a href="#L-1853"><span class="linenos">1853</span></a> <span class="n">order</span><span class="p">,</span> +</span><span id="L-1854"><a href="#L-1854"><span class="linenos">1854</span></a> <span class="n">measures</span><span class="p">,</span> +</span><span id="L-1855"><a href="#L-1855"><span class="linenos">1855</span></a> <span class="n">rows</span><span class="p">,</span> +</span><span id="L-1856"><a href="#L-1856"><span class="linenos">1856</span></a> <span class="n">after</span><span class="p">,</span> +</span><span id="L-1857"><a href="#L-1857"><span class="linenos">1857</span></a> <span class="n">pattern</span><span class="p">,</span> +</span><span id="L-1858"><a href="#L-1858"><span class="linenos">1858</span></a> <span class="n">define</span><span class="p">,</span> +</span><span id="L-1859"><a href="#L-1859"><span class="linenos">1859</span></a> <span class="p">)</span> +</span><span id="L-1860"><a href="#L-1860"><span class="linenos">1860</span></a> <span class="p">)</span> +</span><span id="L-1861"><a href="#L-1861"><span class="linenos">1861</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-1862"><a href="#L-1862"><span class="linenos">1862</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </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-1863"><a href="#L-1863"><span class="linenos">1863</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="s1">'MATCH_RECOGNIZE'</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">wrap</span><span class="p">(</span><span class="n">body</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-1864"><a href="#L-1864"><span class="linenos">1864</span></a> +</span><span id="L-1865"><a href="#L-1865"><span class="linenos">1865</span></a> <span class="k">def</span> <span class="nf">query_modifiers</span><span class="p">(</span><span class="bp">self</span><span 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">sqls</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-1866"><a href="#L-1866"><span class="linenos">1866</span></a> <span class="n">limit</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">Fetch</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">]</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">"limit"</span><span class="p">)</span> +</span><span id="L-1867"><a href="#L-1867"><span class="linenos">1867</span></a> +</span><span id="L-1868"><a href="#L-1868"><span class="linenos">1868</span></a> <span class="c1"># If the limit is generated as TOP, we need to ensure it's not generated twice</span> +</span><span id="L-1869"><a href="#L-1869"><span class="linenos">1869</span></a> <span class="n">with_offset_limit_modifiers</span> <span class="o">=</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">limit</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">)</span> <span class="ow">or</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">LIMIT_IS_TOP</span> </span><span id="L-1870"><a href="#L-1870"><span class="linenos">1870</span></a> -</span><span id="L-1871"><a href="#L-1871"><span class="linenos">1871</span></a> <span class="n">fetch</span> <span class="o">=</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">limit</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span><span class="p">)</span> -</span><span id="L-1872"><a href="#L-1872"><span class="linenos">1872</span></a> -</span><span id="L-1873"><a href="#L-1873"><span class="linenos">1873</span></a> <span class="n">offset_limit_modifiers</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="L-1874"><a href="#L-1874"><span class="linenos">1874</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">offset_limit_modifiers</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">fetch</span><span class="p">,</span> <span class="n">limit</span><span class="p">)</span> -</span><span id="L-1875"><a href="#L-1875"><span class="linenos">1875</span></a> <span class="k">if</span> <span class="n">with_offset_limit_modifiers</span> -</span><span id="L-1876"><a href="#L-1876"><span class="linenos">1876</span></a> <span class="k">else</span> <span class="p">[]</span> -</span><span id="L-1877"><a href="#L-1877"><span class="linenos">1877</span></a> <span class="p">)</span> -</span><span id="L-1878"><a href="#L-1878"><span class="linenos">1878</span></a> -</span><span id="L-1879"><a href="#L-1879"><span class="linenos">1879</span></a> <span class="k">return</span> <span class="n">csv</span><span class="p">(</span> -</span><span id="L-1880"><a href="#L-1880"><span class="linenos">1880</span></a> <span class="o">*</span><span class="n">sqls</span><span class="p">,</span> -</span><span id="L-1881"><a href="#L-1881"><span class="linenos">1881</span></a> <span class="o">*</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">join</span><span class="p">)</span> <span class="k">for</span> <span class="n">join</span> <span class="ow">in</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">"joins"</span><span class="p">)</span> <span class="ow">or</span> <span class="p">[]],</span> -</span><span id="L-1882"><a href="#L-1882"><span class="linenos">1882</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">"connect"</span><span class="p">),</span> -</span><span id="L-1883"><a href="#L-1883"><span class="linenos">1883</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">"match"</span><span class="p">),</span> -</span><span id="L-1884"><a href="#L-1884"><span class="linenos">1884</span></a> <span class="o">*</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">lateral</span><span class="p">)</span> <span class="k">for</span> <span class="n">lateral</span> <span class="ow">in</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">"laterals"</span><span class="p">)</span> <span class="ow">or</span> <span class="p">[]],</span> -</span><span id="L-1885"><a href="#L-1885"><span class="linenos">1885</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">"where"</span><span class="p">),</span> -</span><span id="L-1886"><a href="#L-1886"><span class="linenos">1886</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">"group"</span><span class="p">),</span> -</span><span id="L-1887"><a href="#L-1887"><span class="linenos">1887</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">"having"</span><span class="p">),</span> -</span><span id="L-1888"><a href="#L-1888"><span class="linenos">1888</span></a> <span class="o">*</span><span class="bp">self</span><span class="o">.</span><span class="n">after_having_modifiers</span><span class="p">(</span><span class="n">expression</span><span class="p">),</span> -</span><span id="L-1889"><a href="#L-1889"><span class="linenos">1889</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">"order"</span><span class="p">),</span> -</span><span id="L-1890"><a href="#L-1890"><span class="linenos">1890</span></a> <span class="o">*</span><span class="n">offset_limit_modifiers</span><span class="p">,</span> -</span><span id="L-1891"><a href="#L-1891"><span class="linenos">1891</span></a> <span class="o">*</span><span class="bp">self</span><span class="o">.</span><span class="n">after_limit_modifiers</span><span class="p">(</span><span class="n">expression</span><span class="p">),</span> -</span><span id="L-1892"><a href="#L-1892"><span class="linenos">1892</span></a> <span class="n">sep</span><span class="o">=</span><span class="s2">""</span><span class="p">,</span> -</span><span id="L-1893"><a href="#L-1893"><span class="linenos">1893</span></a> <span class="p">)</span> -</span><span id="L-1894"><a href="#L-1894"><span class="linenos">1894</span></a> -</span><span id="L-1895"><a href="#L-1895"><span class="linenos">1895</span></a> <span class="k">def</span> <span class="nf">offset_limit_modifiers</span><span class="p">(</span> -</span><span id="L-1896"><a href="#L-1896"><span class="linenos">1896</span></a> <span class="bp">self</span><span 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">fetch</span><span class="p">:</span> <span class="nb">bool</span><span class="p">,</span> <span class="n">limit</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">Fetch</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">]</span> -</span><span id="L-1897"><a href="#L-1897"><span class="linenos">1897</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> -</span><span id="L-1898"><a href="#L-1898"><span class="linenos">1898</span></a> <span class="k">return</span> <span class="p">[</span> -</span><span id="L-1899"><a href="#L-1899"><span class="linenos">1899</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">"offset"</span><span class="p">)</span> <span class="k">if</span> <span class="n">fetch</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">limit</span><span class="p">),</span> -</span><span id="L-1900"><a href="#L-1900"><span class="linenos">1900</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">limit</span><span class="p">)</span> <span class="k">if</span> <span class="n">fetch</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">expression</span><span class="p">,</span> <span class="s2">"offset"</span><span class="p">),</span> -</span><span id="L-1901"><a href="#L-1901"><span class="linenos">1901</span></a> <span class="p">]</span> -</span><span id="L-1902"><a href="#L-1902"><span class="linenos">1902</span></a> -</span><span id="L-1903"><a href="#L-1903"><span class="linenos">1903</span></a> <span class="k">def</span> <span class="nf">after_having_modifiers</span><span class="p">(</span><span class="bp">self</span><span 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">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> -</span><span id="L-1904"><a href="#L-1904"><span class="linenos">1904</span></a> <span class="k">return</span> <span class="p">[</span> -</span><span id="L-1905"><a href="#L-1905"><span class="linenos">1905</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">"qualify"</span><span class="p">),</span> -</span><span id="L-1906"><a href="#L-1906"><span class="linenos">1906</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s2">"WINDOW "</span><span class="p">)</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">"windows"</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-1907"><a href="#L-1907"><span class="linenos">1907</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">"windows"</span><span class="p">)</span> -</span><span id="L-1908"><a href="#L-1908"><span class="linenos">1908</span></a> <span class="k">else</span> <span class="s2">""</span><span class="p">,</span> -</span><span id="L-1909"><a href="#L-1909"><span class="linenos">1909</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">"distribute"</span><span class="p">),</span> -</span><span id="L-1910"><a href="#L-1910"><span class="linenos">1910</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">"sort"</span><span class="p">),</span> -</span><span id="L-1911"><a href="#L-1911"><span class="linenos">1911</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">"cluster"</span><span class="p">),</span> -</span><span id="L-1912"><a href="#L-1912"><span class="linenos">1912</span></a> <span class="p">]</span> -</span><span id="L-1913"><a href="#L-1913"><span class="linenos">1913</span></a> -</span><span id="L-1914"><a href="#L-1914"><span class="linenos">1914</span></a> <span class="k">def</span> <span class="nf">after_limit_modifiers</span><span class="p">(</span><span class="bp">self</span><span 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">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> -</span><span id="L-1915"><a href="#L-1915"><span class="linenos">1915</span></a> <span class="n">locks</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">"locks"</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-1916"><a href="#L-1916"><span class="linenos">1916</span></a> <span class="n">locks</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">locks</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">locks</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1917"><a href="#L-1917"><span class="linenos">1917</span></a> <span class="k">return</span> <span class="p">[</span><span class="n">locks</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">"sample"</span><span class="p">)]</span> +</span><span id="L-1871"><a href="#L-1871"><span class="linenos">1871</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">LIMIT_FETCH</span> <span class="o">==</span> <span class="s2">"LIMIT"</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">limit</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span><span class="p">):</span> +</span><span id="L-1872"><a href="#L-1872"><span class="linenos">1872</span></a> <span class="n">limit</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">(</span><span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">maybe_copy</span><span class="p">(</span><span class="n">limit</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">"count"</span><span class="p">)))</span> +</span><span id="L-1873"><a href="#L-1873"><span class="linenos">1873</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">LIMIT_FETCH</span> <span class="o">==</span> <span class="s2">"FETCH"</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">limit</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">):</span> +</span><span id="L-1874"><a href="#L-1874"><span class="linenos">1874</span></a> <span class="n">limit</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span><span class="p">(</span><span class="n">direction</span><span class="o">=</span><span class="s2">"FIRST"</span><span class="p">,</span> <span class="n">count</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">maybe_copy</span><span class="p">(</span><span class="n">limit</span><span class="o">.</span><span class="n">expression</span><span class="p">))</span> +</span><span id="L-1875"><a href="#L-1875"><span class="linenos">1875</span></a> +</span><span id="L-1876"><a href="#L-1876"><span class="linenos">1876</span></a> <span class="n">fetch</span> <span class="o">=</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">limit</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span><span class="p">)</span> +</span><span id="L-1877"><a href="#L-1877"><span class="linenos">1877</span></a> +</span><span id="L-1878"><a href="#L-1878"><span class="linenos">1878</span></a> <span class="n">offset_limit_modifiers</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="L-1879"><a href="#L-1879"><span class="linenos">1879</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">offset_limit_modifiers</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">fetch</span><span class="p">,</span> <span class="n">limit</span><span class="p">)</span> +</span><span id="L-1880"><a href="#L-1880"><span class="linenos">1880</span></a> <span class="k">if</span> <span class="n">with_offset_limit_modifiers</span> +</span><span id="L-1881"><a href="#L-1881"><span class="linenos">1881</span></a> <span class="k">else</span> <span class="p">[]</span> +</span><span id="L-1882"><a href="#L-1882"><span class="linenos">1882</span></a> <span class="p">)</span> +</span><span id="L-1883"><a href="#L-1883"><span class="linenos">1883</span></a> +</span><span id="L-1884"><a href="#L-1884"><span class="linenos">1884</span></a> <span class="k">return</span> <span class="n">csv</span><span class="p">(</span> +</span><span id="L-1885"><a href="#L-1885"><span class="linenos">1885</span></a> <span class="o">*</span><span class="n">sqls</span><span class="p">,</span> +</span><span id="L-1886"><a href="#L-1886"><span class="linenos">1886</span></a> <span class="o">*</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">join</span><span class="p">)</span> <span class="k">for</span> <span class="n">join</span> <span class="ow">in</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">"joins"</span><span class="p">)</span> <span class="ow">or</span> <span class="p">[]],</span> +</span><span id="L-1887"><a href="#L-1887"><span class="linenos">1887</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">"connect"</span><span class="p">),</span> +</span><span id="L-1888"><a href="#L-1888"><span class="linenos">1888</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">"match"</span><span class="p">),</span> +</span><span id="L-1889"><a href="#L-1889"><span class="linenos">1889</span></a> <span class="o">*</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">lateral</span><span class="p">)</span> <span class="k">for</span> <span class="n">lateral</span> <span class="ow">in</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">"laterals"</span><span class="p">)</span> <span class="ow">or</span> <span class="p">[]],</span> +</span><span id="L-1890"><a href="#L-1890"><span class="linenos">1890</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">"where"</span><span class="p">),</span> +</span><span id="L-1891"><a href="#L-1891"><span class="linenos">1891</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">"group"</span><span class="p">),</span> +</span><span id="L-1892"><a href="#L-1892"><span class="linenos">1892</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">"having"</span><span class="p">),</span> +</span><span id="L-1893"><a href="#L-1893"><span class="linenos">1893</span></a> <span class="o">*</span><span class="bp">self</span><span class="o">.</span><span class="n">after_having_modifiers</span><span class="p">(</span><span class="n">expression</span><span class="p">),</span> +</span><span id="L-1894"><a href="#L-1894"><span class="linenos">1894</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">"order"</span><span class="p">),</span> +</span><span id="L-1895"><a href="#L-1895"><span class="linenos">1895</span></a> <span class="o">*</span><span class="n">offset_limit_modifiers</span><span class="p">,</span> +</span><span id="L-1896"><a href="#L-1896"><span class="linenos">1896</span></a> <span class="o">*</span><span class="bp">self</span><span class="o">.</span><span class="n">after_limit_modifiers</span><span class="p">(</span><span class="n">expression</span><span class="p">),</span> +</span><span id="L-1897"><a href="#L-1897"><span class="linenos">1897</span></a> <span class="n">sep</span><span class="o">=</span><span class="s2">""</span><span class="p">,</span> +</span><span id="L-1898"><a href="#L-1898"><span class="linenos">1898</span></a> <span class="p">)</span> +</span><span id="L-1899"><a href="#L-1899"><span class="linenos">1899</span></a> +</span><span id="L-1900"><a href="#L-1900"><span class="linenos">1900</span></a> <span class="k">def</span> <span class="nf">offset_limit_modifiers</span><span class="p">(</span> +</span><span id="L-1901"><a href="#L-1901"><span class="linenos">1901</span></a> <span class="bp">self</span><span 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">fetch</span><span class="p">:</span> <span class="nb">bool</span><span class="p">,</span> <span class="n">limit</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">Fetch</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">]</span> +</span><span id="L-1902"><a href="#L-1902"><span class="linenos">1902</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> +</span><span id="L-1903"><a href="#L-1903"><span class="linenos">1903</span></a> <span class="k">return</span> <span class="p">[</span> +</span><span id="L-1904"><a href="#L-1904"><span class="linenos">1904</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">"offset"</span><span class="p">)</span> <span class="k">if</span> <span class="n">fetch</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">limit</span><span class="p">),</span> +</span><span id="L-1905"><a href="#L-1905"><span class="linenos">1905</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">limit</span><span class="p">)</span> <span class="k">if</span> <span class="n">fetch</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">expression</span><span class="p">,</span> <span class="s2">"offset"</span><span class="p">),</span> +</span><span id="L-1906"><a href="#L-1906"><span class="linenos">1906</span></a> <span class="p">]</span> +</span><span id="L-1907"><a href="#L-1907"><span class="linenos">1907</span></a> +</span><span id="L-1908"><a href="#L-1908"><span class="linenos">1908</span></a> <span class="k">def</span> <span class="nf">after_having_modifiers</span><span class="p">(</span><span class="bp">self</span><span 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">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> +</span><span id="L-1909"><a href="#L-1909"><span class="linenos">1909</span></a> <span class="k">return</span> <span class="p">[</span> +</span><span id="L-1910"><a href="#L-1910"><span class="linenos">1910</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">"qualify"</span><span class="p">),</span> +</span><span id="L-1911"><a href="#L-1911"><span class="linenos">1911</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s2">"WINDOW "</span><span class="p">)</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">"windows"</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-1912"><a href="#L-1912"><span class="linenos">1912</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">"windows"</span><span class="p">)</span> +</span><span id="L-1913"><a href="#L-1913"><span class="linenos">1913</span></a> <span class="k">else</span> <span class="s2">""</span><span class="p">,</span> +</span><span id="L-1914"><a href="#L-1914"><span class="linenos">1914</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">"distribute"</span><span class="p">),</span> +</span><span id="L-1915"><a href="#L-1915"><span class="linenos">1915</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">"sort"</span><span class="p">),</span> +</span><span id="L-1916"><a href="#L-1916"><span class="linenos">1916</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">"cluster"</span><span class="p">),</span> +</span><span id="L-1917"><a href="#L-1917"><span class="linenos">1917</span></a> <span class="p">]</span> </span><span id="L-1918"><a href="#L-1918"><span class="linenos">1918</span></a> -</span><span id="L-1919"><a href="#L-1919"><span class="linenos">1919</span></a> <span class="k">def</span> <span class="nf">select_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1920"><a href="#L-1920"><span class="linenos">1920</span></a> <span class="n">hint</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"hint"</span><span class="p">)</span> -</span><span id="L-1921"><a href="#L-1921"><span class="linenos">1921</span></a> <span class="n">distinct</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"distinct"</span><span class="p">)</span> -</span><span id="L-1922"><a href="#L-1922"><span class="linenos">1922</span></a> <span class="n">distinct</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">distinct</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">distinct</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1923"><a href="#L-1923"><span class="linenos">1923</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 class="o">.</span><span class="n">upper</span><span class="p">()</span> -</span><span id="L-1924"><a href="#L-1924"><span class="linenos">1924</span></a> <span class="n">limit</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">"limit"</span><span class="p">)</span> -</span><span id="L-1925"><a href="#L-1925"><span class="linenos">1925</span></a> <span class="n">top</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="L-1926"><a href="#L-1926"><span class="linenos">1926</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">limit_sql</span><span class="p">(</span><span class="n">limit</span><span class="p">,</span> <span class="n">top</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-1927"><a href="#L-1927"><span class="linenos">1927</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">limit</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">LIMIT_IS_TOP</span> -</span><span id="L-1928"><a href="#L-1928"><span class="linenos">1928</span></a> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1929"><a href="#L-1929"><span class="linenos">1929</span></a> <span class="p">)</span> -</span><span id="L-1930"><a href="#L-1930"><span class="linenos">1930</span></a> -</span><span id="L-1931"><a href="#L-1931"><span class="linenos">1931</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-1932"><a href="#L-1932"><span class="linenos">1932</span></a> -</span><span id="L-1933"><a href="#L-1933"><span class="linenos">1933</span></a> <span class="k">if</span> <span class="n">kind</span><span class="p">:</span> -</span><span id="L-1934"><a href="#L-1934"><span class="linenos">1934</span></a> <span class="k">if</span> <span class="n">kind</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">SELECT_KINDS</span><span class="p">:</span> -</span><span id="L-1935"><a href="#L-1935"><span class="linenos">1935</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1936"><a href="#L-1936"><span class="linenos">1936</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-1937"><a href="#L-1937"><span class="linenos">1937</span></a> <span class="k">if</span> <span class="n">kind</span> <span class="o">==</span> <span class="s2">"STRUCT"</span><span class="p">:</span> -</span><span id="L-1938"><a href="#L-1938"><span class="linenos">1938</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><span id="L-1939"><a href="#L-1939"><span class="linenos">1939</span></a> <span class="n">sqls</span><span class="o">=</span><span class="p">[</span> -</span><span id="L-1940"><a href="#L-1940"><span class="linenos">1940</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span> -</span><span id="L-1941"><a href="#L-1941"><span class="linenos">1941</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Struct</span><span class="p">(</span> -</span><span id="L-1942"><a href="#L-1942"><span class="linenos">1942</span></a> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span> -</span><span id="L-1943"><a href="#L-1943"><span class="linenos">1943</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">column</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">output_name</span><span class="p">)</span><span class="o">.</span><span class="n">eq</span><span class="p">(</span> -</span><span id="L-1944"><a href="#L-1944"><span class="linenos">1944</span></a> <span class="n">e</span><span class="o">.</span><span class="n">this</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">Alias</span><span class="p">)</span> <span class="k">else</span> <span class="n">e</span> -</span><span id="L-1945"><a href="#L-1945"><span class="linenos">1945</span></a> <span class="p">)</span> -</span><span id="L-1946"><a href="#L-1946"><span class="linenos">1946</span></a> <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">expressions</span> -</span><span id="L-1947"><a href="#L-1947"><span class="linenos">1947</span></a> <span class="p">]</span> -</span><span id="L-1948"><a href="#L-1948"><span class="linenos">1948</span></a> <span class="p">)</span> -</span><span id="L-1949"><a href="#L-1949"><span class="linenos">1949</span></a> <span class="p">)</span> -</span><span id="L-1950"><a href="#L-1950"><span class="linenos">1950</span></a> <span class="p">]</span> -</span><span id="L-1951"><a href="#L-1951"><span class="linenos">1951</span></a> <span class="p">)</span> -</span><span id="L-1952"><a href="#L-1952"><span class="linenos">1952</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="L-1953"><a href="#L-1953"><span class="linenos">1953</span></a> -</span><span id="L-1954"><a href="#L-1954"><span class="linenos">1954</span></a> <span class="c1"># We use LIMIT_IS_TOP as a proxy for whether DISTINCT should go first because tsql and Teradata</span> -</span><span id="L-1955"><a href="#L-1955"><span class="linenos">1955</span></a> <span class="c1"># are the only dialects that use LIMIT_IS_TOP and both place DISTINCT first.</span> -</span><span id="L-1956"><a href="#L-1956"><span class="linenos">1956</span></a> <span class="n">top_distinct</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">distinct</span><span class="si">}{</span><span class="n">hint</span><span class="si">}{</span><span class="n">top</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">LIMIT_IS_TOP</span> <span class="k">else</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">top</span><span class="si">}{</span><span class="n">hint</span><span class="si">}{</span><span class="n">distinct</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1957"><a href="#L-1957"><span class="linenos">1957</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="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</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="n">expressions</span> -</span><span id="L-1958"><a href="#L-1958"><span class="linenos">1958</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">query_modifiers</span><span class="p">(</span> -</span><span id="L-1959"><a href="#L-1959"><span class="linenos">1959</span></a> <span class="n">expression</span><span class="p">,</span> -</span><span id="L-1960"><a href="#L-1960"><span class="linenos">1960</span></a> <span class="sa">f</span><span class="s2">"SELECT</span><span class="si">{</span><span class="n">top_distinct</span><span class="si">}{</span><span class="n">kind</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> -</span><span id="L-1961"><a href="#L-1961"><span class="linenos">1961</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">"into"</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-1962"><a href="#L-1962"><span class="linenos">1962</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">"from"</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-1963"><a href="#L-1963"><span class="linenos">1963</span></a> <span class="p">)</span> -</span><span id="L-1964"><a href="#L-1964"><span class="linenos">1964</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-1965"><a href="#L-1965"><span class="linenos">1965</span></a> -</span><span id="L-1966"><a href="#L-1966"><span class="linenos">1966</span></a> <span class="k">def</span> <span class="nf">schema_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Schema</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1967"><a href="#L-1967"><span class="linenos">1967</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-1968"><a href="#L-1968"><span class="linenos">1968</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">schema_columns_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="L-1969"><a href="#L-1969"><span class="linenos">1969</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">sql</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="ow">and</span> <span class="n">sql</span> <span class="k">else</span> <span class="n">this</span> <span class="ow">or</span> <span class="n">sql</span> +</span><span id="L-1919"><a href="#L-1919"><span class="linenos">1919</span></a> <span class="k">def</span> <span class="nf">after_limit_modifiers</span><span class="p">(</span><span class="bp">self</span><span 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">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> +</span><span id="L-1920"><a href="#L-1920"><span class="linenos">1920</span></a> <span class="n">locks</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">"locks"</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-1921"><a href="#L-1921"><span class="linenos">1921</span></a> <span class="n">locks</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">locks</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">locks</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1922"><a href="#L-1922"><span class="linenos">1922</span></a> <span class="k">return</span> <span class="p">[</span><span class="n">locks</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">"sample"</span><span class="p">)]</span> +</span><span id="L-1923"><a href="#L-1923"><span class="linenos">1923</span></a> +</span><span id="L-1924"><a href="#L-1924"><span class="linenos">1924</span></a> <span class="k">def</span> <span class="nf">select_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1925"><a href="#L-1925"><span class="linenos">1925</span></a> <span class="n">hint</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"hint"</span><span class="p">)</span> +</span><span id="L-1926"><a href="#L-1926"><span class="linenos">1926</span></a> <span class="n">distinct</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"distinct"</span><span class="p">)</span> +</span><span id="L-1927"><a href="#L-1927"><span class="linenos">1927</span></a> <span class="n">distinct</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">distinct</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">distinct</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1928"><a href="#L-1928"><span class="linenos">1928</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 class="o">.</span><span class="n">upper</span><span class="p">()</span> +</span><span id="L-1929"><a href="#L-1929"><span class="linenos">1929</span></a> <span class="n">limit</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">"limit"</span><span class="p">)</span> +</span><span id="L-1930"><a href="#L-1930"><span class="linenos">1930</span></a> <span class="n">top</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="L-1931"><a href="#L-1931"><span class="linenos">1931</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">limit_sql</span><span class="p">(</span><span class="n">limit</span><span class="p">,</span> <span class="n">top</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-1932"><a href="#L-1932"><span class="linenos">1932</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">limit</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">LIMIT_IS_TOP</span> +</span><span id="L-1933"><a href="#L-1933"><span class="linenos">1933</span></a> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1934"><a href="#L-1934"><span class="linenos">1934</span></a> <span class="p">)</span> +</span><span id="L-1935"><a href="#L-1935"><span class="linenos">1935</span></a> +</span><span id="L-1936"><a href="#L-1936"><span class="linenos">1936</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-1937"><a href="#L-1937"><span class="linenos">1937</span></a> +</span><span id="L-1938"><a href="#L-1938"><span class="linenos">1938</span></a> <span class="k">if</span> <span class="n">kind</span><span class="p">:</span> +</span><span id="L-1939"><a href="#L-1939"><span class="linenos">1939</span></a> <span class="k">if</span> <span class="n">kind</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">SELECT_KINDS</span><span class="p">:</span> +</span><span id="L-1940"><a href="#L-1940"><span class="linenos">1940</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1941"><a href="#L-1941"><span class="linenos">1941</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-1942"><a href="#L-1942"><span class="linenos">1942</span></a> <span class="k">if</span> <span class="n">kind</span> <span class="o">==</span> <span class="s2">"STRUCT"</span><span class="p">:</span> +</span><span id="L-1943"><a href="#L-1943"><span class="linenos">1943</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><span id="L-1944"><a href="#L-1944"><span class="linenos">1944</span></a> <span class="n">sqls</span><span class="o">=</span><span class="p">[</span> +</span><span id="L-1945"><a href="#L-1945"><span class="linenos">1945</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span> +</span><span id="L-1946"><a href="#L-1946"><span class="linenos">1946</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Struct</span><span class="p">(</span> +</span><span id="L-1947"><a href="#L-1947"><span class="linenos">1947</span></a> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span> +</span><span id="L-1948"><a href="#L-1948"><span class="linenos">1948</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">column</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">output_name</span><span class="p">)</span><span class="o">.</span><span class="n">eq</span><span class="p">(</span> +</span><span id="L-1949"><a href="#L-1949"><span class="linenos">1949</span></a> <span class="n">e</span><span class="o">.</span><span class="n">this</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">Alias</span><span class="p">)</span> <span class="k">else</span> <span class="n">e</span> +</span><span id="L-1950"><a href="#L-1950"><span class="linenos">1950</span></a> <span class="p">)</span> +</span><span id="L-1951"><a href="#L-1951"><span class="linenos">1951</span></a> <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">expressions</span> +</span><span id="L-1952"><a href="#L-1952"><span class="linenos">1952</span></a> <span class="p">]</span> +</span><span id="L-1953"><a href="#L-1953"><span class="linenos">1953</span></a> <span class="p">)</span> +</span><span id="L-1954"><a href="#L-1954"><span class="linenos">1954</span></a> <span class="p">)</span> +</span><span id="L-1955"><a href="#L-1955"><span class="linenos">1955</span></a> <span class="p">]</span> +</span><span id="L-1956"><a href="#L-1956"><span class="linenos">1956</span></a> <span class="p">)</span> +</span><span id="L-1957"><a href="#L-1957"><span class="linenos">1957</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="L-1958"><a href="#L-1958"><span class="linenos">1958</span></a> +</span><span id="L-1959"><a href="#L-1959"><span class="linenos">1959</span></a> <span class="c1"># We use LIMIT_IS_TOP as a proxy for whether DISTINCT should go first because tsql and Teradata</span> +</span><span id="L-1960"><a href="#L-1960"><span class="linenos">1960</span></a> <span class="c1"># are the only dialects that use LIMIT_IS_TOP and both place DISTINCT first.</span> +</span><span id="L-1961"><a href="#L-1961"><span class="linenos">1961</span></a> <span class="n">top_distinct</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">distinct</span><span class="si">}{</span><span class="n">hint</span><span class="si">}{</span><span class="n">top</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">LIMIT_IS_TOP</span> <span class="k">else</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">top</span><span class="si">}{</span><span class="n">hint</span><span class="si">}{</span><span class="n">distinct</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1962"><a href="#L-1962"><span class="linenos">1962</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="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</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="n">expressions</span> +</span><span id="L-1963"><a href="#L-1963"><span class="linenos">1963</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">query_modifiers</span><span class="p">(</span> +</span><span id="L-1964"><a href="#L-1964"><span class="linenos">1964</span></a> <span class="n">expression</span><span class="p">,</span> +</span><span id="L-1965"><a href="#L-1965"><span class="linenos">1965</span></a> <span class="sa">f</span><span class="s2">"SELECT</span><span class="si">{</span><span class="n">top_distinct</span><span class="si">}{</span><span class="n">kind</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> +</span><span id="L-1966"><a href="#L-1966"><span class="linenos">1966</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">"into"</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-1967"><a href="#L-1967"><span class="linenos">1967</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">"from"</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-1968"><a href="#L-1968"><span class="linenos">1968</span></a> <span class="p">)</span> +</span><span id="L-1969"><a href="#L-1969"><span class="linenos">1969</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-1970"><a href="#L-1970"><span class="linenos">1970</span></a> -</span><span id="L-1971"><a href="#L-1971"><span class="linenos">1971</span></a> <span class="k">def</span> <span class="nf">schema_columns_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Schema</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1972"><a href="#L-1972"><span class="linenos">1972</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> -</span><span id="L-1973"><a href="#L-1973"><span class="linenos">1973</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">sep</span><span class="p">(</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">expressions</span><span class="p">(</span><span class="n">expression</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-1974"><a href="#L-1974"><span class="linenos">1974</span></a> <span class="k">return</span> <span class="s2">""</span> +</span><span id="L-1971"><a href="#L-1971"><span class="linenos">1971</span></a> <span class="k">def</span> <span class="nf">schema_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Schema</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1972"><a href="#L-1972"><span class="linenos">1972</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-1973"><a href="#L-1973"><span class="linenos">1973</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">schema_columns_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-1974"><a href="#L-1974"><span class="linenos">1974</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">sql</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="ow">and</span> <span class="n">sql</span> <span class="k">else</span> <span class="n">this</span> <span class="ow">or</span> <span class="n">sql</span> </span><span id="L-1975"><a href="#L-1975"><span class="linenos">1975</span></a> -</span><span id="L-1976"><a href="#L-1976"><span class="linenos">1976</span></a> <span class="k">def</span> <span class="nf">star_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Star</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1977"><a href="#L-1977"><span class="linenos">1977</span></a> <span class="n">except_</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">"except"</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-1978"><a href="#L-1978"><span class="linenos">1978</span></a> <span class="n">except_</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">seg</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">STAR_MAPPING</span><span class="p">[</span><span class="s1">'except'</span><span class="p">])</span><span class="si">}</span><span class="s2"> (</span><span class="si">{</span><span class="n">except_</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">except_</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1979"><a href="#L-1979"><span class="linenos">1979</span></a> <span class="n">replace</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">"replace"</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-1980"><a href="#L-1980"><span class="linenos">1980</span></a> <span class="n">replace</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">seg</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">STAR_MAPPING</span><span class="p">[</span><span class="s1">'replace'</span><span class="p">])</span><span class="si">}</span><span class="s2"> (</span><span class="si">{</span><span class="n">replace</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">replace</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1981"><a href="#L-1981"><span class="linenos">1981</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"*</span><span class="si">{</span><span class="n">except_</span><span class="si">}{</span><span class="n">replace</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1982"><a href="#L-1982"><span class="linenos">1982</span></a> -</span><span id="L-1983"><a href="#L-1983"><span class="linenos">1983</span></a> <span class="k">def</span> <span class="nf">parameter_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Parameter</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1984"><a href="#L-1984"><span class="linenos">1984</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-1985"><a href="#L-1985"><span class="linenos">1985</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">PARAMETER_TOKEN</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1986"><a href="#L-1986"><span class="linenos">1986</span></a> -</span><span id="L-1987"><a href="#L-1987"><span class="linenos">1987</span></a> <span class="k">def</span> <span class="nf">sessionparameter_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SessionParameter</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1988"><a href="#L-1988"><span class="linenos">1988</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-1989"><a href="#L-1989"><span class="linenos">1989</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">)</span> -</span><span id="L-1990"><a href="#L-1990"><span class="linenos">1990</span></a> <span class="k">if</span> <span class="n">kind</span><span class="p">:</span> -</span><span id="L-1991"><a href="#L-1991"><span class="linenos">1991</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><span id="L-1992"><a href="#L-1992"><span class="linenos">1992</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="s2">"</span> -</span><span id="L-1993"><a href="#L-1993"><span class="linenos">1993</span></a> -</span><span id="L-1994"><a href="#L-1994"><span class="linenos">1994</span></a> <span class="k">def</span> <span class="nf">placeholder_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Placeholder</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1995"><a href="#L-1995"><span class="linenos">1995</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">name</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">name</span> <span class="k">else</span> <span class="s2">"?"</span> -</span><span id="L-1996"><a href="#L-1996"><span class="linenos">1996</span></a> -</span><span id="L-1997"><a href="#L-1997"><span class="linenos">1997</span></a> <span class="k">def</span> <span class="nf">subquery_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</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="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">" AS "</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1998"><a href="#L-1998"><span class="linenos">1998</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-1999"><a href="#L-1999"><span class="linenos">1999</span></a> <span class="n">alias</span> <span class="o">=</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">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-2000"><a href="#L-2000"><span class="linenos">2000</span></a> -</span><span id="L-2001"><a href="#L-2001"><span class="linenos">2001</span></a> <span class="n">pivots</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">"pivots"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</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-2002"><a href="#L-2002"><span class="linenos">2002</span></a> <span class="n">pivots</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">pivots</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">pivots</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-2003"><a href="#L-2003"><span class="linenos">2003</span></a> -</span><span id="L-2004"><a href="#L-2004"><span class="linenos">2004</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">query_modifiers</span><span class="p">(</span><span class="n">expression</span><span class="p">,</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 class="n">alias</span><span class="p">,</span> <span class="n">pivots</span><span class="p">)</span> -</span><span id="L-2005"><a href="#L-2005"><span class="linenos">2005</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-2006"><a href="#L-2006"><span class="linenos">2006</span></a> -</span><span id="L-2007"><a href="#L-2007"><span class="linenos">2007</span></a> <span class="k">def</span> <span class="nf">qualify_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Qualify</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2008"><a href="#L-2008"><span class="linenos">2008</span></a> <span class="n">this</span> <span class="o">=</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><span id="L-2009"><a href="#L-2009"><span class="linenos">2009</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="s1">'QUALIFY'</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="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2010"><a href="#L-2010"><span class="linenos">2010</span></a> -</span><span id="L-2011"><a href="#L-2011"><span class="linenos">2011</span></a> <span class="k">def</span> <span class="nf">union_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Union</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2012"><a href="#L-2012"><span class="linenos">2012</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><span id="L-2013"><a href="#L-2013"><span class="linenos">2013</span></a> <span class="n">expression</span><span class="p">,</span> -</span><span id="L-2014"><a href="#L-2014"><span class="linenos">2014</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">set_operation</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">union_op</span><span class="p">(</span><span class="n">expression</span><span class="p">)),</span> -</span><span id="L-2015"><a href="#L-2015"><span class="linenos">2015</span></a> <span class="p">)</span> -</span><span id="L-2016"><a href="#L-2016"><span class="linenos">2016</span></a> -</span><span id="L-2017"><a href="#L-2017"><span class="linenos">2017</span></a> <span class="k">def</span> <span class="nf">union_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Union</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2018"><a href="#L-2018"><span class="linenos">2018</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="s2">" DISTINCT"</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">EXPLICIT_UNION</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-2019"><a href="#L-2019"><span class="linenos">2019</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">kind</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">"distinct"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">" ALL"</span> -</span><span id="L-2020"><a href="#L-2020"><span class="linenos">2020</span></a> <span class="n">by_name</span> <span class="o">=</span> <span class="s2">" BY NAME"</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">"by_name"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-2021"><a href="#L-2021"><span class="linenos">2021</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"UNION</span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">by_name</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2022"><a href="#L-2022"><span class="linenos">2022</span></a> -</span><span id="L-2023"><a href="#L-2023"><span class="linenos">2023</span></a> <span class="k">def</span> <span class="nf">unnest_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</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-2024"><a href="#L-2024"><span class="linenos">2024</span></a> <span class="n">args</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-2025"><a href="#L-2025"><span class="linenos">2025</span></a> -</span><span id="L-2026"><a href="#L-2026"><span class="linenos">2026</span></a> <span class="n">alias</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">"alias"</span><span class="p">)</span> -</span><span id="L-2027"><a href="#L-2027"><span class="linenos">2027</span></a> <span class="n">offset</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">"offset"</span><span class="p">)</span> -</span><span id="L-2028"><a href="#L-2028"><span class="linenos">2028</span></a> -</span><span id="L-2029"><a href="#L-2029"><span class="linenos">2029</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">UNNEST_WITH_ORDINALITY</span><span class="p">:</span> -</span><span id="L-2030"><a href="#L-2030"><span class="linenos">2030</span></a> <span class="k">if</span> <span class="n">alias</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">offset</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="L-2031"><a href="#L-2031"><span class="linenos">2031</span></a> <span class="n">alias</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"columns"</span><span class="p">,</span> <span class="n">offset</span><span class="p">)</span> -</span><span id="L-2032"><a href="#L-2032"><span class="linenos">2032</span></a> -</span><span id="L-2033"><a href="#L-2033"><span class="linenos">2033</span></a> <span class="k">if</span> <span class="n">alias</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">UNNEST_COLUMN_ONLY</span><span class="p">:</span> -</span><span id="L-2034"><a href="#L-2034"><span class="linenos">2034</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="n">alias</span><span class="o">.</span><span class="n">columns</span> -</span><span id="L-2035"><a href="#L-2035"><span class="linenos">2035</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">columns</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="k">if</span> <span class="n">columns</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-2036"><a href="#L-2036"><span class="linenos">2036</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-2037"><a href="#L-2037"><span class="linenos">2037</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">alias</span><span class="p">)</span> -</span><span id="L-2038"><a href="#L-2038"><span class="linenos">2038</span></a> -</span><span id="L-2039"><a href="#L-2039"><span class="linenos">2039</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="n">alias</span> -</span><span id="L-2040"><a href="#L-2040"><span class="linenos">2040</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">UNNEST_WITH_ORDINALITY</span><span class="p">:</span> -</span><span id="L-2041"><a href="#L-2041"><span class="linenos">2041</span></a> <span class="n">suffix</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" WITH ORDINALITY</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">offset</span> <span class="k">else</span> <span class="n">alias</span> -</span><span id="L-2042"><a href="#L-2042"><span class="linenos">2042</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-2043"><a href="#L-2043"><span class="linenos">2043</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">offset</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="L-2044"><a href="#L-2044"><span class="linenos">2044</span></a> <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">alias</span><span class="si">}</span><span class="s2"> WITH OFFSET 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">offset</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2045"><a href="#L-2045"><span class="linenos">2045</span></a> <span class="k">elif</span> <span class="n">offset</span><span class="p">:</span> -</span><span id="L-2046"><a href="#L-2046"><span class="linenos">2046</span></a> <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">alias</span><span class="si">}</span><span class="s2"> WITH OFFSET"</span> -</span><span id="L-2047"><a href="#L-2047"><span class="linenos">2047</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-2048"><a href="#L-2048"><span class="linenos">2048</span></a> <span class="n">suffix</span> <span class="o">=</span> <span class="n">alias</span> -</span><span id="L-2049"><a href="#L-2049"><span class="linenos">2049</span></a> -</span><span id="L-2050"><a href="#L-2050"><span class="linenos">2050</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"UNNEST(</span><span class="si">{</span><span class="n">args</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="n">suffix</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2051"><a href="#L-2051"><span class="linenos">2051</span></a> -</span><span id="L-2052"><a href="#L-2052"><span class="linenos">2052</span></a> <span class="k">def</span> <span class="nf">where_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Where</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2053"><a href="#L-2053"><span class="linenos">2053</span></a> <span class="n">this</span> <span class="o">=</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><span id="L-2054"><a href="#L-2054"><span class="linenos">2054</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="s1">'WHERE'</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="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2055"><a href="#L-2055"><span class="linenos">2055</span></a> -</span><span id="L-2056"><a href="#L-2056"><span class="linenos">2056</span></a> <span class="k">def</span> <span class="nf">window_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Window</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2057"><a href="#L-2057"><span class="linenos">2057</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-2058"><a href="#L-2058"><span class="linenos">2058</span></a> <span class="n">partition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">partition_by_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="L-2059"><a href="#L-2059"><span class="linenos">2059</span></a> <span class="n">order</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">"order"</span><span class="p">)</span> -</span><span id="L-2060"><a href="#L-2060"><span class="linenos">2060</span></a> <span class="n">order</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">order_sql</span><span class="p">(</span><span class="n">order</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="k">if</span> <span class="n">order</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-2061"><a href="#L-2061"><span class="linenos">2061</span></a> <span class="n">spec</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"spec"</span><span class="p">)</span> -</span><span id="L-2062"><a href="#L-2062"><span class="linenos">2062</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-2063"><a href="#L-2063"><span class="linenos">2063</span></a> <span class="n">over</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"over"</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">"OVER"</span> -</span><span id="L-2064"><a href="#L-2064"><span class="linenos">2064</span></a> -</span><span id="L-2065"><a href="#L-2065"><span class="linenos">2065</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="si">{</span><span class="s1">'AS'</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">arg_key</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="s1">'windows'</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="n">over</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2066"><a href="#L-2066"><span class="linenos">2066</span></a> -</span><span id="L-2067"><a href="#L-2067"><span class="linenos">2067</span></a> <span class="n">first</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">"first"</span><span class="p">)</span> -</span><span id="L-2068"><a href="#L-2068"><span class="linenos">2068</span></a> <span class="k">if</span> <span class="n">first</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="L-2069"><a href="#L-2069"><span class="linenos">2069</span></a> <span class="n">first</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="L-2070"><a href="#L-2070"><span class="linenos">2070</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-2071"><a href="#L-2071"><span class="linenos">2071</span></a> <span class="n">first</span> <span class="o">=</span> <span class="s2">"FIRST"</span> <span class="k">if</span> <span class="n">first</span> <span class="k">else</span> <span class="s2">"LAST"</span> -</span><span id="L-2072"><a href="#L-2072"><span class="linenos">2072</span></a> -</span><span id="L-2073"><a href="#L-2073"><span class="linenos">2073</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">partition</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">order</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">spec</span> <span class="ow">and</span> <span class="n">alias</span><span class="p">:</span> -</span><span id="L-2074"><a href="#L-2074"><span class="linenos">2074</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">alias</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2075"><a href="#L-2075"><span class="linenos">2075</span></a> -</span><span id="L-2076"><a href="#L-2076"><span class="linenos">2076</span></a> <span class="n">args</span> <span class="o">=</span> <span class="s2">" "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">arg</span> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="p">(</span><span class="n">alias</span><span class="p">,</span> <span class="n">first</span><span class="p">,</span> <span class="n">partition</span><span class="p">,</span> <span class="n">order</span><span class="p">,</span> <span class="n">spec</span><span class="p">)</span> <span class="k">if</span> <span class="n">arg</span><span class="p">)</span> -</span><span id="L-2077"><a href="#L-2077"><span class="linenos">2077</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">args</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="L-2078"><a href="#L-2078"><span class="linenos">2078</span></a> -</span><span id="L-2079"><a href="#L-2079"><span class="linenos">2079</span></a> <span class="k">def</span> <span class="nf">partition_by_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Window</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">MatchRecognize</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2080"><a href="#L-2080"><span class="linenos">2080</span></a> <span class="n">partition</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">"partition_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-2081"><a href="#L-2081"><span class="linenos">2081</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PARTITION BY </span><span class="si">{</span><span class="n">partition</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">partition</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-2082"><a href="#L-2082"><span class="linenos">2082</span></a> -</span><span id="L-2083"><a href="#L-2083"><span class="linenos">2083</span></a> <span class="k">def</span> <span class="nf">windowspec_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">WindowSpec</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2084"><a href="#L-2084"><span class="linenos">2084</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-2085"><a href="#L-2085"><span class="linenos">2085</span></a> <span class="n">start</span> <span class="o">=</span> <span class="n">csv</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">"start"</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">"start_side"</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-2086"><a href="#L-2086"><span class="linenos">2086</span></a> <span class="n">end</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="L-2087"><a href="#L-2087"><span class="linenos">2087</span></a> <span class="n">csv</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">"end"</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">"end_side"</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-2088"><a href="#L-2088"><span class="linenos">2088</span></a> <span class="ow">or</span> <span class="s2">"CURRENT ROW"</span> -</span><span id="L-2089"><a href="#L-2089"><span class="linenos">2089</span></a> <span class="p">)</span> -</span><span id="L-2090"><a href="#L-2090"><span class="linenos">2090</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="s2"> BETWEEN </span><span class="si">{</span><span class="n">start</span><span class="si">}</span><span class="s2"> AND </span><span class="si">{</span><span class="n">end</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2091"><a href="#L-2091"><span class="linenos">2091</span></a> -</span><span id="L-2092"><a href="#L-2092"><span class="linenos">2092</span></a> <span class="k">def</span> <span class="nf">withingroup_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">WithinGroup</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2093"><a href="#L-2093"><span class="linenos">2093</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-2094"><a href="#L-2094"><span class="linenos">2094</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 class="mi">1</span><span class="p">:]</span> <span class="c1"># order has a leading space</span> -</span><span id="L-2095"><a href="#L-2095"><span class="linenos">2095</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"> WITHIN GROUP (</span><span class="si">{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="L-1976"><a href="#L-1976"><span class="linenos">1976</span></a> <span class="k">def</span> <span class="nf">schema_columns_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Schema</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1977"><a href="#L-1977"><span class="linenos">1977</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> +</span><span id="L-1978"><a href="#L-1978"><span class="linenos">1978</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">sep</span><span class="p">(</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">expressions</span><span class="p">(</span><span class="n">expression</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-1979"><a href="#L-1979"><span class="linenos">1979</span></a> <span class="k">return</span> <span class="s2">""</span> +</span><span id="L-1980"><a href="#L-1980"><span class="linenos">1980</span></a> +</span><span id="L-1981"><a href="#L-1981"><span class="linenos">1981</span></a> <span class="k">def</span> <span class="nf">star_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Star</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1982"><a href="#L-1982"><span class="linenos">1982</span></a> <span class="n">except_</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">"except"</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-1983"><a href="#L-1983"><span class="linenos">1983</span></a> <span class="n">except_</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">seg</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">STAR_MAPPING</span><span class="p">[</span><span class="s1">'except'</span><span class="p">])</span><span class="si">}</span><span class="s2"> (</span><span class="si">{</span><span class="n">except_</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">except_</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1984"><a href="#L-1984"><span class="linenos">1984</span></a> <span class="n">replace</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">"replace"</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-1985"><a href="#L-1985"><span class="linenos">1985</span></a> <span class="n">replace</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">seg</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">STAR_MAPPING</span><span class="p">[</span><span class="s1">'replace'</span><span class="p">])</span><span class="si">}</span><span class="s2"> (</span><span class="si">{</span><span class="n">replace</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">replace</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1986"><a href="#L-1986"><span class="linenos">1986</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"*</span><span class="si">{</span><span class="n">except_</span><span class="si">}{</span><span class="n">replace</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1987"><a href="#L-1987"><span class="linenos">1987</span></a> +</span><span id="L-1988"><a href="#L-1988"><span class="linenos">1988</span></a> <span class="k">def</span> <span class="nf">parameter_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Parameter</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1989"><a href="#L-1989"><span class="linenos">1989</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-1990"><a href="#L-1990"><span class="linenos">1990</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">PARAMETER_TOKEN</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1991"><a href="#L-1991"><span class="linenos">1991</span></a> +</span><span id="L-1992"><a href="#L-1992"><span class="linenos">1992</span></a> <span class="k">def</span> <span class="nf">sessionparameter_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SessionParameter</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1993"><a href="#L-1993"><span class="linenos">1993</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-1994"><a href="#L-1994"><span class="linenos">1994</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">)</span> +</span><span id="L-1995"><a href="#L-1995"><span class="linenos">1995</span></a> <span class="k">if</span> <span class="n">kind</span><span class="p">:</span> +</span><span id="L-1996"><a href="#L-1996"><span class="linenos">1996</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><span id="L-1997"><a href="#L-1997"><span class="linenos">1997</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="s2">"</span> +</span><span id="L-1998"><a href="#L-1998"><span class="linenos">1998</span></a> +</span><span id="L-1999"><a href="#L-1999"><span class="linenos">1999</span></a> <span class="k">def</span> <span class="nf">placeholder_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Placeholder</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2000"><a href="#L-2000"><span class="linenos">2000</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">name</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">name</span> <span class="k">else</span> <span class="s2">"?"</span> +</span><span id="L-2001"><a href="#L-2001"><span class="linenos">2001</span></a> +</span><span id="L-2002"><a href="#L-2002"><span class="linenos">2002</span></a> <span class="k">def</span> <span class="nf">subquery_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</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="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">" AS "</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2003"><a href="#L-2003"><span class="linenos">2003</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-2004"><a href="#L-2004"><span class="linenos">2004</span></a> <span class="n">alias</span> <span class="o">=</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">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-2005"><a href="#L-2005"><span class="linenos">2005</span></a> +</span><span id="L-2006"><a href="#L-2006"><span class="linenos">2006</span></a> <span class="n">pivots</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">"pivots"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</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-2007"><a href="#L-2007"><span class="linenos">2007</span></a> <span class="n">pivots</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">pivots</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">pivots</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-2008"><a href="#L-2008"><span class="linenos">2008</span></a> +</span><span id="L-2009"><a href="#L-2009"><span class="linenos">2009</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">query_modifiers</span><span class="p">(</span><span class="n">expression</span><span class="p">,</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 class="n">alias</span><span class="p">,</span> <span class="n">pivots</span><span class="p">)</span> +</span><span id="L-2010"><a href="#L-2010"><span class="linenos">2010</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-2011"><a href="#L-2011"><span class="linenos">2011</span></a> +</span><span id="L-2012"><a href="#L-2012"><span class="linenos">2012</span></a> <span class="k">def</span> <span class="nf">qualify_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Qualify</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2013"><a href="#L-2013"><span class="linenos">2013</span></a> <span class="n">this</span> <span class="o">=</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><span id="L-2014"><a href="#L-2014"><span class="linenos">2014</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="s1">'QUALIFY'</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="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2015"><a href="#L-2015"><span class="linenos">2015</span></a> +</span><span id="L-2016"><a href="#L-2016"><span class="linenos">2016</span></a> <span class="k">def</span> <span class="nf">union_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Union</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2017"><a href="#L-2017"><span class="linenos">2017</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><span id="L-2018"><a href="#L-2018"><span class="linenos">2018</span></a> <span class="n">expression</span><span class="p">,</span> +</span><span id="L-2019"><a href="#L-2019"><span class="linenos">2019</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">set_operation</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">union_op</span><span class="p">(</span><span class="n">expression</span><span class="p">)),</span> +</span><span id="L-2020"><a href="#L-2020"><span class="linenos">2020</span></a> <span class="p">)</span> +</span><span id="L-2021"><a href="#L-2021"><span class="linenos">2021</span></a> +</span><span id="L-2022"><a href="#L-2022"><span class="linenos">2022</span></a> <span class="k">def</span> <span class="nf">union_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Union</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2023"><a href="#L-2023"><span class="linenos">2023</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="s2">" DISTINCT"</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">EXPLICIT_UNION</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-2024"><a href="#L-2024"><span class="linenos">2024</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">kind</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">"distinct"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">" ALL"</span> +</span><span id="L-2025"><a href="#L-2025"><span class="linenos">2025</span></a> <span class="n">by_name</span> <span class="o">=</span> <span class="s2">" BY NAME"</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">"by_name"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-2026"><a href="#L-2026"><span class="linenos">2026</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"UNION</span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">by_name</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2027"><a href="#L-2027"><span class="linenos">2027</span></a> +</span><span id="L-2028"><a href="#L-2028"><span class="linenos">2028</span></a> <span class="k">def</span> <span class="nf">unnest_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</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-2029"><a href="#L-2029"><span class="linenos">2029</span></a> <span class="n">args</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-2030"><a href="#L-2030"><span class="linenos">2030</span></a> +</span><span id="L-2031"><a href="#L-2031"><span class="linenos">2031</span></a> <span class="n">alias</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">"alias"</span><span class="p">)</span> +</span><span id="L-2032"><a href="#L-2032"><span class="linenos">2032</span></a> <span class="n">offset</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">"offset"</span><span class="p">)</span> +</span><span id="L-2033"><a href="#L-2033"><span class="linenos">2033</span></a> +</span><span id="L-2034"><a href="#L-2034"><span class="linenos">2034</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">UNNEST_WITH_ORDINALITY</span><span class="p">:</span> +</span><span id="L-2035"><a href="#L-2035"><span class="linenos">2035</span></a> <span class="k">if</span> <span class="n">alias</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">offset</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="L-2036"><a href="#L-2036"><span class="linenos">2036</span></a> <span class="n">alias</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"columns"</span><span class="p">,</span> <span class="n">offset</span><span class="p">)</span> +</span><span id="L-2037"><a href="#L-2037"><span class="linenos">2037</span></a> +</span><span id="L-2038"><a href="#L-2038"><span class="linenos">2038</span></a> <span class="k">if</span> <span class="n">alias</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">UNNEST_COLUMN_ONLY</span><span class="p">:</span> +</span><span id="L-2039"><a href="#L-2039"><span class="linenos">2039</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="n">alias</span><span class="o">.</span><span class="n">columns</span> +</span><span id="L-2040"><a href="#L-2040"><span class="linenos">2040</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">columns</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="k">if</span> <span class="n">columns</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-2041"><a href="#L-2041"><span class="linenos">2041</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-2042"><a href="#L-2042"><span class="linenos">2042</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">alias</span><span class="p">)</span> +</span><span id="L-2043"><a href="#L-2043"><span class="linenos">2043</span></a> +</span><span id="L-2044"><a href="#L-2044"><span class="linenos">2044</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="n">alias</span> +</span><span id="L-2045"><a href="#L-2045"><span class="linenos">2045</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">UNNEST_WITH_ORDINALITY</span><span class="p">:</span> +</span><span id="L-2046"><a href="#L-2046"><span class="linenos">2046</span></a> <span class="n">suffix</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" WITH ORDINALITY</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">offset</span> <span class="k">else</span> <span class="n">alias</span> +</span><span id="L-2047"><a href="#L-2047"><span class="linenos">2047</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-2048"><a href="#L-2048"><span class="linenos">2048</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">offset</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="L-2049"><a href="#L-2049"><span class="linenos">2049</span></a> <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">alias</span><span class="si">}</span><span class="s2"> WITH OFFSET 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">offset</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2050"><a href="#L-2050"><span class="linenos">2050</span></a> <span class="k">elif</span> <span class="n">offset</span><span class="p">:</span> +</span><span id="L-2051"><a href="#L-2051"><span class="linenos">2051</span></a> <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">alias</span><span class="si">}</span><span class="s2"> WITH OFFSET"</span> +</span><span id="L-2052"><a href="#L-2052"><span class="linenos">2052</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-2053"><a href="#L-2053"><span class="linenos">2053</span></a> <span class="n">suffix</span> <span class="o">=</span> <span class="n">alias</span> +</span><span id="L-2054"><a href="#L-2054"><span class="linenos">2054</span></a> +</span><span id="L-2055"><a href="#L-2055"><span class="linenos">2055</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"UNNEST(</span><span class="si">{</span><span class="n">args</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="n">suffix</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2056"><a href="#L-2056"><span class="linenos">2056</span></a> +</span><span id="L-2057"><a href="#L-2057"><span class="linenos">2057</span></a> <span class="k">def</span> <span class="nf">where_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Where</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2058"><a href="#L-2058"><span class="linenos">2058</span></a> <span class="n">this</span> <span class="o">=</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><span id="L-2059"><a href="#L-2059"><span class="linenos">2059</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="s1">'WHERE'</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="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2060"><a href="#L-2060"><span class="linenos">2060</span></a> +</span><span id="L-2061"><a href="#L-2061"><span class="linenos">2061</span></a> <span class="k">def</span> <span class="nf">window_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Window</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2062"><a href="#L-2062"><span class="linenos">2062</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-2063"><a href="#L-2063"><span class="linenos">2063</span></a> <span class="n">partition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">partition_by_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-2064"><a href="#L-2064"><span class="linenos">2064</span></a> <span class="n">order</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">"order"</span><span class="p">)</span> +</span><span id="L-2065"><a href="#L-2065"><span class="linenos">2065</span></a> <span class="n">order</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">order_sql</span><span class="p">(</span><span class="n">order</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="k">if</span> <span class="n">order</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-2066"><a href="#L-2066"><span class="linenos">2066</span></a> <span class="n">spec</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"spec"</span><span class="p">)</span> +</span><span id="L-2067"><a href="#L-2067"><span class="linenos">2067</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-2068"><a href="#L-2068"><span class="linenos">2068</span></a> <span class="n">over</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"over"</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">"OVER"</span> +</span><span id="L-2069"><a href="#L-2069"><span class="linenos">2069</span></a> +</span><span id="L-2070"><a href="#L-2070"><span class="linenos">2070</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="si">{</span><span class="s1">'AS'</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">arg_key</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="s1">'windows'</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="n">over</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2071"><a href="#L-2071"><span class="linenos">2071</span></a> +</span><span id="L-2072"><a href="#L-2072"><span class="linenos">2072</span></a> <span class="n">first</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">"first"</span><span class="p">)</span> +</span><span id="L-2073"><a href="#L-2073"><span class="linenos">2073</span></a> <span class="k">if</span> <span class="n">first</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-2074"><a href="#L-2074"><span class="linenos">2074</span></a> <span class="n">first</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="L-2075"><a href="#L-2075"><span class="linenos">2075</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-2076"><a href="#L-2076"><span class="linenos">2076</span></a> <span class="n">first</span> <span class="o">=</span> <span class="s2">"FIRST"</span> <span class="k">if</span> <span class="n">first</span> <span class="k">else</span> <span class="s2">"LAST"</span> +</span><span id="L-2077"><a href="#L-2077"><span class="linenos">2077</span></a> +</span><span id="L-2078"><a href="#L-2078"><span class="linenos">2078</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">partition</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">order</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">spec</span> <span class="ow">and</span> <span class="n">alias</span><span class="p">:</span> +</span><span id="L-2079"><a href="#L-2079"><span class="linenos">2079</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">alias</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2080"><a href="#L-2080"><span class="linenos">2080</span></a> +</span><span id="L-2081"><a href="#L-2081"><span class="linenos">2081</span></a> <span class="n">args</span> <span class="o">=</span> <span class="s2">" "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">arg</span> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="p">(</span><span class="n">alias</span><span class="p">,</span> <span class="n">first</span><span class="p">,</span> <span class="n">partition</span><span class="p">,</span> <span class="n">order</span><span class="p">,</span> <span class="n">spec</span><span class="p">)</span> <span class="k">if</span> <span class="n">arg</span><span class="p">)</span> +</span><span id="L-2082"><a href="#L-2082"><span class="linenos">2082</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">args</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="L-2083"><a href="#L-2083"><span class="linenos">2083</span></a> +</span><span id="L-2084"><a href="#L-2084"><span class="linenos">2084</span></a> <span class="k">def</span> <span class="nf">partition_by_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Window</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">MatchRecognize</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2085"><a href="#L-2085"><span class="linenos">2085</span></a> <span class="n">partition</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">"partition_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-2086"><a href="#L-2086"><span class="linenos">2086</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PARTITION BY </span><span class="si">{</span><span class="n">partition</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">partition</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-2087"><a href="#L-2087"><span class="linenos">2087</span></a> +</span><span id="L-2088"><a href="#L-2088"><span class="linenos">2088</span></a> <span class="k">def</span> <span class="nf">windowspec_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">WindowSpec</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2089"><a href="#L-2089"><span class="linenos">2089</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-2090"><a href="#L-2090"><span class="linenos">2090</span></a> <span class="n">start</span> <span class="o">=</span> <span class="n">csv</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">"start"</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">"start_side"</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-2091"><a href="#L-2091"><span class="linenos">2091</span></a> <span class="n">end</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="L-2092"><a href="#L-2092"><span class="linenos">2092</span></a> <span class="n">csv</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">"end"</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">"end_side"</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-2093"><a href="#L-2093"><span class="linenos">2093</span></a> <span class="ow">or</span> <span class="s2">"CURRENT ROW"</span> +</span><span id="L-2094"><a href="#L-2094"><span class="linenos">2094</span></a> <span class="p">)</span> +</span><span id="L-2095"><a href="#L-2095"><span class="linenos">2095</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="s2"> BETWEEN </span><span class="si">{</span><span class="n">start</span><span class="si">}</span><span class="s2"> AND </span><span class="si">{</span><span class="n">end</span><span class="si">}</span><span class="s2">"</span> </span><span id="L-2096"><a href="#L-2096"><span class="linenos">2096</span></a> -</span><span id="L-2097"><a href="#L-2097"><span class="linenos">2097</span></a> <span class="k">def</span> <span class="nf">between_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Between</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2097"><a href="#L-2097"><span class="linenos">2097</span></a> <span class="k">def</span> <span class="nf">withingroup_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">WithinGroup</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> </span><span id="L-2098"><a href="#L-2098"><span class="linenos">2098</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-2099"><a href="#L-2099"><span class="linenos">2099</span></a> <span class="n">low</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"low"</span><span class="p">)</span> -</span><span id="L-2100"><a href="#L-2100"><span class="linenos">2100</span></a> <span class="n">high</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"high"</span><span class="p">)</span> -</span><span id="L-2101"><a href="#L-2101"><span class="linenos">2101</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"> BETWEEN </span><span class="si">{</span><span class="n">low</span><span class="si">}</span><span class="s2"> AND </span><span class="si">{</span><span class="n">high</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2102"><a href="#L-2102"><span class="linenos">2102</span></a> -</span><span id="L-2103"><a href="#L-2103"><span class="linenos">2103</span></a> <span class="k">def</span> <span class="nf">bracket_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Bracket</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2104"><a href="#L-2104"><span class="linenos">2104</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="n">apply_index_offset</span><span class="p">(</span> -</span><span id="L-2105"><a href="#L-2105"><span class="linenos">2105</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> -</span><span id="L-2106"><a href="#L-2106"><span class="linenos">2106</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">,</span> -</span><span id="L-2107"><a href="#L-2107"><span class="linenos">2107</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">INDEX_OFFSET</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">"offset"</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> -</span><span id="L-2108"><a href="#L-2108"><span class="linenos">2108</span></a> <span class="p">)</span> -</span><span id="L-2109"><a href="#L-2109"><span class="linenos">2109</span></a> <span class="n">expressions_sql</span> <span class="o">=</span> <span class="s2">", "</span><span class="o">.</span><span class="n">join</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><span id="L-2110"><a href="#L-2110"><span class="linenos">2110</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">expressions_sql</span><span class="si">}</span><span class="s2">]"</span> -</span><span id="L-2111"><a href="#L-2111"><span class="linenos">2111</span></a> -</span><span id="L-2112"><a href="#L-2112"><span class="linenos">2112</span></a> <span class="k">def</span> <span class="nf">all_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">All</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2113"><a href="#L-2113"><span class="linenos">2113</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ALL </span><span class="si">{</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 class="si">}</span><span class="s2">"</span> -</span><span id="L-2114"><a href="#L-2114"><span class="linenos">2114</span></a> -</span><span id="L-2115"><a href="#L-2115"><span class="linenos">2115</span></a> <span class="k">def</span> <span class="nf">any_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Any</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2116"><a href="#L-2116"><span class="linenos">2116</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-2117"><a href="#L-2117"><span class="linenos">2117</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">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Subqueryable</span><span class="p">):</span> -</span><span id="L-2118"><a href="#L-2118"><span class="linenos">2118</span></a> <span class="n">this</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">this</span><span class="p">)</span> -</span><span id="L-2119"><a href="#L-2119"><span class="linenos">2119</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ANY </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2120"><a href="#L-2120"><span class="linenos">2120</span></a> -</span><span id="L-2121"><a href="#L-2121"><span class="linenos">2121</span></a> <span class="k">def</span> <span class="nf">exists_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Exists</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2122"><a href="#L-2122"><span class="linenos">2122</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"EXISTS</span><span class="si">{</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 class="si">}</span><span class="s2">"</span> -</span><span id="L-2123"><a href="#L-2123"><span class="linenos">2123</span></a> -</span><span id="L-2124"><a href="#L-2124"><span class="linenos">2124</span></a> <span class="k">def</span> <span class="nf">case_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</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="nb">str</span><span class="p">:</span> -</span><span id="L-2125"><a href="#L-2125"><span class="linenos">2125</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-2126"><a href="#L-2126"><span class="linenos">2126</span></a> <span class="n">statements</span> <span class="o">=</span> <span class="p">[</span><span class="sa">f</span><span class="s2">"CASE </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">"CASE"</span><span class="p">]</span> -</span><span id="L-2127"><a href="#L-2127"><span class="linenos">2127</span></a> -</span><span id="L-2128"><a href="#L-2128"><span class="linenos">2128</span></a> <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">args</span><span class="p">[</span><span class="s2">"ifs"</span><span class="p">]:</span> -</span><span id="L-2129"><a href="#L-2129"><span class="linenos">2129</span></a> <span class="n">statements</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="sa">f</span><span class="s2">"WHEN </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">e</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="p">)</span> -</span><span id="L-2130"><a href="#L-2130"><span class="linenos">2130</span></a> <span class="n">statements</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="sa">f</span><span class="s2">"THEN </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">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'true'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="L-2131"><a href="#L-2131"><span class="linenos">2131</span></a> -</span><span id="L-2132"><a href="#L-2132"><span class="linenos">2132</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-2133"><a href="#L-2133"><span class="linenos">2133</span></a> -</span><span id="L-2134"><a href="#L-2134"><span class="linenos">2134</span></a> <span class="k">if</span> <span class="n">default</span><span class="p">:</span> -</span><span id="L-2135"><a href="#L-2135"><span class="linenos">2135</span></a> <span class="n">statements</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="sa">f</span><span class="s2">"ELSE </span><span class="si">{</span><span class="n">default</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="L-2099"><a href="#L-2099"><span class="linenos">2099</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 class="mi">1</span><span class="p">:]</span> <span class="c1"># order has a leading space</span> +</span><span id="L-2100"><a href="#L-2100"><span class="linenos">2100</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"> WITHIN GROUP (</span><span class="si">{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="L-2101"><a href="#L-2101"><span class="linenos">2101</span></a> +</span><span id="L-2102"><a href="#L-2102"><span class="linenos">2102</span></a> <span class="k">def</span> <span class="nf">between_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Between</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2103"><a href="#L-2103"><span class="linenos">2103</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-2104"><a href="#L-2104"><span class="linenos">2104</span></a> <span class="n">low</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"low"</span><span class="p">)</span> +</span><span id="L-2105"><a href="#L-2105"><span class="linenos">2105</span></a> <span class="n">high</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"high"</span><span class="p">)</span> +</span><span id="L-2106"><a href="#L-2106"><span class="linenos">2106</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"> BETWEEN </span><span class="si">{</span><span class="n">low</span><span class="si">}</span><span class="s2"> AND </span><span class="si">{</span><span class="n">high</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2107"><a href="#L-2107"><span class="linenos">2107</span></a> +</span><span id="L-2108"><a href="#L-2108"><span class="linenos">2108</span></a> <span class="k">def</span> <span class="nf">bracket_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Bracket</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2109"><a href="#L-2109"><span class="linenos">2109</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="n">apply_index_offset</span><span class="p">(</span> +</span><span id="L-2110"><a href="#L-2110"><span class="linenos">2110</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> +</span><span id="L-2111"><a href="#L-2111"><span class="linenos">2111</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">,</span> +</span><span id="L-2112"><a href="#L-2112"><span class="linenos">2112</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">INDEX_OFFSET</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">"offset"</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> +</span><span id="L-2113"><a href="#L-2113"><span class="linenos">2113</span></a> <span class="p">)</span> +</span><span id="L-2114"><a href="#L-2114"><span class="linenos">2114</span></a> <span class="n">expressions_sql</span> <span class="o">=</span> <span class="s2">", "</span><span class="o">.</span><span class="n">join</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><span id="L-2115"><a href="#L-2115"><span class="linenos">2115</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">expressions_sql</span><span class="si">}</span><span class="s2">]"</span> +</span><span id="L-2116"><a href="#L-2116"><span class="linenos">2116</span></a> +</span><span id="L-2117"><a href="#L-2117"><span class="linenos">2117</span></a> <span class="k">def</span> <span class="nf">all_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">All</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2118"><a href="#L-2118"><span class="linenos">2118</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ALL </span><span class="si">{</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 class="si">}</span><span class="s2">"</span> +</span><span id="L-2119"><a href="#L-2119"><span class="linenos">2119</span></a> +</span><span id="L-2120"><a href="#L-2120"><span class="linenos">2120</span></a> <span class="k">def</span> <span class="nf">any_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Any</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2121"><a href="#L-2121"><span class="linenos">2121</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-2122"><a href="#L-2122"><span class="linenos">2122</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">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Subqueryable</span><span class="p">):</span> +</span><span id="L-2123"><a href="#L-2123"><span class="linenos">2123</span></a> <span class="n">this</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">this</span><span class="p">)</span> +</span><span id="L-2124"><a href="#L-2124"><span class="linenos">2124</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ANY </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2125"><a href="#L-2125"><span class="linenos">2125</span></a> +</span><span id="L-2126"><a href="#L-2126"><span class="linenos">2126</span></a> <span class="k">def</span> <span class="nf">exists_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Exists</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2127"><a href="#L-2127"><span class="linenos">2127</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"EXISTS</span><span class="si">{</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 class="si">}</span><span class="s2">"</span> +</span><span id="L-2128"><a href="#L-2128"><span class="linenos">2128</span></a> +</span><span id="L-2129"><a href="#L-2129"><span class="linenos">2129</span></a> <span class="k">def</span> <span class="nf">case_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</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="nb">str</span><span class="p">:</span> +</span><span id="L-2130"><a href="#L-2130"><span class="linenos">2130</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-2131"><a href="#L-2131"><span class="linenos">2131</span></a> <span class="n">statements</span> <span class="o">=</span> <span class="p">[</span><span class="sa">f</span><span class="s2">"CASE </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">"CASE"</span><span class="p">]</span> +</span><span id="L-2132"><a href="#L-2132"><span class="linenos">2132</span></a> +</span><span id="L-2133"><a href="#L-2133"><span class="linenos">2133</span></a> <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">args</span><span class="p">[</span><span class="s2">"ifs"</span><span class="p">]:</span> +</span><span id="L-2134"><a href="#L-2134"><span class="linenos">2134</span></a> <span class="n">statements</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="sa">f</span><span class="s2">"WHEN </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">e</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="p">)</span> +</span><span id="L-2135"><a href="#L-2135"><span class="linenos">2135</span></a> <span class="n">statements</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="sa">f</span><span class="s2">"THEN </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">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'true'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> </span><span id="L-2136"><a href="#L-2136"><span class="linenos">2136</span></a> -</span><span id="L-2137"><a href="#L-2137"><span class="linenos">2137</span></a> <span class="n">statements</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"END"</span><span class="p">)</span> +</span><span id="L-2137"><a href="#L-2137"><span class="linenos">2137</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-2138"><a href="#L-2138"><span class="linenos">2138</span></a> -</span><span id="L-2139"><a href="#L-2139"><span class="linenos">2139</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">statements</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-2140"><a href="#L-2140"><span class="linenos">2140</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="n">join</span><span class="p">(</span><span class="n">statements</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-2139"><a href="#L-2139"><span class="linenos">2139</span></a> <span class="k">if</span> <span class="n">default</span><span class="p">:</span> +</span><span id="L-2140"><a href="#L-2140"><span class="linenos">2140</span></a> <span class="n">statements</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="sa">f</span><span class="s2">"ELSE </span><span class="si">{</span><span class="n">default</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> </span><span id="L-2141"><a href="#L-2141"><span class="linenos">2141</span></a> -</span><span id="L-2142"><a href="#L-2142"><span class="linenos">2142</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">statements</span><span class="p">)</span> +</span><span id="L-2142"><a href="#L-2142"><span class="linenos">2142</span></a> <span class="n">statements</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"END"</span><span class="p">)</span> </span><span id="L-2143"><a href="#L-2143"><span class="linenos">2143</span></a> -</span><span id="L-2144"><a href="#L-2144"><span class="linenos">2144</span></a> <span class="k">def</span> <span class="nf">constraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Constraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2145"><a href="#L-2145"><span class="linenos">2145</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-2146"><a href="#L-2146"><span class="linenos">2146</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-2147"><a href="#L-2147"><span class="linenos">2147</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CONSTRAINT </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-2144"><a href="#L-2144"><span class="linenos">2144</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">statements</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-2145"><a href="#L-2145"><span class="linenos">2145</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="n">join</span><span class="p">(</span><span class="n">statements</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-2146"><a href="#L-2146"><span class="linenos">2146</span></a> +</span><span id="L-2147"><a href="#L-2147"><span class="linenos">2147</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">statements</span><span class="p">)</span> </span><span id="L-2148"><a href="#L-2148"><span class="linenos">2148</span></a> -</span><span id="L-2149"><a href="#L-2149"><span class="linenos">2149</span></a> <span class="k">def</span> <span class="nf">nextvaluefor_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">NextValueFor</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2150"><a href="#L-2150"><span class="linenos">2150</span></a> <span class="n">order</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">"order"</span><span class="p">)</span> -</span><span id="L-2151"><a href="#L-2151"><span class="linenos">2151</span></a> <span class="n">order</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" OVER (</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">order_sql</span><span class="p">(</span><span class="n">order</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 class="k">if</span> <span class="n">order</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-2152"><a href="#L-2152"><span class="linenos">2152</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"NEXT VALUE FOR </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">order</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2149"><a href="#L-2149"><span class="linenos">2149</span></a> <span class="k">def</span> <span class="nf">constraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Constraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2150"><a href="#L-2150"><span class="linenos">2150</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-2151"><a href="#L-2151"><span class="linenos">2151</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-2152"><a href="#L-2152"><span class="linenos">2152</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CONSTRAINT </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-2153"><a href="#L-2153"><span class="linenos">2153</span></a> -</span><span id="L-2154"><a href="#L-2154"><span class="linenos">2154</span></a> <span class="k">def</span> <span class="nf">extract_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Extract</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2155"><a href="#L-2155"><span class="linenos">2155</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 class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">EXTRACT_ALLOWS_QUOTES</span> <span class="k">else</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><span id="L-2156"><a href="#L-2156"><span class="linenos">2156</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-2157"><a href="#L-2157"><span class="linenos">2157</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"EXTRACT(</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> FROM </span><span class="si">{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="L-2154"><a href="#L-2154"><span class="linenos">2154</span></a> <span class="k">def</span> <span class="nf">nextvaluefor_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">NextValueFor</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2155"><a href="#L-2155"><span class="linenos">2155</span></a> <span class="n">order</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">"order"</span><span class="p">)</span> +</span><span id="L-2156"><a href="#L-2156"><span class="linenos">2156</span></a> <span class="n">order</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" OVER (</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">order_sql</span><span class="p">(</span><span class="n">order</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 class="k">if</span> <span class="n">order</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-2157"><a href="#L-2157"><span class="linenos">2157</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"NEXT VALUE FOR </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">order</span><span class="si">}</span><span class="s2">"</span> </span><span id="L-2158"><a href="#L-2158"><span class="linenos">2158</span></a> -</span><span id="L-2159"><a href="#L-2159"><span class="linenos">2159</span></a> <span class="k">def</span> <span class="nf">trim_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Trim</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2160"><a href="#L-2160"><span class="linenos">2160</span></a> <span class="n">trim_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">"position"</span><span class="p">)</span> -</span><span id="L-2161"><a href="#L-2161"><span class="linenos">2161</span></a> -</span><span id="L-2162"><a href="#L-2162"><span class="linenos">2162</span></a> <span class="k">if</span> <span class="n">trim_type</span> <span class="o">==</span> <span class="s2">"LEADING"</span><span class="p">:</span> -</span><span id="L-2163"><a href="#L-2163"><span class="linenos">2163</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">"LTRIM"</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-2164"><a href="#L-2164"><span class="linenos">2164</span></a> <span class="k">elif</span> <span class="n">trim_type</span> <span class="o">==</span> <span class="s2">"TRAILING"</span><span class="p">:</span> -</span><span id="L-2165"><a href="#L-2165"><span class="linenos">2165</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">"RTRIM"</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-2166"><a href="#L-2166"><span class="linenos">2166</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-2167"><a href="#L-2167"><span class="linenos">2167</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">"TRIM"</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="n">expression</span><span class="o">.</span><span class="n">expression</span><span class="p">)</span> -</span><span id="L-2168"><a href="#L-2168"><span class="linenos">2168</span></a> -</span><span id="L-2169"><a href="#L-2169"><span class="linenos">2169</span></a> <span class="k">def</span> <span class="nf">concat_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Concat</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2170"><a href="#L-2170"><span class="linenos">2170</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> -</span><span id="L-2171"><a href="#L-2171"><span class="linenos">2171</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">STRICT_STRING_CONCAT</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">"safe"</span><span class="p">):</span> -</span><span id="L-2172"><a href="#L-2172"><span class="linenos">2172</span></a> <span class="n">expressions</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">expressions</span><span class="p">]</span> -</span><span id="L-2173"><a href="#L-2173"><span class="linenos">2173</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="n">expressions</span><span class="p">)</span> -</span><span id="L-2174"><a href="#L-2174"><span class="linenos">2174</span></a> -</span><span id="L-2175"><a href="#L-2175"><span class="linenos">2175</span></a> <span class="k">def</span> <span class="nf">check_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Check</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2176"><a href="#L-2176"><span class="linenos">2176</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="n">key</span><span class="o">=</span><span class="s2">"this"</span><span class="p">)</span> -</span><span id="L-2177"><a href="#L-2177"><span class="linenos">2177</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CHECK (</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="L-2159"><a href="#L-2159"><span class="linenos">2159</span></a> <span class="k">def</span> <span class="nf">extract_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Extract</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2160"><a href="#L-2160"><span class="linenos">2160</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 class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">EXTRACT_ALLOWS_QUOTES</span> <span class="k">else</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><span id="L-2161"><a href="#L-2161"><span class="linenos">2161</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-2162"><a href="#L-2162"><span class="linenos">2162</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"EXTRACT(</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> FROM </span><span class="si">{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="L-2163"><a href="#L-2163"><span class="linenos">2163</span></a> +</span><span id="L-2164"><a href="#L-2164"><span class="linenos">2164</span></a> <span class="k">def</span> <span class="nf">trim_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Trim</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2165"><a href="#L-2165"><span class="linenos">2165</span></a> <span class="n">trim_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">"position"</span><span class="p">)</span> +</span><span id="L-2166"><a href="#L-2166"><span class="linenos">2166</span></a> +</span><span id="L-2167"><a href="#L-2167"><span class="linenos">2167</span></a> <span class="k">if</span> <span class="n">trim_type</span> <span class="o">==</span> <span class="s2">"LEADING"</span><span class="p">:</span> +</span><span id="L-2168"><a href="#L-2168"><span class="linenos">2168</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">"LTRIM"</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-2169"><a href="#L-2169"><span class="linenos">2169</span></a> <span class="k">elif</span> <span class="n">trim_type</span> <span class="o">==</span> <span class="s2">"TRAILING"</span><span class="p">:</span> +</span><span id="L-2170"><a href="#L-2170"><span class="linenos">2170</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">"RTRIM"</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-2171"><a href="#L-2171"><span class="linenos">2171</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-2172"><a href="#L-2172"><span class="linenos">2172</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">"TRIM"</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="n">expression</span><span class="o">.</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-2173"><a href="#L-2173"><span class="linenos">2173</span></a> +</span><span id="L-2174"><a href="#L-2174"><span class="linenos">2174</span></a> <span class="k">def</span> <span class="nf">convert_concat_args</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Concat</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">ConcatWs</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]:</span> +</span><span id="L-2175"><a href="#L-2175"><span class="linenos">2175</span></a> <span class="n">args</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> +</span><span id="L-2176"><a href="#L-2176"><span class="linenos">2176</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">ConcatWs</span><span class="p">):</span> +</span><span id="L-2177"><a href="#L-2177"><span class="linenos">2177</span></a> <span class="n">args</span> <span class="o">=</span> <span class="n">args</span><span class="p">[</span><span class="mi">1</span><span class="p">:]</span> <span class="c1"># Skip the delimiter</span> </span><span id="L-2178"><a href="#L-2178"><span class="linenos">2178</span></a> -</span><span id="L-2179"><a href="#L-2179"><span class="linenos">2179</span></a> <span class="k">def</span> <span class="nf">foreignkey_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ForeignKey</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2180"><a href="#L-2180"><span class="linenos">2180</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-2181"><a href="#L-2181"><span class="linenos">2181</span></a> <span class="n">reference</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"reference"</span><span class="p">)</span> -</span><span id="L-2182"><a href="#L-2182"><span class="linenos">2182</span></a> <span class="n">reference</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">reference</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">reference</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-2183"><a href="#L-2183"><span class="linenos">2183</span></a> <span class="n">delete</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"delete"</span><span class="p">)</span> -</span><span id="L-2184"><a href="#L-2184"><span class="linenos">2184</span></a> <span class="n">delete</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" ON DELETE </span><span class="si">{</span><span class="n">delete</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">delete</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">update</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"update"</span><span class="p">)</span> -</span><span id="L-2186"><a href="#L-2186"><span class="linenos">2186</span></a> <span class="n">update</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" ON UPDATE </span><span class="si">{</span><span class="n">update</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">update</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">"FOREIGN KEY (</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">reference</span><span class="si">}{</span><span class="n">delete</span><span class="si">}{</span><span class="n">update</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">primarykey_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ForeignKey</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">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-2191"><a href="#L-2191"><span class="linenos">2191</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-2192"><a href="#L-2192"><span class="linenos">2192</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-2193"><a href="#L-2193"><span class="linenos">2193</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PRIMARY KEY (</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">options</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2194"><a href="#L-2194"><span class="linenos">2194</span></a> -</span><span id="L-2195"><a href="#L-2195"><span class="linenos">2195</span></a> <span class="k">def</span> <span class="nf">if_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">If</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2196"><a href="#L-2196"><span class="linenos">2196</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">case_sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Case</span><span class="p">(</span><span class="n">ifs</span><span class="o">=</span><span class="p">[</span><span class="n">expression</span><span class="p">],</span> <span class="n">default</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-2197"><a href="#L-2197"><span class="linenos">2197</span></a> -</span><span id="L-2198"><a href="#L-2198"><span class="linenos">2198</span></a> <span class="k">def</span> <span class="nf">matchagainst_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">MatchAgainst</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2199"><a href="#L-2199"><span class="linenos">2199</span></a> <span class="n">modifier</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">"modifier"</span><span class="p">)</span> -</span><span id="L-2200"><a href="#L-2200"><span class="linenos">2200</span></a> <span class="n">modifier</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">modifier</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">modifier</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="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">func</span><span class="p">(</span><span class="s1">'MATCH'</span><span class="p">,</span><span class="w"> </span><span class="o">*</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span><span class="si">}</span><span class="s2"> AGAINST(</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">modifier</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="L-2202"><a href="#L-2202"><span class="linenos">2202</span></a> -</span><span id="L-2203"><a href="#L-2203"><span class="linenos">2203</span></a> <span class="k">def</span> <span class="nf">jsonkeyvalue_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">JSONKeyValue</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2204"><a href="#L-2204"><span class="linenos">2204</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-2205"><a href="#L-2205"><span class="linenos">2205</span></a> -</span><span id="L-2206"><a href="#L-2206"><span class="linenos">2206</span></a> <span class="k">def</span> <span class="nf">formatjson_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">FormatJson</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2207"><a href="#L-2207"><span class="linenos">2207</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"> FORMAT JSON"</span> -</span><span id="L-2208"><a href="#L-2208"><span class="linenos">2208</span></a> -</span><span id="L-2209"><a href="#L-2209"><span class="linenos">2209</span></a> <span class="k">def</span> <span class="nf">jsonobject_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">JSONObject</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="n">null_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">"null_handling"</span><span class="p">)</span> -</span><span id="L-2211"><a href="#L-2211"><span class="linenos">2211</span></a> <span class="n">null_handling</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">null_handling</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">null_handling</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-2212"><a href="#L-2212"><span class="linenos">2212</span></a> <span class="n">unique_keys</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">"unique_keys"</span><span class="p">)</span> -</span><span id="L-2213"><a href="#L-2213"><span class="linenos">2213</span></a> <span class="k">if</span> <span class="n">unique_keys</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="L-2214"><a href="#L-2214"><span class="linenos">2214</span></a> <span class="n">unique_keys</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="s1">'WITH'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">unique_keys</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">'WITHOUT'</span><span class="si">}</span><span class="s2"> UNIQUE KEYS"</span> -</span><span id="L-2215"><a href="#L-2215"><span class="linenos">2215</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-2216"><a href="#L-2216"><span class="linenos">2216</span></a> <span class="n">unique_keys</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="L-2217"><a href="#L-2217"><span class="linenos">2217</span></a> <span class="n">return_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">"return_type"</span><span class="p">)</span> -</span><span id="L-2218"><a href="#L-2218"><span class="linenos">2218</span></a> <span class="n">return_type</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" RETURNING </span><span class="si">{</span><span class="n">return_type</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">return_type</span> <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="n">encoding</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"encoding"</span><span class="p">)</span> -</span><span id="L-2220"><a href="#L-2220"><span class="linenos">2220</span></a> <span class="n">encoding</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" ENCODING </span><span class="si">{</span><span class="n">encoding</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">encoding</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-2221"><a href="#L-2221"><span class="linenos">2221</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-2222"><a href="#L-2222"><span class="linenos">2222</span></a> <span class="s2">"JSON_OBJECT"</span><span class="p">,</span> -</span><span id="L-2223"><a href="#L-2223"><span class="linenos">2223</span></a> <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-2224"><a href="#L-2224"><span class="linenos">2224</span></a> <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">null_handling</span><span class="si">}{</span><span class="n">unique_keys</span><span class="si">}{</span><span class="n">return_type</span><span class="si">}{</span><span class="n">encoding</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="L-2225"><a href="#L-2225"><span class="linenos">2225</span></a> <span class="p">)</span> -</span><span id="L-2226"><a href="#L-2226"><span class="linenos">2226</span></a> -</span><span id="L-2227"><a href="#L-2227"><span class="linenos">2227</span></a> <span class="k">def</span> <span class="nf">jsonarray_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">JSONArray</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2228"><a href="#L-2228"><span class="linenos">2228</span></a> <span class="n">null_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">"null_handling"</span><span class="p">)</span> -</span><span id="L-2229"><a href="#L-2229"><span class="linenos">2229</span></a> <span class="n">null_handling</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">null_handling</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">null_handling</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-2230"><a href="#L-2230"><span class="linenos">2230</span></a> <span class="n">return_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">"return_type"</span><span class="p">)</span> -</span><span id="L-2231"><a href="#L-2231"><span class="linenos">2231</span></a> <span class="n">return_type</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" RETURNING </span><span class="si">{</span><span class="n">return_type</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">return_type</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-2232"><a href="#L-2232"><span class="linenos">2232</span></a> <span class="n">strict</span> <span class="o">=</span> <span class="s2">" STRICT"</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">"strict"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-2233"><a href="#L-2233"><span class="linenos">2233</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-2234"><a href="#L-2234"><span class="linenos">2234</span></a> <span class="s2">"JSON_ARRAY"</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 class="n">suffix</span><span class="o">=</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">null_handling</span><span class="si">}{</span><span class="n">return_type</span><span class="si">}{</span><span class="n">strict</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="L-2235"><a href="#L-2235"><span class="linenos">2235</span></a> <span class="p">)</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">def</span> <span class="nf">jsonarrayagg_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">JSONArrayAgg</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2238"><a href="#L-2238"><span class="linenos">2238</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-2239"><a href="#L-2239"><span class="linenos">2239</span></a> <span class="n">order</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"order"</span><span class="p">)</span> -</span><span id="L-2240"><a href="#L-2240"><span class="linenos">2240</span></a> <span class="n">null_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">"null_handling"</span><span class="p">)</span> -</span><span id="L-2241"><a href="#L-2241"><span class="linenos">2241</span></a> <span class="n">null_handling</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">null_handling</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">null_handling</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-2242"><a href="#L-2242"><span class="linenos">2242</span></a> <span class="n">return_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">"return_type"</span><span class="p">)</span> -</span><span id="L-2243"><a href="#L-2243"><span class="linenos">2243</span></a> <span class="n">return_type</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" RETURNING </span><span class="si">{</span><span class="n">return_type</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">return_type</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-2244"><a href="#L-2244"><span class="linenos">2244</span></a> <span class="n">strict</span> <span class="o">=</span> <span class="s2">" STRICT"</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">"strict"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-2245"><a href="#L-2245"><span class="linenos">2245</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-2246"><a href="#L-2246"><span class="linenos">2246</span></a> <span class="s2">"JSON_ARRAYAGG"</span><span class="p">,</span> -</span><span id="L-2247"><a href="#L-2247"><span class="linenos">2247</span></a> <span class="n">this</span><span class="p">,</span> -</span><span id="L-2248"><a href="#L-2248"><span class="linenos">2248</span></a> <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">order</span><span class="si">}{</span><span class="n">null_handling</span><span class="si">}{</span><span class="n">return_type</span><span class="si">}{</span><span class="n">strict</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="L-2249"><a href="#L-2249"><span class="linenos">2249</span></a> <span class="p">)</span> -</span><span id="L-2250"><a href="#L-2250"><span class="linenos">2250</span></a> -</span><span id="L-2251"><a href="#L-2251"><span class="linenos">2251</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-2252"><a href="#L-2252"><span class="linenos">2252</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-2253"><a href="#L-2253"><span class="linenos">2253</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-2254"><a href="#L-2254"><span class="linenos">2254</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-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="n">nested_schema</span><span class="p">:</span> -</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">"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-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="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-2260"><a href="#L-2260"><span class="linenos">2260</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-2261"><a href="#L-2261"><span class="linenos">2261</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-2262"><a href="#L-2262"><span class="linenos">2262</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-2263"><a href="#L-2263"><span class="linenos">2263</span></a> -</span><span id="L-2264"><a href="#L-2264"><span class="linenos">2264</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-2265"><a href="#L-2265"><span class="linenos">2265</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-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">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-2268"><a href="#L-2268"><span class="linenos">2268</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-2269"><a href="#L-2269"><span class="linenos">2269</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-2270"><a href="#L-2270"><span class="linenos">2270</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-2271"><a href="#L-2271"><span class="linenos">2271</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-2272"><a href="#L-2272"><span class="linenos">2272</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-2273"><a href="#L-2273"><span class="linenos">2273</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-2274"><a href="#L-2274"><span class="linenos">2274</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-2275"><a href="#L-2275"><span class="linenos">2275</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-2276"><a href="#L-2276"><span class="linenos">2276</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-2277"><a href="#L-2277"><span class="linenos">2277</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-2278"><a href="#L-2278"><span class="linenos">2278</span></a> <span class="p">)</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">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-2281"><a href="#L-2281"><span class="linenos">2281</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-2282"><a href="#L-2282"><span class="linenos">2282</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-2283"><a href="#L-2283"><span class="linenos">2283</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-2284"><a href="#L-2284"><span class="linenos">2284</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-2285"><a href="#L-2285"><span class="linenos">2285</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-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">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-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">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-2289"><a href="#L-2289"><span class="linenos">2289</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-2290"><a href="#L-2290"><span class="linenos">2290</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-2291"><a href="#L-2291"><span class="linenos">2291</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-2292"><a href="#L-2292"><span class="linenos">2292</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-2293"><a href="#L-2293"><span class="linenos">2293</span></a> <span class="n">with_</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="L-2294"><a href="#L-2294"><span class="linenos">2294</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-2295"><a href="#L-2295"><span class="linenos">2295</span></a> <span class="k">if</span> <span class="n">expressions</span> -</span><span id="L-2296"><a href="#L-2296"><span class="linenos">2296</span></a> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-2297"><a href="#L-2297"><span class="linenos">2297</span></a> <span class="p">)</span> -</span><span id="L-2298"><a href="#L-2298"><span class="linenos">2298</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-2299"><a href="#L-2299"><span class="linenos">2299</span></a> -</span><span id="L-2300"><a href="#L-2300"><span class="linenos">2300</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-2301"><a href="#L-2301"><span class="linenos">2301</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-2302"><a href="#L-2302"><span class="linenos">2302</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-2303"><a href="#L-2303"><span class="linenos">2303</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-2304"><a href="#L-2304"><span class="linenos">2304</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-2179"><a href="#L-2179"><span class="linenos">2179</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">STRICT_STRING_CONCAT</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">"safe"</span><span class="p">):</span> +</span><span id="L-2180"><a href="#L-2180"><span class="linenos">2180</span></a> <span class="n">args</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">args</span><span class="p">]</span> +</span><span id="L-2181"><a href="#L-2181"><span class="linenos">2181</span></a> +</span><span id="L-2182"><a href="#L-2182"><span class="linenos">2182</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">CONCAT_COALESCE</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">"coalesce"</span><span class="p">):</span> +</span><span id="L-2183"><a href="#L-2183"><span class="linenos">2183</span></a> <span class="n">args</span> <span class="o">=</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="s2">"coalesce"</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">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="s2">""</span><span class="p">))</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">args</span><span class="p">]</span> +</span><span id="L-2184"><a href="#L-2184"><span class="linenos">2184</span></a> +</span><span id="L-2185"><a href="#L-2185"><span class="linenos">2185</span></a> <span class="k">return</span> <span class="n">args</span> +</span><span id="L-2186"><a href="#L-2186"><span class="linenos">2186</span></a> +</span><span id="L-2187"><a href="#L-2187"><span class="linenos">2187</span></a> <span class="k">def</span> <span class="nf">concat_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Concat</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2188"><a href="#L-2188"><span class="linenos">2188</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">convert_concat_args</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-2189"><a href="#L-2189"><span class="linenos">2189</span></a> +</span><span id="L-2190"><a href="#L-2190"><span class="linenos">2190</span></a> <span class="c1"># Some dialects don't allow a single-argument CONCAT call</span> +</span><span id="L-2191"><a href="#L-2191"><span class="linenos">2191</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">SUPPORTS_SINGLE_ARG_CONCAT</span> <span class="ow">and</span> <span class="nb">len</span><span class="p">(</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-2192"><a href="#L-2192"><span class="linenos">2192</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">expressions</span><span class="p">[</span><span class="mi">0</span><span class="p">])</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">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="n">expressions</span><span class="p">)</span> +</span><span id="L-2195"><a href="#L-2195"><span class="linenos">2195</span></a> +</span><span id="L-2196"><a href="#L-2196"><span class="linenos">2196</span></a> <span class="k">def</span> <span class="nf">concatws_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ConcatWs</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2197"><a href="#L-2197"><span class="linenos">2197</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-2198"><a href="#L-2198"><span class="linenos">2198</span></a> <span class="s2">"CONCAT_WS"</span><span class="p">,</span> <span class="n">seq_get</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="mi">0</span><span class="p">),</span> <span class="o">*</span><span class="bp">self</span><span class="o">.</span><span class="n">convert_concat_args</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-2199"><a href="#L-2199"><span class="linenos">2199</span></a> <span class="p">)</span> +</span><span id="L-2200"><a href="#L-2200"><span class="linenos">2200</span></a> +</span><span id="L-2201"><a href="#L-2201"><span class="linenos">2201</span></a> <span class="k">def</span> <span class="nf">check_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Check</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2202"><a href="#L-2202"><span class="linenos">2202</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="n">key</span><span class="o">=</span><span class="s2">"this"</span><span class="p">)</span> +</span><span id="L-2203"><a href="#L-2203"><span class="linenos">2203</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CHECK (</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="L-2204"><a href="#L-2204"><span class="linenos">2204</span></a> +</span><span id="L-2205"><a href="#L-2205"><span class="linenos">2205</span></a> <span class="k">def</span> <span class="nf">foreignkey_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ForeignKey</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2206"><a href="#L-2206"><span class="linenos">2206</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-2207"><a href="#L-2207"><span class="linenos">2207</span></a> <span class="n">reference</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"reference"</span><span class="p">)</span> +</span><span id="L-2208"><a href="#L-2208"><span class="linenos">2208</span></a> <span class="n">reference</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">reference</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">reference</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-2209"><a href="#L-2209"><span class="linenos">2209</span></a> <span class="n">delete</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"delete"</span><span class="p">)</span> +</span><span id="L-2210"><a href="#L-2210"><span class="linenos">2210</span></a> <span class="n">delete</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" ON DELETE </span><span class="si">{</span><span class="n">delete</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">delete</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-2211"><a href="#L-2211"><span class="linenos">2211</span></a> <span class="n">update</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"update"</span><span class="p">)</span> +</span><span id="L-2212"><a href="#L-2212"><span class="linenos">2212</span></a> <span class="n">update</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" ON UPDATE </span><span class="si">{</span><span class="n">update</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">update</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-2213"><a href="#L-2213"><span class="linenos">2213</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"FOREIGN KEY (</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">reference</span><span class="si">}{</span><span class="n">delete</span><span class="si">}{</span><span class="n">update</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2214"><a href="#L-2214"><span class="linenos">2214</span></a> +</span><span id="L-2215"><a href="#L-2215"><span class="linenos">2215</span></a> <span class="k">def</span> <span class="nf">primarykey_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ForeignKey</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2216"><a href="#L-2216"><span class="linenos">2216</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-2217"><a href="#L-2217"><span class="linenos">2217</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-2218"><a href="#L-2218"><span class="linenos">2218</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-2219"><a href="#L-2219"><span class="linenos">2219</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PRIMARY KEY (</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">options</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2220"><a href="#L-2220"><span class="linenos">2220</span></a> +</span><span id="L-2221"><a href="#L-2221"><span class="linenos">2221</span></a> <span class="k">def</span> <span class="nf">if_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">If</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2222"><a href="#L-2222"><span class="linenos">2222</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">case_sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Case</span><span class="p">(</span><span class="n">ifs</span><span class="o">=</span><span class="p">[</span><span class="n">expression</span><span class="p">],</span> <span class="n">default</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-2223"><a href="#L-2223"><span class="linenos">2223</span></a> +</span><span id="L-2224"><a href="#L-2224"><span class="linenos">2224</span></a> <span class="k">def</span> <span class="nf">matchagainst_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">MatchAgainst</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2225"><a href="#L-2225"><span class="linenos">2225</span></a> <span class="n">modifier</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">"modifier"</span><span class="p">)</span> +</span><span id="L-2226"><a href="#L-2226"><span class="linenos">2226</span></a> <span class="n">modifier</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">modifier</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">modifier</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 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">func</span><span class="p">(</span><span class="s1">'MATCH'</span><span class="p">,</span><span class="w"> </span><span class="o">*</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span><span class="si">}</span><span class="s2"> AGAINST(</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">modifier</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="L-2228"><a href="#L-2228"><span class="linenos">2228</span></a> +</span><span id="L-2229"><a href="#L-2229"><span class="linenos">2229</span></a> <span class="k">def</span> <span class="nf">jsonkeyvalue_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">JSONKeyValue</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2230"><a href="#L-2230"><span class="linenos">2230</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-2231"><a href="#L-2231"><span class="linenos">2231</span></a> +</span><span id="L-2232"><a href="#L-2232"><span class="linenos">2232</span></a> <span class="k">def</span> <span class="nf">formatjson_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">FormatJson</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2233"><a href="#L-2233"><span class="linenos">2233</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"> FORMAT JSON"</span> +</span><span id="L-2234"><a href="#L-2234"><span class="linenos">2234</span></a> +</span><span id="L-2235"><a href="#L-2235"><span class="linenos">2235</span></a> <span class="k">def</span> <span class="nf">jsonobject_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">JSONObject</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2236"><a href="#L-2236"><span class="linenos">2236</span></a> <span class="n">null_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">"null_handling"</span><span class="p">)</span> +</span><span id="L-2237"><a href="#L-2237"><span class="linenos">2237</span></a> <span class="n">null_handling</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">null_handling</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">null_handling</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-2238"><a href="#L-2238"><span class="linenos">2238</span></a> <span class="n">unique_keys</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">"unique_keys"</span><span class="p">)</span> +</span><span id="L-2239"><a href="#L-2239"><span class="linenos">2239</span></a> <span class="k">if</span> <span class="n">unique_keys</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-2240"><a href="#L-2240"><span class="linenos">2240</span></a> <span class="n">unique_keys</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="s1">'WITH'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">unique_keys</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">'WITHOUT'</span><span class="si">}</span><span class="s2"> UNIQUE KEYS"</span> +</span><span id="L-2241"><a href="#L-2241"><span class="linenos">2241</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-2242"><a href="#L-2242"><span class="linenos">2242</span></a> <span class="n">unique_keys</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="L-2243"><a href="#L-2243"><span class="linenos">2243</span></a> <span class="n">return_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">"return_type"</span><span class="p">)</span> +</span><span id="L-2244"><a href="#L-2244"><span class="linenos">2244</span></a> <span class="n">return_type</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" RETURNING </span><span class="si">{</span><span class="n">return_type</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">return_type</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-2245"><a href="#L-2245"><span class="linenos">2245</span></a> <span class="n">encoding</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"encoding"</span><span class="p">)</span> +</span><span id="L-2246"><a href="#L-2246"><span class="linenos">2246</span></a> <span class="n">encoding</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" ENCODING </span><span class="si">{</span><span class="n">encoding</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">encoding</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 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-2248"><a href="#L-2248"><span class="linenos">2248</span></a> <span class="s2">"JSON_OBJECT"</span><span class="p">,</span> +</span><span id="L-2249"><a href="#L-2249"><span class="linenos">2249</span></a> <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-2250"><a href="#L-2250"><span class="linenos">2250</span></a> <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">null_handling</span><span class="si">}{</span><span class="n">unique_keys</span><span class="si">}{</span><span class="n">return_type</span><span class="si">}{</span><span class="n">encoding</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="L-2251"><a href="#L-2251"><span class="linenos">2251</span></a> <span class="p">)</span> +</span><span id="L-2252"><a href="#L-2252"><span class="linenos">2252</span></a> +</span><span id="L-2253"><a href="#L-2253"><span class="linenos">2253</span></a> <span class="k">def</span> <span class="nf">jsonarray_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">JSONArray</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2254"><a href="#L-2254"><span class="linenos">2254</span></a> <span class="n">null_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">"null_handling"</span><span class="p">)</span> +</span><span id="L-2255"><a href="#L-2255"><span class="linenos">2255</span></a> <span class="n">null_handling</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">null_handling</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">null_handling</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-2256"><a href="#L-2256"><span class="linenos">2256</span></a> <span class="n">return_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">"return_type"</span><span class="p">)</span> +</span><span id="L-2257"><a href="#L-2257"><span class="linenos">2257</span></a> <span class="n">return_type</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" RETURNING </span><span class="si">{</span><span class="n">return_type</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">return_type</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="n">strict</span> <span class="o">=</span> <span class="s2">" STRICT"</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">"strict"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-2259"><a href="#L-2259"><span class="linenos">2259</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-2260"><a href="#L-2260"><span class="linenos">2260</span></a> <span class="s2">"JSON_ARRAY"</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 class="n">suffix</span><span class="o">=</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">null_handling</span><span class="si">}{</span><span class="n">return_type</span><span class="si">}{</span><span class="n">strict</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 class="p">)</span> +</span><span id="L-2262"><a href="#L-2262"><span class="linenos">2262</span></a> +</span><span id="L-2263"><a href="#L-2263"><span class="linenos">2263</span></a> <span class="k">def</span> <span class="nf">jsonarrayagg_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">JSONArrayAgg</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2264"><a href="#L-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="L-2265"><a href="#L-2265"><span class="linenos">2265</span></a> <span class="n">order</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"order"</span><span class="p">)</span> +</span><span id="L-2266"><a href="#L-2266"><span class="linenos">2266</span></a> <span class="n">null_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">"null_handling"</span><span class="p">)</span> +</span><span id="L-2267"><a href="#L-2267"><span class="linenos">2267</span></a> <span class="n">null_handling</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">null_handling</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">null_handling</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="n">return_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">"return_type"</span><span class="p">)</span> +</span><span id="L-2269"><a href="#L-2269"><span class="linenos">2269</span></a> <span class="n">return_type</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" RETURNING </span><span class="si">{</span><span class="n">return_type</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">return_type</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-2270"><a href="#L-2270"><span class="linenos">2270</span></a> <span class="n">strict</span> <span class="o">=</span> <span class="s2">" STRICT"</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">"strict"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</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><span id="L-2272"><a href="#L-2272"><span class="linenos">2272</span></a> <span class="s2">"JSON_ARRAYAGG"</span><span class="p">,</span> +</span><span id="L-2273"><a href="#L-2273"><span class="linenos">2273</span></a> <span class="n">this</span><span class="p">,</span> +</span><span id="L-2274"><a href="#L-2274"><span class="linenos">2274</span></a> <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">order</span><span class="si">}{</span><span class="n">null_handling</span><span class="si">}{</span><span class="n">return_type</span><span class="si">}{</span><span class="n">strict</span><span class="si">}</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="p">)</span> +</span><span id="L-2276"><a href="#L-2276"><span class="linenos">2276</span></a> +</span><span id="L-2277"><a href="#L-2277"><span class="linenos">2277</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-2278"><a href="#L-2278"><span class="linenos">2278</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-2279"><a href="#L-2279"><span class="linenos">2279</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-2280"><a href="#L-2280"><span class="linenos">2280</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-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">if</span> <span class="n">nested_schema</span><span class="p">:</span> +</span><span id="L-2283"><a href="#L-2283"><span class="linenos">2283</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-2284"><a href="#L-2284"><span class="linenos">2284</span></a> +</span><span id="L-2285"><a href="#L-2285"><span class="linenos">2285</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-2286"><a href="#L-2286"><span class="linenos">2286</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-2287"><a href="#L-2287"><span class="linenos">2287</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-2288"><a href="#L-2288"><span class="linenos">2288</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-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">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-2291"><a href="#L-2291"><span class="linenos">2291</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-2292"><a href="#L-2292"><span class="linenos">2292</span></a> +</span><span id="L-2293"><a href="#L-2293"><span class="linenos">2293</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-2294"><a href="#L-2294"><span class="linenos">2294</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-2295"><a href="#L-2295"><span class="linenos">2295</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-2296"><a href="#L-2296"><span class="linenos">2296</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-2297"><a href="#L-2297"><span class="linenos">2297</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-2298"><a href="#L-2298"><span class="linenos">2298</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-2299"><a href="#L-2299"><span class="linenos">2299</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-2300"><a href="#L-2300"><span class="linenos">2300</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-2301"><a href="#L-2301"><span class="linenos">2301</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-2302"><a href="#L-2302"><span class="linenos">2302</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-2303"><a href="#L-2303"><span class="linenos">2303</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-2304"><a href="#L-2304"><span class="linenos">2304</span></a> <span class="p">)</span> </span><span id="L-2305"><a href="#L-2305"><span class="linenos">2305</span></a> -</span><span id="L-2306"><a href="#L-2306"><span class="linenos">2306</span></a> <span class="k">if</span> <span class="n">query</span><span class="p">:</span> -</span><span id="L-2307"><a href="#L-2307"><span class="linenos">2307</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-2308"><a href="#L-2308"><span class="linenos">2308</span></a> <span class="k">elif</span> <span class="n">unnest</span><span class="p">:</span> -</span><span id="L-2309"><a href="#L-2309"><span class="linenos">2309</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-2310"><a href="#L-2310"><span class="linenos">2310</span></a> <span class="k">elif</span> <span class="n">field</span><span class="p">:</span> -</span><span id="L-2311"><a href="#L-2311"><span class="linenos">2311</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-2312"><a href="#L-2312"><span class="linenos">2312</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-2313"><a href="#L-2313"><span class="linenos">2313</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-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">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-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="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-2318"><a href="#L-2318"><span class="linenos">2318</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-2319"><a href="#L-2319"><span class="linenos">2319</span></a> -</span><span id="L-2320"><a href="#L-2320"><span class="linenos">2320</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-2321"><a href="#L-2321"><span class="linenos">2321</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-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">INTERVAL_ALLOWS_PLURAL_FORM</span><span class="p">:</span> -</span><span id="L-2323"><a href="#L-2323"><span class="linenos">2323</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-2324"><a href="#L-2324"><span class="linenos">2324</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-2306"><a href="#L-2306"><span class="linenos">2306</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-2307"><a href="#L-2307"><span class="linenos">2307</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-2308"><a href="#L-2308"><span class="linenos">2308</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-2309"><a href="#L-2309"><span class="linenos">2309</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-2310"><a href="#L-2310"><span class="linenos">2310</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-2311"><a href="#L-2311"><span class="linenos">2311</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-2312"><a href="#L-2312"><span class="linenos">2312</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-2313"><a href="#L-2313"><span class="linenos">2313</span></a> +</span><span id="L-2314"><a href="#L-2314"><span class="linenos">2314</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-2315"><a href="#L-2315"><span class="linenos">2315</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-2316"><a href="#L-2316"><span class="linenos">2316</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-2317"><a href="#L-2317"><span class="linenos">2317</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-2318"><a href="#L-2318"><span class="linenos">2318</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-2319"><a href="#L-2319"><span class="linenos">2319</span></a> <span class="n">with_</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="L-2320"><a href="#L-2320"><span class="linenos">2320</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-2321"><a href="#L-2321"><span class="linenos">2321</span></a> <span class="k">if</span> <span class="n">expressions</span> +</span><span id="L-2322"><a href="#L-2322"><span class="linenos">2322</span></a> <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="p">)</span> +</span><span id="L-2324"><a href="#L-2324"><span class="linenos">2324</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-2325"><a href="#L-2325"><span class="linenos">2325</span></a> -</span><span id="L-2326"><a href="#L-2326"><span class="linenos">2326</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-2327"><a href="#L-2327"><span class="linenos">2327</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-2328"><a href="#L-2328"><span class="linenos">2328</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-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">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-2331"><a href="#L-2331"><span class="linenos">2331</span></a> <span class="k">if</span> <span class="n">this</span><span class="p">:</span> -</span><span id="L-2332"><a href="#L-2332"><span class="linenos">2332</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-2333"><a href="#L-2333"><span class="linenos">2333</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-2334"><a href="#L-2334"><span class="linenos">2334</span></a> -</span><span id="L-2335"><a href="#L-2335"><span class="linenos">2335</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-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">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-2338"><a href="#L-2338"><span class="linenos">2338</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-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">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-2341"><a href="#L-2341"><span class="linenos">2341</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-2342"><a href="#L-2342"><span class="linenos">2342</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-2343"><a href="#L-2343"><span class="linenos">2343</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-2344"><a href="#L-2344"><span class="linenos">2344</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-2345"><a href="#L-2345"><span class="linenos">2345</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-2346"><a href="#L-2346"><span class="linenos">2346</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-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">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-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">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-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">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-2352"><a href="#L-2352"><span class="linenos">2352</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-2353"><a href="#L-2353"><span class="linenos">2353</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-2354"><a href="#L-2354"><span class="linenos">2354</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-2355"><a href="#L-2355"><span class="linenos">2355</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-2356"><a href="#L-2356"><span class="linenos">2356</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-2357"><a href="#L-2357"><span class="linenos">2357</span></a> -</span><span id="L-2358"><a href="#L-2358"><span class="linenos">2358</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-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">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-2361"><a href="#L-2361"><span class="linenos">2361</span></a> <span class="c1"># This makes sure we don't convert "- - 5" to "--5", which is a comment</span> -</span><span id="L-2362"><a href="#L-2362"><span class="linenos">2362</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-2363"><a href="#L-2363"><span class="linenos">2363</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-2364"><a href="#L-2364"><span class="linenos">2364</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-2326"><a href="#L-2326"><span class="linenos">2326</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-2327"><a href="#L-2327"><span class="linenos">2327</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-2328"><a href="#L-2328"><span class="linenos">2328</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-2329"><a href="#L-2329"><span class="linenos">2329</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-2330"><a href="#L-2330"><span class="linenos">2330</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-2331"><a href="#L-2331"><span class="linenos">2331</span></a> +</span><span id="L-2332"><a href="#L-2332"><span class="linenos">2332</span></a> <span class="k">if</span> <span class="n">query</span><span class="p">:</span> +</span><span id="L-2333"><a href="#L-2333"><span class="linenos">2333</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-2334"><a href="#L-2334"><span class="linenos">2334</span></a> <span class="k">elif</span> <span class="n">unnest</span><span class="p">:</span> +</span><span id="L-2335"><a href="#L-2335"><span class="linenos">2335</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-2336"><a href="#L-2336"><span class="linenos">2336</span></a> <span class="k">elif</span> <span class="n">field</span><span class="p">:</span> +</span><span id="L-2337"><a href="#L-2337"><span class="linenos">2337</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-2338"><a href="#L-2338"><span class="linenos">2338</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-2339"><a href="#L-2339"><span class="linenos">2339</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-2340"><a href="#L-2340"><span class="linenos">2340</span></a> +</span><span id="L-2341"><a href="#L-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="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-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">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-2344"><a href="#L-2344"><span class="linenos">2344</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-2345"><a href="#L-2345"><span class="linenos">2345</span></a> +</span><span id="L-2346"><a href="#L-2346"><span class="linenos">2346</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-2347"><a href="#L-2347"><span class="linenos">2347</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-2348"><a href="#L-2348"><span class="linenos">2348</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-2349"><a href="#L-2349"><span class="linenos">2349</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-2350"><a href="#L-2350"><span class="linenos">2350</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-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">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-2353"><a href="#L-2353"><span class="linenos">2353</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-2354"><a href="#L-2354"><span class="linenos">2354</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-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="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-2357"><a href="#L-2357"><span class="linenos">2357</span></a> <span class="k">if</span> <span class="n">this</span><span class="p">:</span> +</span><span id="L-2358"><a href="#L-2358"><span class="linenos">2358</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-2359"><a href="#L-2359"><span class="linenos">2359</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-2360"><a href="#L-2360"><span class="linenos">2360</span></a> +</span><span id="L-2361"><a href="#L-2361"><span class="linenos">2361</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-2362"><a href="#L-2362"><span class="linenos">2362</span></a> +</span><span id="L-2363"><a href="#L-2363"><span class="linenos">2363</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-2364"><a href="#L-2364"><span class="linenos">2364</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-2365"><a href="#L-2365"><span class="linenos">2365</span></a> -</span><span id="L-2366"><a href="#L-2366"><span class="linenos">2366</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-2367"><a href="#L-2367"><span class="linenos">2367</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-2368"><a href="#L-2368"><span class="linenos">2368</span></a> -</span><span id="L-2369"><a href="#L-2369"><span class="linenos">2369</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-2370"><a href="#L-2370"><span class="linenos">2370</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-2371"><a href="#L-2371"><span class="linenos">2371</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-2372"><a href="#L-2372"><span class="linenos">2372</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-2366"><a href="#L-2366"><span class="linenos">2366</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-2367"><a href="#L-2367"><span class="linenos">2367</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-2368"><a href="#L-2368"><span class="linenos">2368</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-2369"><a href="#L-2369"><span class="linenos">2369</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-2370"><a href="#L-2370"><span class="linenos">2370</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-2371"><a href="#L-2371"><span class="linenos">2371</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-2372"><a href="#L-2372"><span class="linenos">2372</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-2373"><a href="#L-2373"><span class="linenos">2373</span></a> -</span><span id="L-2374"><a href="#L-2374"><span class="linenos">2374</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-2375"><a href="#L-2375"><span class="linenos">2375</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-2374"><a href="#L-2374"><span class="linenos">2374</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-2375"><a href="#L-2375"><span class="linenos">2375</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-2376"><a href="#L-2376"><span class="linenos">2376</span></a> -</span><span id="L-2377"><a href="#L-2377"><span class="linenos">2377</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-2378"><a href="#L-2378"><span class="linenos">2378</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-2379"><a href="#L-2379"><span class="linenos">2379</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-2380"><a href="#L-2380"><span class="linenos">2380</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-2381"><a href="#L-2381"><span class="linenos">2381</span></a> -</span><span id="L-2382"><a href="#L-2382"><span class="linenos">2382</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-2383"><a href="#L-2383"><span class="linenos">2383</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-2384"><a href="#L-2384"><span class="linenos">2384</span></a> -</span><span id="L-2385"><a href="#L-2385"><span class="linenos">2385</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-2386"><a href="#L-2386"><span class="linenos">2386</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-2387"><a href="#L-2387"><span class="linenos">2387</span></a> -</span><span id="L-2388"><a href="#L-2388"><span class="linenos">2388</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-2389"><a href="#L-2389"><span class="linenos">2389</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-2390"><a href="#L-2390"><span class="linenos">2390</span></a> -</span><span id="L-2391"><a href="#L-2391"><span class="linenos">2391</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-2392"><a href="#L-2392"><span class="linenos">2392</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-2393"><a href="#L-2393"><span class="linenos">2393</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-2377"><a href="#L-2377"><span class="linenos">2377</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-2378"><a href="#L-2378"><span class="linenos">2378</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-2379"><a href="#L-2379"><span class="linenos">2379</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-2380"><a href="#L-2380"><span class="linenos">2380</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-2381"><a href="#L-2381"><span class="linenos">2381</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-2382"><a href="#L-2382"><span class="linenos">2382</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-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">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-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">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-2387"><a href="#L-2387"><span class="linenos">2387</span></a> <span class="c1"># This makes sure we don't convert "- - 5" to "--5", which is a comment</span> +</span><span id="L-2388"><a href="#L-2388"><span class="linenos">2388</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-2389"><a href="#L-2389"><span class="linenos">2389</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-2390"><a href="#L-2390"><span class="linenos">2390</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-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">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-2393"><a href="#L-2393"><span class="linenos">2393</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-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="n">sqls</span> <span class="o">=</span> <span class="nb">tuple</span><span class="p">(</span> -</span><span id="L-2396"><a href="#L-2396"><span class="linenos">2396</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-2397"><a href="#L-2397"><span class="linenos">2397</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-2398"><a href="#L-2398"><span class="linenos">2398</span></a> <span class="p">)</span> +</span><span id="L-2395"><a href="#L-2395"><span class="linenos">2395</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-2396"><a href="#L-2396"><span class="linenos">2396</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-2397"><a href="#L-2397"><span class="linenos">2397</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-2398"><a href="#L-2398"><span class="linenos">2398</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-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="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-2401"><a href="#L-2401"><span class="linenos">2401</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-2400"><a href="#L-2400"><span class="linenos">2400</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-2401"><a href="#L-2401"><span class="linenos">2401</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-2402"><a href="#L-2402"><span class="linenos">2402</span></a> -</span><span id="L-2403"><a href="#L-2403"><span class="linenos">2403</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-2404"><a href="#L-2404"><span class="linenos">2404</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-2405"><a href="#L-2405"><span class="linenos">2405</span></a> -</span><span id="L-2406"><a href="#L-2406"><span class="linenos">2406</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-2407"><a href="#L-2407"><span class="linenos">2407</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-2408"><a href="#L-2408"><span class="linenos">2408</span></a> -</span><span id="L-2409"><a href="#L-2409"><span class="linenos">2409</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-2410"><a href="#L-2410"><span class="linenos">2410</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-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">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-2413"><a href="#L-2413"><span class="linenos">2413</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-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="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-2416"><a href="#L-2416"><span class="linenos">2416</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-2417"><a href="#L-2417"><span class="linenos">2417</span></a> -</span><span id="L-2418"><a href="#L-2418"><span class="linenos">2418</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-2419"><a href="#L-2419"><span class="linenos">2419</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-2403"><a href="#L-2403"><span class="linenos">2403</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-2404"><a href="#L-2404"><span class="linenos">2404</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-2405"><a href="#L-2405"><span class="linenos">2405</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-2406"><a href="#L-2406"><span class="linenos">2406</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-2407"><a href="#L-2407"><span class="linenos">2407</span></a> +</span><span id="L-2408"><a href="#L-2408"><span class="linenos">2408</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-2409"><a href="#L-2409"><span class="linenos">2409</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-2410"><a href="#L-2410"><span class="linenos">2410</span></a> +</span><span id="L-2411"><a href="#L-2411"><span class="linenos">2411</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-2412"><a href="#L-2412"><span class="linenos">2412</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-2413"><a href="#L-2413"><span class="linenos">2413</span></a> +</span><span id="L-2414"><a href="#L-2414"><span class="linenos">2414</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-2415"><a href="#L-2415"><span class="linenos">2415</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-2416"><a href="#L-2416"><span class="linenos">2416</span></a> +</span><span id="L-2417"><a href="#L-2417"><span class="linenos">2417</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-2418"><a href="#L-2418"><span class="linenos">2418</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-2419"><a href="#L-2419"><span class="linenos">2419</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-2420"><a href="#L-2420"><span class="linenos">2420</span></a> -</span><span id="L-2421"><a href="#L-2421"><span class="linenos">2421</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-2422"><a href="#L-2422"><span class="linenos">2422</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-2423"><a href="#L-2423"><span class="linenos">2423</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-2424"><a href="#L-2424"><span class="linenos">2424</span></a> <span class="n">to_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">"to"</span><span class="p">)</span> -</span><span id="L-2425"><a href="#L-2425"><span class="linenos">2425</span></a> <span class="n">to_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">to_sql</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">to_sql</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-2426"><a href="#L-2426"><span class="linenos">2426</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="n">to_sql</span><span class="si">}{</span><span class="n">format_sql</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="L-2427"><a href="#L-2427"><span class="linenos">2427</span></a> -</span><span id="L-2428"><a href="#L-2428"><span class="linenos">2428</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-2429"><a href="#L-2429"><span class="linenos">2429</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-2430"><a href="#L-2430"><span class="linenos">2430</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-2421"><a href="#L-2421"><span class="linenos">2421</span></a> <span class="n">sqls</span> <span class="o">=</span> <span class="nb">tuple</span><span class="p">(</span> +</span><span id="L-2422"><a href="#L-2422"><span class="linenos">2422</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-2423"><a href="#L-2423"><span class="linenos">2423</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-2424"><a href="#L-2424"><span class="linenos">2424</span></a> <span class="p">)</span> +</span><span id="L-2425"><a href="#L-2425"><span class="linenos">2425</span></a> +</span><span id="L-2426"><a href="#L-2426"><span class="linenos">2426</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-2427"><a href="#L-2427"><span class="linenos">2427</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-2428"><a href="#L-2428"><span class="linenos">2428</span></a> +</span><span id="L-2429"><a href="#L-2429"><span class="linenos">2429</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-2430"><a href="#L-2430"><span class="linenos">2430</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-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">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-2433"><a href="#L-2433"><span class="linenos">2433</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-2434"><a href="#L-2434"><span class="linenos">2434</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-2435"><a href="#L-2435"><span class="linenos">2435</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-2436"><a href="#L-2436"><span class="linenos">2436</span></a> -</span><span id="L-2437"><a href="#L-2437"><span class="linenos">2437</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-2438"><a href="#L-2438"><span class="linenos">2438</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-2439"><a href="#L-2439"><span class="linenos">2439</span></a> -</span><span id="L-2440"><a href="#L-2440"><span class="linenos">2440</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-2441"><a href="#L-2441"><span class="linenos">2441</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-2442"><a href="#L-2442"><span class="linenos">2442</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-2443"><a href="#L-2443"><span class="linenos">2443</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-2444"><a href="#L-2444"><span class="linenos">2444</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-2445"><a href="#L-2445"><span class="linenos">2445</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-2432"><a href="#L-2432"><span class="linenos">2432</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-2433"><a href="#L-2433"><span class="linenos">2433</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-2434"><a href="#L-2434"><span class="linenos">2434</span></a> +</span><span id="L-2435"><a href="#L-2435"><span class="linenos">2435</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-2436"><a href="#L-2436"><span class="linenos">2436</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-2437"><a href="#L-2437"><span class="linenos">2437</span></a> +</span><span id="L-2438"><a href="#L-2438"><span class="linenos">2438</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-2439"><a href="#L-2439"><span class="linenos">2439</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-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">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-2442"><a href="#L-2442"><span class="linenos">2442</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-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">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-2445"><a href="#L-2445"><span class="linenos">2445</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-2446"><a href="#L-2446"><span class="linenos">2446</span></a> -</span><span id="L-2447"><a href="#L-2447"><span class="linenos">2447</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-2448"><a href="#L-2448"><span class="linenos">2448</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-2449"><a href="#L-2449"><span class="linenos">2449</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-2450"><a href="#L-2450"><span class="linenos">2450</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-2451"><a href="#L-2451"><span class="linenos">2451</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-2452"><a href="#L-2452"><span class="linenos">2452</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-2453"><a href="#L-2453"><span class="linenos">2453</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-2454"><a href="#L-2454"><span class="linenos">2454</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-2455"><a href="#L-2455"><span class="linenos">2455</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-2456"><a href="#L-2456"><span class="linenos">2456</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-2447"><a href="#L-2447"><span class="linenos">2447</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-2448"><a href="#L-2448"><span class="linenos">2448</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-2449"><a href="#L-2449"><span class="linenos">2449</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-2450"><a href="#L-2450"><span class="linenos">2450</span></a> <span class="n">to_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">"to"</span><span class="p">)</span> +</span><span id="L-2451"><a href="#L-2451"><span class="linenos">2451</span></a> <span class="n">to_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">to_sql</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">to_sql</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-2452"><a href="#L-2452"><span class="linenos">2452</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="n">to_sql</span><span class="si">}{</span><span class="n">format_sql</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><span id="L-2454"><a href="#L-2454"><span class="linenos">2454</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-2455"><a href="#L-2455"><span class="linenos">2455</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-2456"><a href="#L-2456"><span class="linenos">2456</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-2457"><a href="#L-2457"><span class="linenos">2457</span></a> -</span><span id="L-2458"><a href="#L-2458"><span class="linenos">2458</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-2459"><a href="#L-2459"><span class="linenos">2459</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-2460"><a href="#L-2460"><span class="linenos">2460</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-2461"><a href="#L-2461"><span class="linenos">2461</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-2462"><a href="#L-2462"><span class="linenos">2462</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-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">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-2465"><a href="#L-2465"><span class="linenos">2465</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-2466"><a href="#L-2466"><span class="linenos">2466</span></a> -</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">"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-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">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-2470"><a href="#L-2470"><span class="linenos">2470</span></a> <span class="k">return</span> <span class="s2">"BEGIN"</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">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-2473"><a href="#L-2473"><span class="linenos">2473</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-2474"><a href="#L-2474"><span class="linenos">2474</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-2475"><a href="#L-2475"><span class="linenos">2475</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-2476"><a href="#L-2476"><span class="linenos">2476</span></a> -</span><span id="L-2477"><a href="#L-2477"><span class="linenos">2477</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-2478"><a href="#L-2478"><span class="linenos">2478</span></a> -</span><span id="L-2479"><a href="#L-2479"><span class="linenos">2479</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-2480"><a href="#L-2480"><span class="linenos">2480</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-2481"><a href="#L-2481"><span class="linenos">2481</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-2482"><a href="#L-2482"><span class="linenos">2482</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-2458"><a href="#L-2458"><span class="linenos">2458</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-2459"><a href="#L-2459"><span class="linenos">2459</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-2460"><a href="#L-2460"><span class="linenos">2460</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-2461"><a href="#L-2461"><span class="linenos">2461</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-2462"><a href="#L-2462"><span class="linenos">2462</span></a> +</span><span id="L-2463"><a href="#L-2463"><span class="linenos">2463</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-2464"><a href="#L-2464"><span class="linenos">2464</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-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="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-2467"><a href="#L-2467"><span class="linenos">2467</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-2468"><a href="#L-2468"><span class="linenos">2468</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-2469"><a href="#L-2469"><span class="linenos">2469</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-2470"><a href="#L-2470"><span class="linenos">2470</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-2471"><a href="#L-2471"><span class="linenos">2471</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-2472"><a href="#L-2472"><span class="linenos">2472</span></a> +</span><span id="L-2473"><a href="#L-2473"><span class="linenos">2473</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-2474"><a href="#L-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">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-2475"><a href="#L-2475"><span class="linenos">2475</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-2476"><a href="#L-2476"><span class="linenos">2476</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-2477"><a href="#L-2477"><span class="linenos">2477</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-2478"><a href="#L-2478"><span class="linenos">2478</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-2479"><a href="#L-2479"><span class="linenos">2479</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-2480"><a href="#L-2480"><span class="linenos">2480</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-2481"><a href="#L-2481"><span class="linenos">2481</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-2482"><a href="#L-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="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-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="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-2485"><a href="#L-2485"><span class="linenos">2485</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-2486"><a href="#L-2486"><span class="linenos">2486</span></a> -</span><span id="L-2487"><a href="#L-2487"><span class="linenos">2487</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-2488"><a href="#L-2488"><span class="linenos">2488</span></a> <span class="k">if</span> <span class="n">dtype</span><span class="p">:</span> -</span><span id="L-2489"><a href="#L-2489"><span class="linenos">2489</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-2490"><a href="#L-2490"><span class="linenos">2490</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-2491"><a href="#L-2491"><span class="linenos">2491</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-2492"><a href="#L-2492"><span class="linenos">2492</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-2493"><a href="#L-2493"><span class="linenos">2493</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-2484"><a href="#L-2484"><span class="linenos">2484</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-2485"><a href="#L-2485"><span class="linenos">2485</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-2486"><a href="#L-2486"><span class="linenos">2486</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-2487"><a href="#L-2487"><span class="linenos">2487</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-2488"><a href="#L-2488"><span class="linenos">2488</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-2489"><a href="#L-2489"><span class="linenos">2489</span></a> +</span><span id="L-2490"><a href="#L-2490"><span class="linenos">2490</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-2491"><a href="#L-2491"><span class="linenos">2491</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-2492"><a href="#L-2492"><span class="linenos">2492</span></a> +</span><span id="L-2493"><a href="#L-2493"><span class="linenos">2493</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-2494"><a href="#L-2494"><span class="linenos">2494</span></a> -</span><span id="L-2495"><a href="#L-2495"><span class="linenos">2495</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-2496"><a href="#L-2496"><span class="linenos">2496</span></a> <span class="k">if</span> <span class="n">default</span><span class="p">:</span> -</span><span id="L-2497"><a href="#L-2497"><span class="linenos">2497</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-2498"><a href="#L-2498"><span class="linenos">2498</span></a> -</span><span id="L-2499"><a href="#L-2499"><span class="linenos">2499</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-2500"><a href="#L-2500"><span class="linenos">2500</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-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">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-2503"><a href="#L-2503"><span class="linenos">2503</span></a> -</span><span id="L-2504"><a href="#L-2504"><span class="linenos">2504</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-2505"><a href="#L-2505"><span class="linenos">2505</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-2506"><a href="#L-2506"><span class="linenos">2506</span></a> <span class="c1"># Remove db from tables</span> -</span><span id="L-2507"><a href="#L-2507"><span class="linenos">2507</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-2508"><a href="#L-2508"><span class="linenos">2508</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-2509"><a href="#L-2509"><span class="linenos">2509</span></a> <span class="p">)</span> -</span><span id="L-2510"><a href="#L-2510"><span class="linenos">2510</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-2511"><a href="#L-2511"><span class="linenos">2511</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-2495"><a href="#L-2495"><span class="linenos">2495</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-2496"><a href="#L-2496"><span class="linenos">2496</span></a> <span class="k">return</span> <span class="s2">"BEGIN"</span> +</span><span id="L-2497"><a href="#L-2497"><span class="linenos">2497</span></a> +</span><span id="L-2498"><a href="#L-2498"><span class="linenos">2498</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-2499"><a href="#L-2499"><span class="linenos">2499</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-2500"><a href="#L-2500"><span class="linenos">2500</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-2501"><a href="#L-2501"><span class="linenos">2501</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-2502"><a href="#L-2502"><span class="linenos">2502</span></a> +</span><span id="L-2503"><a href="#L-2503"><span class="linenos">2503</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-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">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-2506"><a href="#L-2506"><span class="linenos">2506</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-2507"><a href="#L-2507"><span class="linenos">2507</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-2508"><a href="#L-2508"><span class="linenos">2508</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-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">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-2511"><a href="#L-2511"><span class="linenos">2511</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-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">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-2514"><a href="#L-2514"><span class="linenos">2514</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-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">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-2517"><a href="#L-2517"><span class="linenos">2517</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">add_column_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="L-2518"><a href="#L-2518"><span class="linenos">2518</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-2519"><a href="#L-2519"><span class="linenos">2519</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-2520"><a href="#L-2520"><span class="linenos">2520</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-2521"><a href="#L-2521"><span class="linenos">2521</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-2522"><a href="#L-2522"><span class="linenos">2522</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-2523"><a href="#L-2523"><span class="linenos">2523</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-2513"><a href="#L-2513"><span class="linenos">2513</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-2514"><a href="#L-2514"><span class="linenos">2514</span></a> <span class="k">if</span> <span class="n">dtype</span><span class="p">:</span> +</span><span id="L-2515"><a href="#L-2515"><span class="linenos">2515</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-2516"><a href="#L-2516"><span class="linenos">2516</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-2517"><a href="#L-2517"><span class="linenos">2517</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-2518"><a href="#L-2518"><span class="linenos">2518</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-2519"><a href="#L-2519"><span class="linenos">2519</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-2520"><a href="#L-2520"><span class="linenos">2520</span></a> +</span><span id="L-2521"><a href="#L-2521"><span class="linenos">2521</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-2522"><a href="#L-2522"><span class="linenos">2522</span></a> <span class="k">if</span> <span class="n">default</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="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-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="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-2526"><a href="#L-2526"><span class="linenos">2526</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-2527"><a href="#L-2527"><span class="linenos">2527</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-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">add_column_sql</span><span class="p">(</span><span class="bp">self</span><span 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-2530"><a href="#L-2530"><span class="linenos">2530</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">ALTER_TABLE_INCLUDE_COLUMN_KEYWORD</span><span class="p">:</span> -</span><span id="L-2531"><a href="#L-2531"><span class="linenos">2531</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span> -</span><span id="L-2532"><a href="#L-2532"><span class="linenos">2532</span></a> <span class="n">expression</span><span class="p">,</span> -</span><span id="L-2533"><a href="#L-2533"><span class="linenos">2533</span></a> <span class="n">key</span><span class="o">=</span><span class="s2">"actions"</span><span class="p">,</span> -</span><span id="L-2534"><a href="#L-2534"><span class="linenos">2534</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-2525"><a href="#L-2525"><span class="linenos">2525</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-2526"><a href="#L-2526"><span class="linenos">2526</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-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">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-2529"><a href="#L-2529"><span class="linenos">2529</span></a> +</span><span id="L-2530"><a href="#L-2530"><span class="linenos">2530</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-2531"><a href="#L-2531"><span class="linenos">2531</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-2532"><a href="#L-2532"><span class="linenos">2532</span></a> <span class="c1"># Remove db from tables</span> +</span><span id="L-2533"><a href="#L-2533"><span class="linenos">2533</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-2534"><a href="#L-2534"><span class="linenos">2534</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-2535"><a href="#L-2535"><span class="linenos">2535</span></a> <span class="p">)</span> -</span><span id="L-2536"><a href="#L-2536"><span class="linenos">2536</span></a> <span class="k">return</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="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-2537"><a href="#L-2537"><span class="linenos">2537</span></a> -</span><span id="L-2538"><a href="#L-2538"><span class="linenos">2538</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-2539"><a href="#L-2539"><span class="linenos">2539</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-2540"><a href="#L-2540"><span class="linenos">2540</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-2541"><a href="#L-2541"><span class="linenos">2541</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-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">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-2544"><a href="#L-2544"><span class="linenos">2544</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-2545"><a href="#L-2545"><span class="linenos">2545</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-2546"><a href="#L-2546"><span class="linenos">2546</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-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="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-2549"><a href="#L-2549"><span class="linenos">2549</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-2550"><a href="#L-2550"><span class="linenos">2550</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-2551"><a href="#L-2551"><span class="linenos">2551</span></a> -</span><span id="L-2552"><a href="#L-2552"><span class="linenos">2552</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-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">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-2555"><a href="#L-2555"><span class="linenos">2555</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-2556"><a href="#L-2556"><span class="linenos">2556</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-2557"><a href="#L-2557"><span class="linenos">2557</span></a> -</span><span id="L-2558"><a href="#L-2558"><span class="linenos">2558</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-2559"><a href="#L-2559"><span class="linenos">2559</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-2560"><a href="#L-2560"><span class="linenos">2560</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-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">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-2563"><a href="#L-2563"><span class="linenos">2563</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-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">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-2566"><a href="#L-2566"><span class="linenos">2566</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-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">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-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">sql</span><span class="p">(</span> -</span><span id="L-2570"><a href="#L-2570"><span class="linenos">2570</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">(</span> -</span><span id="L-2571"><a href="#L-2571"><span class="linenos">2571</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="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="p">),</span> -</span><span id="L-2572"><a href="#L-2572"><span class="linenos">2572</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-2573"><a href="#L-2573"><span class="linenos">2573</span></a> <span class="p">)</span> -</span><span id="L-2574"><a href="#L-2574"><span class="linenos">2574</span></a> <span class="p">)</span> -</span><span id="L-2575"><a href="#L-2575"><span class="linenos">2575</span></a> -</span><span id="L-2576"><a href="#L-2576"><span class="linenos">2576</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-2577"><a href="#L-2577"><span class="linenos">2577</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">STRICT_STRING_CONCAT</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">"safe"</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">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-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">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-2582"><a href="#L-2582"><span class="linenos">2582</span></a> <span class="n">l</span><span class="p">,</span> <span class="n">r</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">left</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">right</span> +</span><span id="L-2536"><a href="#L-2536"><span class="linenos">2536</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-2537"><a href="#L-2537"><span class="linenos">2537</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-2538"><a href="#L-2538"><span class="linenos">2538</span></a> +</span><span id="L-2539"><a href="#L-2539"><span class="linenos">2539</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-2540"><a href="#L-2540"><span class="linenos">2540</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-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">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-2543"><a href="#L-2543"><span class="linenos">2543</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">add_column_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-2544"><a href="#L-2544"><span class="linenos">2544</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-2545"><a href="#L-2545"><span class="linenos">2545</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-2546"><a href="#L-2546"><span class="linenos">2546</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-2547"><a href="#L-2547"><span class="linenos">2547</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-2548"><a href="#L-2548"><span class="linenos">2548</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-2549"><a href="#L-2549"><span class="linenos">2549</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-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="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-2552"><a href="#L-2552"><span class="linenos">2552</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-2553"><a href="#L-2553"><span class="linenos">2553</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-2554"><a href="#L-2554"><span class="linenos">2554</span></a> +</span><span id="L-2555"><a href="#L-2555"><span class="linenos">2555</span></a> <span class="k">def</span> <span class="nf">add_column_sql</span><span class="p">(</span><span class="bp">self</span><span 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-2556"><a href="#L-2556"><span class="linenos">2556</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">ALTER_TABLE_INCLUDE_COLUMN_KEYWORD</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">expressions</span><span class="p">(</span> +</span><span id="L-2558"><a href="#L-2558"><span class="linenos">2558</span></a> <span class="n">expression</span><span class="p">,</span> +</span><span id="L-2559"><a href="#L-2559"><span class="linenos">2559</span></a> <span class="n">key</span><span class="o">=</span><span class="s2">"actions"</span><span class="p">,</span> +</span><span id="L-2560"><a href="#L-2560"><span class="linenos">2560</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-2561"><a href="#L-2561"><span class="linenos">2561</span></a> <span class="p">)</span> +</span><span id="L-2562"><a href="#L-2562"><span class="linenos">2562</span></a> <span class="k">return</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="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-2563"><a href="#L-2563"><span class="linenos">2563</span></a> +</span><span id="L-2564"><a href="#L-2564"><span class="linenos">2564</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-2565"><a href="#L-2565"><span class="linenos">2565</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-2566"><a href="#L-2566"><span class="linenos">2566</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-2567"><a href="#L-2567"><span class="linenos">2567</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-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">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-2570"><a href="#L-2570"><span class="linenos">2570</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-2571"><a href="#L-2571"><span class="linenos">2571</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-2572"><a href="#L-2572"><span class="linenos">2572</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-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="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-2575"><a href="#L-2575"><span class="linenos">2575</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-2576"><a href="#L-2576"><span class="linenos">2576</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-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">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-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">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-2581"><a href="#L-2581"><span class="linenos">2581</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-2582"><a href="#L-2582"><span class="linenos">2582</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-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">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">SAFE_DIVISION</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">"safe"</span><span class="p">):</span> -</span><span id="L-2585"><a href="#L-2585"><span class="linenos">2585</span></a> <span class="n">r</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Nullif</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">r</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">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">number</span><span class="p">(</span><span class="mi">0</span><span class="p">)))</span> -</span><span id="L-2586"><a href="#L-2586"><span class="linenos">2586</span></a> -</span><span id="L-2587"><a href="#L-2587"><span class="linenos">2587</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">TYPED_DIVISION</span> <span class="ow">and</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">"typed"</span><span class="p">):</span> -</span><span id="L-2588"><a href="#L-2588"><span class="linenos">2588</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">l</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</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">FLOAT_TYPES</span><span class="p">)</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">r</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span> -</span><span id="L-2589"><a href="#L-2589"><span class="linenos">2589</span></a> <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">FLOAT_TYPES</span> -</span><span id="L-2590"><a href="#L-2590"><span class="linenos">2590</span></a> <span class="p">):</span> -</span><span id="L-2591"><a href="#L-2591"><span class="linenos">2591</span></a> <span class="n">l</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">l</span><span class="o">.</span><span class="n">copy</span><span class="p">(),</span> <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="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">DOUBLE</span><span class="p">))</span> -</span><span id="L-2592"><a href="#L-2592"><span class="linenos">2592</span></a> -</span><span id="L-2593"><a href="#L-2593"><span class="linenos">2593</span></a> <span class="k">elif</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">TYPED_DIVISION</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">"typed"</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="n">l</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</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">INTEGER_TYPES</span><span class="p">)</span> <span class="ow">and</span> <span class="n">r</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</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">INTEGER_TYPES</span><span class="p">):</span> -</span><span id="L-2595"><a href="#L-2595"><span class="linenos">2595</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-2596"><a href="#L-2596"><span class="linenos">2596</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span> -</span><span id="L-2597"><a href="#L-2597"><span class="linenos">2597</span></a> <span class="n">l</span> <span class="o">/</span> <span class="n">r</span><span class="p">,</span> -</span><span id="L-2598"><a href="#L-2598"><span class="linenos">2598</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="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">BIGINT</span><span class="p">,</span> -</span><span id="L-2599"><a href="#L-2599"><span class="linenos">2599</span></a> <span class="p">)</span> -</span><span id="L-2600"><a href="#L-2600"><span class="linenos">2600</span></a> <span class="p">)</span> +</span><span id="L-2584"><a href="#L-2584"><span class="linenos">2584</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-2585"><a href="#L-2585"><span class="linenos">2585</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-2586"><a href="#L-2586"><span class="linenos">2586</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-2587"><a href="#L-2587"><span class="linenos">2587</span></a> +</span><span id="L-2588"><a href="#L-2588"><span class="linenos">2588</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-2589"><a href="#L-2589"><span class="linenos">2589</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-2590"><a href="#L-2590"><span class="linenos">2590</span></a> +</span><span id="L-2591"><a href="#L-2591"><span class="linenos">2591</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-2592"><a href="#L-2592"><span class="linenos">2592</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-2593"><a href="#L-2593"><span class="linenos">2593</span></a> +</span><span id="L-2594"><a href="#L-2594"><span class="linenos">2594</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-2595"><a href="#L-2595"><span class="linenos">2595</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-2596"><a href="#L-2596"><span class="linenos">2596</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">(</span> +</span><span id="L-2597"><a href="#L-2597"><span class="linenos">2597</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="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="p">),</span> +</span><span id="L-2598"><a href="#L-2598"><span class="linenos">2598</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-2599"><a href="#L-2599"><span class="linenos">2599</span></a> <span class="p">)</span> +</span><span id="L-2600"><a href="#L-2600"><span class="linenos">2600</span></a> <span class="p">)</span> </span><span id="L-2601"><a href="#L-2601"><span class="linenos">2601</span></a> -</span><span id="L-2602"><a href="#L-2602"><span class="linenos">2602</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-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">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-2605"><a href="#L-2605"><span class="linenos">2605</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-2602"><a href="#L-2602"><span class="linenos">2602</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-2603"><a href="#L-2603"><span class="linenos">2603</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">STRICT_STRING_CONCAT</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">"safe"</span><span class="p">):</span> +</span><span id="L-2604"><a href="#L-2604"><span class="linenos">2604</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-2605"><a href="#L-2605"><span class="linenos">2605</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-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">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-2608"><a href="#L-2608"><span class="linenos">2608</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-2607"><a href="#L-2607"><span class="linenos">2607</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-2608"><a href="#L-2608"><span class="linenos">2608</span></a> <span class="n">l</span><span class="p">,</span> <span class="n">r</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">left</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">right</span> </span><span id="L-2609"><a href="#L-2609"><span class="linenos">2609</span></a> -</span><span id="L-2610"><a href="#L-2610"><span class="linenos">2610</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-2611"><a href="#L-2611"><span class="linenos">2611</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-2610"><a href="#L-2610"><span class="linenos">2610</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">SAFE_DIVISION</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">"safe"</span><span class="p">):</span> +</span><span id="L-2611"><a href="#L-2611"><span class="linenos">2611</span></a> <span class="n">r</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Nullif</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">r</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">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">number</span><span class="p">(</span><span class="mi">0</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">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-2614"><a href="#L-2614"><span class="linenos">2614</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-2615"><a href="#L-2615"><span class="linenos">2615</span></a> -</span><span id="L-2616"><a href="#L-2616"><span class="linenos">2616</span></a> <span class="k">def</span> <span class="nf">propertyeq_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">PropertyEQ</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2617"><a href="#L-2617"><span class="linenos">2617</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-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">dialect</span><span class="o">.</span><span class="n">TYPED_DIVISION</span> <span class="ow">and</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">"typed"</span><span class="p">):</span> +</span><span id="L-2614"><a href="#L-2614"><span class="linenos">2614</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">l</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</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">FLOAT_TYPES</span><span class="p">)</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">r</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span> +</span><span id="L-2615"><a href="#L-2615"><span class="linenos">2615</span></a> <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">FLOAT_TYPES</span> +</span><span id="L-2616"><a href="#L-2616"><span class="linenos">2616</span></a> <span class="p">):</span> +</span><span id="L-2617"><a href="#L-2617"><span class="linenos">2617</span></a> <span class="n">l</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">l</span><span class="o">.</span><span class="n">copy</span><span class="p">(),</span> <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="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">DOUBLE</span><span class="p">))</span> </span><span id="L-2618"><a href="#L-2618"><span class="linenos">2618</span></a> -</span><span id="L-2619"><a href="#L-2619"><span class="linenos">2619</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-2620"><a href="#L-2620"><span class="linenos">2620</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-2621"><a href="#L-2621"><span class="linenos">2621</span></a> -</span><span id="L-2622"><a href="#L-2622"><span class="linenos">2622</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-2623"><a href="#L-2623"><span class="linenos">2623</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-2624"><a href="#L-2624"><span class="linenos">2624</span></a> -</span><span id="L-2625"><a href="#L-2625"><span class="linenos">2625</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-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">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-2619"><a href="#L-2619"><span class="linenos">2619</span></a> <span class="k">elif</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">TYPED_DIVISION</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">"typed"</span><span class="p">):</span> +</span><span id="L-2620"><a href="#L-2620"><span class="linenos">2620</span></a> <span class="k">if</span> <span class="n">l</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</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">INTEGER_TYPES</span><span class="p">)</span> <span class="ow">and</span> <span class="n">r</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</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">INTEGER_TYPES</span><span class="p">):</span> +</span><span id="L-2621"><a href="#L-2621"><span class="linenos">2621</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-2622"><a href="#L-2622"><span class="linenos">2622</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span> +</span><span id="L-2623"><a href="#L-2623"><span class="linenos">2623</span></a> <span class="n">l</span> <span class="o">/</span> <span class="n">r</span><span class="p">,</span> +</span><span id="L-2624"><a href="#L-2624"><span class="linenos">2624</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="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">BIGINT</span><span class="p">,</span> +</span><span id="L-2625"><a href="#L-2625"><span class="linenos">2625</span></a> <span class="p">)</span> +</span><span id="L-2626"><a href="#L-2626"><span class="linenos">2626</span></a> <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">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-2629"><a href="#L-2629"><span class="linenos">2629</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-2630"><a href="#L-2630"><span class="linenos">2630</span></a> -</span><span id="L-2631"><a href="#L-2631"><span class="linenos">2631</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-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">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-2633"><a href="#L-2633"><span class="linenos">2633</span></a> -</span><span id="L-2634"><a href="#L-2634"><span class="linenos">2634</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-2635"><a href="#L-2635"><span class="linenos">2635</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-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">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-2638"><a href="#L-2638"><span class="linenos">2638</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-2639"><a href="#L-2639"><span class="linenos">2639</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-2640"><a href="#L-2640"><span class="linenos">2640</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-2641"><a href="#L-2641"><span class="linenos">2641</span></a> <span class="p">)</span> -</span><span id="L-2642"><a href="#L-2642"><span class="linenos">2642</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-2643"><a href="#L-2643"><span class="linenos">2643</span></a> -</span><span id="L-2644"><a href="#L-2644"><span class="linenos">2644</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-2645"><a href="#L-2645"><span class="linenos">2645</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-2646"><a href="#L-2646"><span class="linenos">2646</span></a> -</span><span id="L-2647"><a href="#L-2647"><span class="linenos">2647</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-2648"><a href="#L-2648"><span class="linenos">2648</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-2649"><a href="#L-2649"><span class="linenos">2649</span></a> -</span><span id="L-2650"><a href="#L-2650"><span class="linenos">2650</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-2651"><a href="#L-2651"><span class="linenos">2651</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-2652"><a href="#L-2652"><span class="linenos">2652</span></a> -</span><span id="L-2653"><a href="#L-2653"><span class="linenos">2653</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-2654"><a href="#L-2654"><span class="linenos">2654</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-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">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-2657"><a href="#L-2657"><span class="linenos">2657</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-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">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-2660"><a href="#L-2660"><span class="linenos">2660</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-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="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-2663"><a href="#L-2663"><span class="linenos">2663</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-2664"><a href="#L-2664"><span class="linenos">2664</span></a> -</span><span id="L-2665"><a href="#L-2665"><span class="linenos">2665</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-2666"><a href="#L-2666"><span class="linenos">2666</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-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="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-2669"><a href="#L-2669"><span class="linenos">2669</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-2670"><a href="#L-2670"><span class="linenos">2670</span></a> -</span><span id="L-2671"><a href="#L-2671"><span class="linenos">2671</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-2672"><a href="#L-2672"><span class="linenos">2672</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-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="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-2675"><a href="#L-2675"><span class="linenos">2675</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-2676"><a href="#L-2676"><span class="linenos">2676</span></a> -</span><span id="L-2677"><a href="#L-2677"><span class="linenos">2677</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-2678"><a href="#L-2678"><span class="linenos">2678</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-2679"><a href="#L-2679"><span class="linenos">2679</span></a> -</span><span id="L-2680"><a href="#L-2680"><span class="linenos">2680</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-2681"><a href="#L-2681"><span class="linenos">2681</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-2682"><a href="#L-2682"><span class="linenos">2682</span></a> -</span><span id="L-2683"><a href="#L-2683"><span class="linenos">2683</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-2684"><a href="#L-2684"><span class="linenos">2684</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-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="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-2687"><a href="#L-2687"><span class="linenos">2687</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><span id="L-2688"><a href="#L-2688"><span class="linenos">2688</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span> -</span><span id="L-2689"><a href="#L-2689"><span class="linenos">2689</span></a> -</span><span id="L-2690"><a href="#L-2690"><span class="linenos">2690</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">LOG_BASE_FIRST</span><span class="p">:</span> -</span><span id="L-2691"><a href="#L-2691"><span class="linenos">2691</span></a> <span class="n">this</span><span class="p">,</span> <span class="n">expr</span> <span class="o">=</span> <span class="n">expr</span><span class="p">,</span> <span class="n">this</span> -</span><span id="L-2692"><a href="#L-2692"><span class="linenos">2692</span></a> -</span><span id="L-2693"><a href="#L-2693"><span class="linenos">2693</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="n">this</span><span class="p">,</span> <span class="n">expr</span><span class="p">)</span> -</span><span id="L-2694"><a href="#L-2694"><span class="linenos">2694</span></a> -</span><span id="L-2695"><a href="#L-2695"><span class="linenos">2695</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-2696"><a href="#L-2696"><span class="linenos">2696</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-2697"><a href="#L-2697"><span class="linenos">2697</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-2698"><a href="#L-2698"><span class="linenos">2698</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-2699"><a href="#L-2699"><span class="linenos">2699</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-2700"><a href="#L-2700"><span class="linenos">2700</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-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">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-2703"><a href="#L-2703"><span class="linenos">2703</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-2704"><a href="#L-2704"><span class="linenos">2704</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-2628"><a href="#L-2628"><span class="linenos">2628</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-2629"><a href="#L-2629"><span class="linenos">2629</span></a> +</span><span id="L-2630"><a href="#L-2630"><span class="linenos">2630</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-2631"><a href="#L-2631"><span class="linenos">2631</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-2632"><a href="#L-2632"><span class="linenos">2632</span></a> +</span><span id="L-2633"><a href="#L-2633"><span class="linenos">2633</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-2634"><a href="#L-2634"><span class="linenos">2634</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-2635"><a href="#L-2635"><span class="linenos">2635</span></a> +</span><span id="L-2636"><a href="#L-2636"><span class="linenos">2636</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-2637"><a href="#L-2637"><span class="linenos">2637</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-2638"><a href="#L-2638"><span class="linenos">2638</span></a> +</span><span id="L-2639"><a href="#L-2639"><span class="linenos">2639</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-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">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-2641"><a href="#L-2641"><span class="linenos">2641</span></a> +</span><span id="L-2642"><a href="#L-2642"><span class="linenos">2642</span></a> <span class="k">def</span> <span class="nf">propertyeq_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">PropertyEQ</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2643"><a href="#L-2643"><span class="linenos">2643</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-2644"><a href="#L-2644"><span class="linenos">2644</span></a> +</span><span id="L-2645"><a href="#L-2645"><span class="linenos">2645</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-2646"><a href="#L-2646"><span class="linenos">2646</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-2647"><a href="#L-2647"><span class="linenos">2647</span></a> +</span><span id="L-2648"><a href="#L-2648"><span class="linenos">2648</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-2649"><a href="#L-2649"><span class="linenos">2649</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-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">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-2652"><a href="#L-2652"><span class="linenos">2652</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-2653"><a href="#L-2653"><span class="linenos">2653</span></a> +</span><span id="L-2654"><a href="#L-2654"><span class="linenos">2654</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-2655"><a href="#L-2655"><span class="linenos">2655</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-2656"><a href="#L-2656"><span class="linenos">2656</span></a> +</span><span id="L-2657"><a href="#L-2657"><span class="linenos">2657</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-2658"><a href="#L-2658"><span class="linenos">2658</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-2659"><a href="#L-2659"><span class="linenos">2659</span></a> +</span><span id="L-2660"><a href="#L-2660"><span class="linenos">2660</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-2661"><a href="#L-2661"><span class="linenos">2661</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-2662"><a href="#L-2662"><span class="linenos">2662</span></a> +</span><span id="L-2663"><a href="#L-2663"><span class="linenos">2663</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-2664"><a href="#L-2664"><span class="linenos">2664</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-2665"><a href="#L-2665"><span class="linenos">2665</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-2666"><a href="#L-2666"><span class="linenos">2666</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-2667"><a href="#L-2667"><span class="linenos">2667</span></a> <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="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-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="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-2671"><a href="#L-2671"><span class="linenos">2671</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-2672"><a href="#L-2672"><span class="linenos">2672</span></a> +</span><span id="L-2673"><a href="#L-2673"><span class="linenos">2673</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-2674"><a href="#L-2674"><span class="linenos">2674</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-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">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-2677"><a href="#L-2677"><span class="linenos">2677</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-2678"><a href="#L-2678"><span class="linenos">2678</span></a> +</span><span id="L-2679"><a href="#L-2679"><span class="linenos">2679</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-2680"><a href="#L-2680"><span class="linenos">2680</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-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="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-2683"><a href="#L-2683"><span class="linenos">2683</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-2684"><a href="#L-2684"><span class="linenos">2684</span></a> +</span><span id="L-2685"><a href="#L-2685"><span class="linenos">2685</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-2686"><a href="#L-2686"><span class="linenos">2686</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-2687"><a href="#L-2687"><span class="linenos">2687</span></a> +</span><span id="L-2688"><a href="#L-2688"><span class="linenos">2688</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-2689"><a href="#L-2689"><span class="linenos">2689</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-2690"><a href="#L-2690"><span class="linenos">2690</span></a> +</span><span id="L-2691"><a href="#L-2691"><span class="linenos">2691</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-2692"><a href="#L-2692"><span class="linenos">2692</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-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="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-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">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-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">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-2698"><a href="#L-2698"><span class="linenos">2698</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-2699"><a href="#L-2699"><span class="linenos">2699</span></a> +</span><span id="L-2700"><a href="#L-2700"><span class="linenos">2700</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-2701"><a href="#L-2701"><span class="linenos">2701</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-2702"><a href="#L-2702"><span class="linenos">2702</span></a> +</span><span id="L-2703"><a href="#L-2703"><span class="linenos">2703</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-2704"><a href="#L-2704"><span class="linenos">2704</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-2705"><a href="#L-2705"><span class="linenos">2705</span></a> -</span><span id="L-2706"><a href="#L-2706"><span class="linenos">2706</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-2707"><a href="#L-2707"><span class="linenos">2707</span></a> <span class="n">args</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="L-2706"><a href="#L-2706"><span class="linenos">2706</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-2707"><a href="#L-2707"><span class="linenos">2707</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-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">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-2710"><a href="#L-2710"><span class="linenos">2710</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-2709"><a href="#L-2709"><span class="linenos">2709</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-2710"><a href="#L-2710"><span class="linenos">2710</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-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">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-2713"><a href="#L-2713"><span class="linenos">2713</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-2714"><a href="#L-2714"><span class="linenos">2714</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-2715"><a href="#L-2715"><span class="linenos">2715</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-2716"><a href="#L-2716"><span class="linenos">2716</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-2717"><a href="#L-2717"><span class="linenos">2717</span></a> -</span><span id="L-2718"><a href="#L-2718"><span class="linenos">2718</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-2719"><a href="#L-2719"><span class="linenos">2719</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-2720"><a href="#L-2720"><span class="linenos">2720</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-2721"><a href="#L-2721"><span class="linenos">2721</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-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">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-2724"><a href="#L-2724"><span class="linenos">2724</span></a> -</span><span id="L-2725"><a href="#L-2725"><span class="linenos">2725</span></a> <span class="k">def</span> <span class="nf">func</span><span class="p">(</span> -</span><span id="L-2726"><a href="#L-2726"><span class="linenos">2726</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="L-2727"><a href="#L-2727"><span class="linenos">2727</span></a> <span class="n">name</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> -</span><span id="L-2728"><a href="#L-2728"><span class="linenos">2728</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-2729"><a href="#L-2729"><span class="linenos">2729</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-2730"><a href="#L-2730"><span class="linenos">2730</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-2731"><a href="#L-2731"><span class="linenos">2731</span></a> <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="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-2733"><a href="#L-2733"><span class="linenos">2733</span></a> -</span><span id="L-2734"><a href="#L-2734"><span class="linenos">2734</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-2735"><a href="#L-2735"><span class="linenos">2735</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-2736"><a href="#L-2736"><span class="linenos">2736</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-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">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-2738"><a href="#L-2738"><span class="linenos">2738</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-2739"><a href="#L-2739"><span class="linenos">2739</span></a> -</span><span id="L-2740"><a href="#L-2740"><span class="linenos">2740</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-2741"><a href="#L-2741"><span class="linenos">2741</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-2742"><a href="#L-2742"><span class="linenos">2742</span></a> -</span><span id="L-2743"><a href="#L-2743"><span class="linenos">2743</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-2744"><a href="#L-2744"><span class="linenos">2744</span></a> <span class="k">return</span> <span class="n">format_time</span><span class="p">(</span> -</span><span id="L-2745"><a href="#L-2745"><span class="linenos">2745</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><span id="L-2746"><a href="#L-2746"><span class="linenos">2746</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">INVERSE_TIME_MAPPING</span><span class="p">,</span> -</span><span id="L-2747"><a href="#L-2747"><span class="linenos">2747</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">INVERSE_TIME_TRIE</span><span class="p">,</span> -</span><span id="L-2748"><a href="#L-2748"><span class="linenos">2748</span></a> <span class="p">)</span> -</span><span id="L-2749"><a href="#L-2749"><span class="linenos">2749</span></a> -</span><span id="L-2750"><a href="#L-2750"><span class="linenos">2750</span></a> <span class="k">def</span> <span class="nf">expressions</span><span class="p">(</span> -</span><span id="L-2751"><a href="#L-2751"><span class="linenos">2751</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="L-2752"><a href="#L-2752"><span class="linenos">2752</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-2753"><a href="#L-2753"><span class="linenos">2753</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-2754"><a href="#L-2754"><span class="linenos">2754</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-2755"><a href="#L-2755"><span class="linenos">2755</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-2756"><a href="#L-2756"><span class="linenos">2756</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-2757"><a href="#L-2757"><span class="linenos">2757</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-2758"><a href="#L-2758"><span class="linenos">2758</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-2759"><a href="#L-2759"><span class="linenos">2759</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-2760"><a href="#L-2760"><span class="linenos">2760</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2761"><a href="#L-2761"><span class="linenos">2761</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-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="k">if</span> <span class="ow">not</span> <span class="n">expressions</span><span class="p">:</span> -</span><span id="L-2764"><a href="#L-2764"><span class="linenos">2764</span></a> <span class="k">return</span> <span class="s2">""</span> +</span><span id="L-2712"><a href="#L-2712"><span class="linenos">2712</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-2713"><a href="#L-2713"><span class="linenos">2713</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><span id="L-2714"><a href="#L-2714"><span class="linenos">2714</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span> +</span><span id="L-2715"><a href="#L-2715"><span class="linenos">2715</span></a> +</span><span id="L-2716"><a href="#L-2716"><span class="linenos">2716</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">LOG_BASE_FIRST</span><span class="p">:</span> +</span><span id="L-2717"><a href="#L-2717"><span class="linenos">2717</span></a> <span class="n">this</span><span class="p">,</span> <span class="n">expr</span> <span class="o">=</span> <span class="n">expr</span><span class="p">,</span> <span class="n">this</span> +</span><span id="L-2718"><a href="#L-2718"><span class="linenos">2718</span></a> +</span><span id="L-2719"><a href="#L-2719"><span class="linenos">2719</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="n">this</span><span class="p">,</span> <span class="n">expr</span><span class="p">)</span> +</span><span id="L-2720"><a href="#L-2720"><span class="linenos">2720</span></a> +</span><span id="L-2721"><a href="#L-2721"><span class="linenos">2721</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-2722"><a href="#L-2722"><span class="linenos">2722</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-2723"><a href="#L-2723"><span class="linenos">2723</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-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">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-2726"><a href="#L-2726"><span class="linenos">2726</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-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">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-2729"><a href="#L-2729"><span class="linenos">2729</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-2730"><a href="#L-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="bp">self</span><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-2731"><a href="#L-2731"><span class="linenos">2731</span></a> +</span><span id="L-2732"><a href="#L-2732"><span class="linenos">2732</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-2733"><a href="#L-2733"><span class="linenos">2733</span></a> <span class="n">args</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="L-2734"><a href="#L-2734"><span class="linenos">2734</span></a> +</span><span id="L-2735"><a href="#L-2735"><span class="linenos">2735</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-2736"><a href="#L-2736"><span class="linenos">2736</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-2737"><a href="#L-2737"><span class="linenos">2737</span></a> +</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">arg_value</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span> +</span><span id="L-2739"><a href="#L-2739"><span class="linenos">2739</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-2740"><a href="#L-2740"><span class="linenos">2740</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-2741"><a href="#L-2741"><span class="linenos">2741</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-2742"><a href="#L-2742"><span class="linenos">2742</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-2743"><a href="#L-2743"><span class="linenos">2743</span></a> +</span><span id="L-2744"><a href="#L-2744"><span class="linenos">2744</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-2745"><a href="#L-2745"><span class="linenos">2745</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-2746"><a href="#L-2746"><span class="linenos">2746</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-2747"><a href="#L-2747"><span class="linenos">2747</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-2748"><a href="#L-2748"><span class="linenos">2748</span></a> +</span><span id="L-2749"><a href="#L-2749"><span class="linenos">2749</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-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">func</span><span class="p">(</span> +</span><span id="L-2752"><a href="#L-2752"><span class="linenos">2752</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="L-2753"><a href="#L-2753"><span class="linenos">2753</span></a> <span class="n">name</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> +</span><span id="L-2754"><a href="#L-2754"><span class="linenos">2754</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-2755"><a href="#L-2755"><span class="linenos">2755</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-2756"><a href="#L-2756"><span class="linenos">2756</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-2757"><a href="#L-2757"><span class="linenos">2757</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2758"><a href="#L-2758"><span class="linenos">2758</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-2759"><a href="#L-2759"><span class="linenos">2759</span></a> +</span><span id="L-2760"><a href="#L-2760"><span class="linenos">2760</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-2761"><a href="#L-2761"><span class="linenos">2761</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-2762"><a href="#L-2762"><span class="linenos">2762</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-2763"><a href="#L-2763"><span class="linenos">2763</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-2764"><a href="#L-2764"><span class="linenos">2764</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-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">if</span> <span class="n">flat</span><span class="p">:</span> -</span><span id="L-2767"><a href="#L-2767"><span class="linenos">2767</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-2766"><a href="#L-2766"><span class="linenos">2766</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-2767"><a href="#L-2767"><span class="linenos">2767</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-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">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-2770"><a href="#L-2770"><span class="linenos">2770</span></a> -</span><span id="L-2771"><a href="#L-2771"><span class="linenos">2771</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-2772"><a href="#L-2772"><span class="linenos">2772</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-2773"><a href="#L-2773"><span class="linenos">2773</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-2774"><a href="#L-2774"><span class="linenos">2774</span></a> -</span><span id="L-2775"><a href="#L-2775"><span class="linenos">2775</span></a> <span class="n">result_sqls</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="L-2776"><a href="#L-2776"><span class="linenos">2776</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-2777"><a href="#L-2777"><span class="linenos">2777</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-2778"><a href="#L-2778"><span class="linenos">2778</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-2779"><a href="#L-2779"><span class="linenos">2779</span></a> <span class="k">continue</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="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-2782"><a href="#L-2782"><span class="linenos">2782</span></a> -</span><span id="L-2783"><a href="#L-2783"><span class="linenos">2783</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-2784"><a href="#L-2784"><span class="linenos">2784</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-2785"><a href="#L-2785"><span class="linenos">2785</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-2786"><a href="#L-2786"><span class="linenos">2786</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-2787"><a href="#L-2787"><span class="linenos">2787</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-2788"><a href="#L-2788"><span class="linenos">2788</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-2789"><a href="#L-2789"><span class="linenos">2789</span></a> <span class="p">)</span> -</span><span id="L-2790"><a href="#L-2790"><span class="linenos">2790</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-2791"><a href="#L-2791"><span class="linenos">2791</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-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="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-2794"><a href="#L-2794"><span class="linenos">2794</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-2795"><a href="#L-2795"><span class="linenos">2795</span></a> -</span><span id="L-2796"><a href="#L-2796"><span class="linenos">2796</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-2797"><a href="#L-2797"><span class="linenos">2797</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-2798"><a href="#L-2798"><span class="linenos">2798</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-2799"><a href="#L-2799"><span class="linenos">2799</span></a> <span class="k">if</span> <span class="n">flat</span><span class="p">:</span> -</span><span id="L-2800"><a href="#L-2800"><span class="linenos">2800</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-2801"><a href="#L-2801"><span class="linenos">2801</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-2802"><a href="#L-2802"><span class="linenos">2802</span></a> -</span><span id="L-2803"><a href="#L-2803"><span class="linenos">2803</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-2804"><a href="#L-2804"><span class="linenos">2804</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-2805"><a href="#L-2805"><span class="linenos">2805</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-2806"><a href="#L-2806"><span class="linenos">2806</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-2807"><a href="#L-2807"><span class="linenos">2807</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-2769"><a href="#L-2769"><span class="linenos">2769</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-2770"><a href="#L-2770"><span class="linenos">2770</span></a> <span class="k">return</span> <span class="n">format_time</span><span class="p">(</span> +</span><span id="L-2771"><a href="#L-2771"><span class="linenos">2771</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><span id="L-2772"><a href="#L-2772"><span class="linenos">2772</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">INVERSE_TIME_MAPPING</span><span class="p">,</span> +</span><span id="L-2773"><a href="#L-2773"><span class="linenos">2773</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">INVERSE_TIME_TRIE</span><span class="p">,</span> +</span><span id="L-2774"><a href="#L-2774"><span class="linenos">2774</span></a> <span class="p">)</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">expressions</span><span class="p">(</span> +</span><span id="L-2777"><a href="#L-2777"><span class="linenos">2777</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="L-2778"><a href="#L-2778"><span class="linenos">2778</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-2779"><a href="#L-2779"><span class="linenos">2779</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-2780"><a href="#L-2780"><span class="linenos">2780</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-2781"><a href="#L-2781"><span class="linenos">2781</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-2782"><a href="#L-2782"><span class="linenos">2782</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-2783"><a href="#L-2783"><span class="linenos">2783</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-2784"><a href="#L-2784"><span class="linenos">2784</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-2785"><a href="#L-2785"><span class="linenos">2785</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-2786"><a href="#L-2786"><span class="linenos">2786</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2787"><a href="#L-2787"><span class="linenos">2787</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-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">if</span> <span class="ow">not</span> <span class="n">expressions</span><span class="p">:</span> +</span><span id="L-2790"><a href="#L-2790"><span class="linenos">2790</span></a> <span class="k">return</span> <span class="s2">""</span> +</span><span id="L-2791"><a href="#L-2791"><span class="linenos">2791</span></a> +</span><span id="L-2792"><a href="#L-2792"><span class="linenos">2792</span></a> <span class="k">if</span> <span class="n">flat</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="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-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="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-2796"><a href="#L-2796"><span class="linenos">2796</span></a> +</span><span id="L-2797"><a href="#L-2797"><span class="linenos">2797</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-2798"><a href="#L-2798"><span class="linenos">2798</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-2799"><a href="#L-2799"><span class="linenos">2799</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-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="n">result_sqls</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="L-2802"><a href="#L-2802"><span class="linenos">2802</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-2803"><a href="#L-2803"><span class="linenos">2803</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-2804"><a href="#L-2804"><span class="linenos">2804</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-2805"><a href="#L-2805"><span class="linenos">2805</span></a> <span class="k">continue</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="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-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">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">Union</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-2810"><a href="#L-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">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">expression</span><span class="p">,</span> <span class="s2">"this"</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-2811"><a href="#L-2811"><span class="linenos">2811</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-2812"><a href="#L-2812"><span class="linenos">2812</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-2813"><a href="#L-2813"><span class="linenos">2813</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-2814"><a href="#L-2814"><span class="linenos">2814</span></a> <span class="p">)</span> -</span><span id="L-2815"><a href="#L-2815"><span class="linenos">2815</span></a> -</span><span id="L-2816"><a href="#L-2816"><span class="linenos">2816</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-2817"><a href="#L-2817"><span class="linenos">2817</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-2809"><a href="#L-2809"><span class="linenos">2809</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-2810"><a href="#L-2810"><span class="linenos">2810</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-2811"><a href="#L-2811"><span class="linenos">2811</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-2812"><a href="#L-2812"><span class="linenos">2812</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-2813"><a href="#L-2813"><span class="linenos">2813</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-2814"><a href="#L-2814"><span class="linenos">2814</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-2815"><a href="#L-2815"><span class="linenos">2815</span></a> <span class="p">)</span> +</span><span id="L-2816"><a href="#L-2816"><span class="linenos">2816</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-2817"><a href="#L-2817"><span class="linenos">2817</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-2818"><a href="#L-2818"><span class="linenos">2818</span></a> -</span><span id="L-2819"><a href="#L-2819"><span class="linenos">2819</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-2820"><a href="#L-2820"><span class="linenos">2820</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-2819"><a href="#L-2819"><span class="linenos">2819</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-2820"><a href="#L-2820"><span class="linenos">2820</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-2821"><a href="#L-2821"><span class="linenos">2821</span></a> -</span><span id="L-2822"><a href="#L-2822"><span class="linenos">2822</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-2823"><a href="#L-2823"><span class="linenos">2823</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-2824"><a href="#L-2824"><span class="linenos">2824</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-2825"><a href="#L-2825"><span class="linenos">2825</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="L-2826"><a href="#L-2826"><span class="linenos">2826</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-2827"><a href="#L-2827"><span class="linenos">2827</span></a> <span class="p">)</span> -</span><span id="L-2828"><a href="#L-2828"><span class="linenos">2828</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-2829"><a href="#L-2829"><span class="linenos">2829</span></a> -</span><span id="L-2830"><a href="#L-2830"><span class="linenos">2830</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-2831"><a href="#L-2831"><span class="linenos">2831</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-2832"><a href="#L-2832"><span class="linenos">2832</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-2833"><a href="#L-2833"><span class="linenos">2833</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-2822"><a href="#L-2822"><span class="linenos">2822</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-2823"><a href="#L-2823"><span class="linenos">2823</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-2824"><a href="#L-2824"><span class="linenos">2824</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-2825"><a href="#L-2825"><span class="linenos">2825</span></a> <span class="k">if</span> <span class="n">flat</span><span class="p">:</span> +</span><span id="L-2826"><a href="#L-2826"><span class="linenos">2826</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-2827"><a href="#L-2827"><span class="linenos">2827</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-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="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-2830"><a href="#L-2830"><span class="linenos">2830</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-2831"><a href="#L-2831"><span class="linenos">2831</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-2832"><a href="#L-2832"><span class="linenos">2832</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-2833"><a href="#L-2833"><span class="linenos">2833</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-2834"><a href="#L-2834"><span class="linenos">2834</span></a> -</span><span id="L-2835"><a href="#L-2835"><span class="linenos">2835</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-2836"><a href="#L-2836"><span class="linenos">2836</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-2837"><a href="#L-2837"><span class="linenos">2837</span></a> -</span><span id="L-2838"><a href="#L-2838"><span class="linenos">2838</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-2839"><a href="#L-2839"><span class="linenos">2839</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-2840"><a href="#L-2840"><span class="linenos">2840</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-2841"><a href="#L-2841"><span class="linenos">2841</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-2842"><a href="#L-2842"><span class="linenos">2842</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-2843"><a href="#L-2843"><span class="linenos">2843</span></a> -</span><span id="L-2844"><a href="#L-2844"><span class="linenos">2844</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-2845"><a href="#L-2845"><span class="linenos">2845</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-2846"><a href="#L-2846"><span class="linenos">2846</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-2847"><a href="#L-2847"><span class="linenos">2847</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-2848"><a href="#L-2848"><span class="linenos">2848</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-2849"><a href="#L-2849"><span class="linenos">2849</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-2850"><a href="#L-2850"><span class="linenos">2850</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-2851"><a href="#L-2851"><span class="linenos">2851</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-2852"><a href="#L-2852"><span class="linenos">2852</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-2853"><a href="#L-2853"><span class="linenos">2853</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-2854"><a href="#L-2854"><span class="linenos">2854</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-2855"><a href="#L-2855"><span class="linenos">2855</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-2856"><a href="#L-2856"><span class="linenos">2856</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-2857"><a href="#L-2857"><span class="linenos">2857</span></a> -</span><span id="L-2858"><a href="#L-2858"><span class="linenos">2858</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-2859"><a href="#L-2859"><span class="linenos">2859</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-2860"><a href="#L-2860"><span class="linenos">2860</span></a> <span class="n">table_alias</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="L-2861"><a href="#L-2861"><span class="linenos">2861</span></a> -</span><span id="L-2862"><a href="#L-2862"><span class="linenos">2862</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-2863"><a href="#L-2863"><span class="linenos">2863</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-2864"><a href="#L-2864"><span class="linenos">2864</span></a> <span class="c1"># T-SQL syntax is MERGE ... <target_table> [WITH (<merge_hint>)] [[AS] table_alias]</span> -</span><span id="L-2865"><a href="#L-2865"><span class="linenos">2865</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-2866"><a href="#L-2866"><span class="linenos">2866</span></a> -</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">table</span><span class="p">)</span> -</span><span id="L-2868"><a href="#L-2868"><span class="linenos">2868</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-2869"><a href="#L-2869"><span class="linenos">2869</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-2870"><a href="#L-2870"><span class="linenos">2870</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-2871"><a href="#L-2871"><span class="linenos">2871</span></a> -</span><span id="L-2872"><a href="#L-2872"><span class="linenos">2872</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><span id="L-2873"><a href="#L-2873"><span class="linenos">2873</span></a> <span class="n">expression</span><span class="p">,</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-2874"><a href="#L-2874"><span class="linenos">2874</span></a> <span class="p">)</span> -</span><span id="L-2875"><a href="#L-2875"><span class="linenos">2875</span></a> -</span><span id="L-2876"><a href="#L-2876"><span class="linenos">2876</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-2877"><a href="#L-2877"><span class="linenos">2877</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-2878"><a href="#L-2878"><span class="linenos">2878</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-2879"><a href="#L-2879"><span class="linenos">2879</span></a> -</span><span id="L-2880"><a href="#L-2880"><span class="linenos">2880</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-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">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-2883"><a href="#L-2883"><span class="linenos">2883</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-2884"><a href="#L-2884"><span class="linenos">2884</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-2885"><a href="#L-2885"><span class="linenos">2885</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-2886"><a href="#L-2886"><span class="linenos">2886</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-2887"><a href="#L-2887"><span class="linenos">2887</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-2888"><a href="#L-2888"><span class="linenos">2888</span></a> -</span><span id="L-2889"><a href="#L-2889"><span class="linenos">2889</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-2890"><a href="#L-2890"><span class="linenos">2890</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-2891"><a href="#L-2891"><span class="linenos">2891</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-2892"><a href="#L-2892"><span class="linenos">2892</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-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="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-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">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-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">'value'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2835"><a href="#L-2835"><span class="linenos">2835</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">Union</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-2836"><a href="#L-2836"><span class="linenos">2836</span></a> <span class="n">this</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="bp">self</span><span 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">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-2837"><a href="#L-2837"><span class="linenos">2837</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-2838"><a href="#L-2838"><span class="linenos">2838</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-2839"><a href="#L-2839"><span class="linenos">2839</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-2840"><a href="#L-2840"><span class="linenos">2840</span></a> <span class="p">)</span> +</span><span id="L-2841"><a href="#L-2841"><span class="linenos">2841</span></a> +</span><span id="L-2842"><a href="#L-2842"><span class="linenos">2842</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-2843"><a href="#L-2843"><span class="linenos">2843</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-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="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-2846"><a href="#L-2846"><span class="linenos">2846</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-2847"><a href="#L-2847"><span class="linenos">2847</span></a> +</span><span id="L-2848"><a href="#L-2848"><span class="linenos">2848</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-2849"><a href="#L-2849"><span class="linenos">2849</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-2850"><a href="#L-2850"><span class="linenos">2850</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-2851"><a href="#L-2851"><span class="linenos">2851</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="L-2852"><a href="#L-2852"><span class="linenos">2852</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-2853"><a href="#L-2853"><span class="linenos">2853</span></a> <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="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-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">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-2857"><a href="#L-2857"><span class="linenos">2857</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-2858"><a href="#L-2858"><span class="linenos">2858</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-2859"><a href="#L-2859"><span class="linenos">2859</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-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="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-2862"><a href="#L-2862"><span class="linenos">2862</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-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">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-2865"><a href="#L-2865"><span class="linenos">2865</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-2866"><a href="#L-2866"><span class="linenos">2866</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-2867"><a href="#L-2867"><span class="linenos">2867</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-2868"><a href="#L-2868"><span class="linenos">2868</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-2869"><a href="#L-2869"><span class="linenos">2869</span></a> +</span><span id="L-2870"><a href="#L-2870"><span class="linenos">2870</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-2871"><a href="#L-2871"><span class="linenos">2871</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-2872"><a href="#L-2872"><span class="linenos">2872</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-2873"><a href="#L-2873"><span class="linenos">2873</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-2874"><a href="#L-2874"><span class="linenos">2874</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-2875"><a href="#L-2875"><span class="linenos">2875</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-2876"><a href="#L-2876"><span class="linenos">2876</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-2877"><a href="#L-2877"><span class="linenos">2877</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-2878"><a href="#L-2878"><span class="linenos">2878</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-2879"><a href="#L-2879"><span class="linenos">2879</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-2880"><a href="#L-2880"><span class="linenos">2880</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-2881"><a href="#L-2881"><span class="linenos">2881</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-2882"><a href="#L-2882"><span class="linenos">2882</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-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">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-2885"><a href="#L-2885"><span class="linenos">2885</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-2886"><a href="#L-2886"><span class="linenos">2886</span></a> <span class="n">table_alias</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="L-2887"><a href="#L-2887"><span class="linenos">2887</span></a> +</span><span id="L-2888"><a href="#L-2888"><span class="linenos">2888</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-2889"><a href="#L-2889"><span class="linenos">2889</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-2890"><a href="#L-2890"><span class="linenos">2890</span></a> <span class="c1"># T-SQL syntax is MERGE ... <target_table> [WITH (<merge_hint>)] [[AS] table_alias]</span> +</span><span id="L-2891"><a href="#L-2891"><span class="linenos">2891</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-2892"><a href="#L-2892"><span class="linenos">2892</span></a> +</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">table</span><span class="p">)</span> +</span><span id="L-2894"><a href="#L-2894"><span class="linenos">2894</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-2895"><a href="#L-2895"><span class="linenos">2895</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-2896"><a href="#L-2896"><span class="linenos">2896</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-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">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-2899"><a href="#L-2899"><span class="linenos">2899</span></a> <span class="k">return</span> <span class="s2">""</span> -</span><span id="L-2900"><a href="#L-2900"><span class="linenos">2900</span></a> -</span><span id="L-2901"><a href="#L-2901"><span class="linenos">2901</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-2902"><a href="#L-2902"><span class="linenos">2902</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-2903"><a href="#L-2903"><span class="linenos">2903</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-2904"><a href="#L-2904"><span class="linenos">2904</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-2905"><a href="#L-2905"><span class="linenos">2905</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-2906"><a href="#L-2906"><span class="linenos">2906</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-2898"><a href="#L-2898"><span class="linenos">2898</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><span id="L-2899"><a href="#L-2899"><span class="linenos">2899</span></a> <span class="n">expression</span><span class="p">,</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-2900"><a href="#L-2900"><span class="linenos">2900</span></a> <span class="p">)</span> +</span><span id="L-2901"><a href="#L-2901"><span class="linenos">2901</span></a> +</span><span id="L-2902"><a href="#L-2902"><span class="linenos">2902</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-2903"><a href="#L-2903"><span class="linenos">2903</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-2904"><a href="#L-2904"><span class="linenos">2904</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-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 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-2907"><a href="#L-2907"><span class="linenos">2907</span></a> -</span><span id="L-2908"><a href="#L-2908"><span class="linenos">2908</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-2908"><a href="#L-2908"><span class="linenos">2908</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-2909"><a href="#L-2909"><span class="linenos">2909</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-2910"><a href="#L-2910"><span class="linenos">2910</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-2911"><a href="#L-2911"><span class="linenos">2911</span></a> -</span><span id="L-2912"><a href="#L-2912"><span class="linenos">2912</span></a> <span class="k">if</span> <span class="n">having</span><span class="p">:</span> -</span><span id="L-2913"><a href="#L-2913"><span class="linenos">2913</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-2910"><a href="#L-2910"><span class="linenos">2910</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-2911"><a href="#L-2911"><span class="linenos">2911</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-2912"><a href="#L-2912"><span class="linenos">2912</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-2913"><a href="#L-2913"><span class="linenos">2913</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-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">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-2916"><a href="#L-2916"><span class="linenos">2916</span></a> -</span><span id="L-2917"><a href="#L-2917"><span class="linenos">2917</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-2918"><a href="#L-2918"><span class="linenos">2918</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-2919"><a href="#L-2919"><span class="linenos">2919</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-2920"><a href="#L-2920"><span class="linenos">2920</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-2921"><a href="#L-2921"><span class="linenos">2921</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-2922"><a href="#L-2922"><span class="linenos">2922</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-2923"><a href="#L-2923"><span class="linenos">2923</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-2924"><a href="#L-2924"><span class="linenos">2924</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-2925"><a href="#L-2925"><span class="linenos">2925</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-2926"><a href="#L-2926"><span class="linenos">2926</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-2927"><a href="#L-2927"><span class="linenos">2927</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-2928"><a href="#L-2928"><span class="linenos">2928</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-2929"><a href="#L-2929"><span class="linenos">2929</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-2930"><a href="#L-2930"><span class="linenos">2930</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-2931"><a href="#L-2931"><span class="linenos">2931</span></a> -</span><span id="L-2932"><a href="#L-2932"><span class="linenos">2932</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-2933"><a href="#L-2933"><span class="linenos">2933</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-2934"><a href="#L-2934"><span class="linenos">2934</span></a> <span class="k">if</span> <span class="n">key_block_size</span><span class="p">:</span> -</span><span id="L-2935"><a href="#L-2935"><span class="linenos">2935</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-2936"><a href="#L-2936"><span class="linenos">2936</span></a> -</span><span id="L-2937"><a href="#L-2937"><span class="linenos">2937</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-2938"><a href="#L-2938"><span class="linenos">2938</span></a> <span class="k">if</span> <span class="n">using</span><span class="p">:</span> -</span><span id="L-2939"><a href="#L-2939"><span class="linenos">2939</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-2915"><a href="#L-2915"><span class="linenos">2915</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-2916"><a href="#L-2916"><span class="linenos">2916</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-2917"><a href="#L-2917"><span class="linenos">2917</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-2918"><a href="#L-2918"><span class="linenos">2918</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-2919"><a href="#L-2919"><span class="linenos">2919</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-2920"><a href="#L-2920"><span class="linenos">2920</span></a> +</span><span id="L-2921"><a href="#L-2921"><span class="linenos">2921</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-2922"><a href="#L-2922"><span class="linenos">2922</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-2923"><a href="#L-2923"><span class="linenos">2923</span></a> +</span><span id="L-2924"><a href="#L-2924"><span class="linenos">2924</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-2925"><a href="#L-2925"><span class="linenos">2925</span></a> <span class="k">return</span> <span class="s2">""</span> +</span><span id="L-2926"><a href="#L-2926"><span class="linenos">2926</span></a> +</span><span id="L-2927"><a href="#L-2927"><span class="linenos">2927</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-2928"><a href="#L-2928"><span class="linenos">2928</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-2929"><a href="#L-2929"><span class="linenos">2929</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-2930"><a href="#L-2930"><span class="linenos">2930</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-2931"><a href="#L-2931"><span class="linenos">2931</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-2932"><a href="#L-2932"><span class="linenos">2932</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-2933"><a href="#L-2933"><span class="linenos">2933</span></a> +</span><span id="L-2934"><a href="#L-2934"><span class="linenos">2934</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-2935"><a href="#L-2935"><span class="linenos">2935</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-2936"><a href="#L-2936"><span class="linenos">2936</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-2937"><a href="#L-2937"><span class="linenos">2937</span></a> +</span><span id="L-2938"><a href="#L-2938"><span class="linenos">2938</span></a> <span class="k">if</span> <span class="n">having</span><span class="p">:</span> +</span><span id="L-2939"><a href="#L-2939"><span class="linenos">2939</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-2940"><a href="#L-2940"><span class="linenos">2940</span></a> -</span><span id="L-2941"><a href="#L-2941"><span class="linenos">2941</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-2942"><a href="#L-2942"><span class="linenos">2942</span></a> <span class="k">if</span> <span class="n">parser</span><span class="p">:</span> -</span><span id="L-2943"><a href="#L-2943"><span class="linenos">2943</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-2944"><a href="#L-2944"><span class="linenos">2944</span></a> -</span><span id="L-2945"><a href="#L-2945"><span class="linenos">2945</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-2946"><a href="#L-2946"><span class="linenos">2946</span></a> <span class="k">if</span> <span class="n">comment</span><span class="p">:</span> -</span><span id="L-2947"><a href="#L-2947"><span class="linenos">2947</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-2948"><a href="#L-2948"><span class="linenos">2948</span></a> -</span><span id="L-2949"><a href="#L-2949"><span class="linenos">2949</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-2950"><a href="#L-2950"><span class="linenos">2950</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-2951"><a href="#L-2951"><span class="linenos">2951</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-2952"><a href="#L-2952"><span class="linenos">2952</span></a> -</span><span id="L-2953"><a href="#L-2953"><span class="linenos">2953</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-2954"><a href="#L-2954"><span class="linenos">2954</span></a> <span class="k">if</span> <span class="n">engine_attr</span><span class="p">:</span> -</span><span id="L-2955"><a href="#L-2955"><span class="linenos">2955</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-2956"><a href="#L-2956"><span class="linenos">2956</span></a> -</span><span id="L-2957"><a href="#L-2957"><span class="linenos">2957</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-2958"><a href="#L-2958"><span class="linenos">2958</span></a> <span class="k">if</span> <span class="n">secondary_engine_attr</span><span class="p">:</span> -</span><span id="L-2959"><a href="#L-2959"><span class="linenos">2959</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-2960"><a href="#L-2960"><span class="linenos">2960</span></a> -</span><span id="L-2961"><a href="#L-2961"><span class="linenos">2961</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-2962"><a href="#L-2962"><span class="linenos">2962</span></a> <span class="k">return</span> <span class="s2">""</span> -</span><span id="L-2963"><a href="#L-2963"><span class="linenos">2963</span></a> -</span><span id="L-2964"><a href="#L-2964"><span class="linenos">2964</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-2965"><a href="#L-2965"><span class="linenos">2965</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-2966"><a href="#L-2966"><span class="linenos">2966</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-2967"><a href="#L-2967"><span class="linenos">2967</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-2968"><a href="#L-2968"><span class="linenos">2968</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-2969"><a href="#L-2969"><span class="linenos">2969</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-2970"><a href="#L-2970"><span class="linenos">2970</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-2971"><a href="#L-2971"><span class="linenos">2971</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-2972"><a href="#L-2972"><span class="linenos">2972</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-2973"><a href="#L-2973"><span class="linenos">2973</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-2974"><a href="#L-2974"><span class="linenos">2974</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-2975"><a href="#L-2975"><span class="linenos">2975</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-2976"><a href="#L-2976"><span class="linenos">2976</span></a> -</span><span id="L-2977"><a href="#L-2977"><span class="linenos">2977</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-2978"><a href="#L-2978"><span class="linenos">2978</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-2979"><a href="#L-2979"><span class="linenos">2979</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-2980"><a href="#L-2980"><span class="linenos">2980</span></a> -</span><span id="L-2981"><a href="#L-2981"><span class="linenos">2981</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-2982"><a href="#L-2982"><span class="linenos">2982</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-2983"><a href="#L-2983"><span class="linenos">2983</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><span id="L-2984"><a href="#L-2984"><span class="linenos">2984</span></a> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> -</span><span id="L-2985"><a href="#L-2985"><span class="linenos">2985</span></a> <span class="p">)</span> -</span><span id="L-2986"><a href="#L-2986"><span class="linenos">2986</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-2987"><a href="#L-2987"><span class="linenos">2987</span></a> <span class="k">if</span> <span class="n">else_cond</span><span class="p">:</span> -</span><span id="L-2988"><a href="#L-2988"><span class="linenos">2988</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="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</span><span id="L-2941"><a href="#L-2941"><span class="linenos">2941</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-2942"><a href="#L-2942"><span class="linenos">2942</span></a> +</span><span id="L-2943"><a href="#L-2943"><span class="linenos">2943</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-2944"><a href="#L-2944"><span class="linenos">2944</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-2945"><a href="#L-2945"><span class="linenos">2945</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-2946"><a href="#L-2946"><span class="linenos">2946</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-2947"><a href="#L-2947"><span class="linenos">2947</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-2948"><a href="#L-2948"><span class="linenos">2948</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-2949"><a href="#L-2949"><span class="linenos">2949</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-2950"><a href="#L-2950"><span class="linenos">2950</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-2951"><a href="#L-2951"><span class="linenos">2951</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-2952"><a href="#L-2952"><span class="linenos">2952</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-2953"><a href="#L-2953"><span class="linenos">2953</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-2954"><a href="#L-2954"><span class="linenos">2954</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-2955"><a href="#L-2955"><span class="linenos">2955</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-2956"><a href="#L-2956"><span class="linenos">2956</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-2957"><a href="#L-2957"><span class="linenos">2957</span></a> +</span><span id="L-2958"><a href="#L-2958"><span class="linenos">2958</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-2959"><a href="#L-2959"><span class="linenos">2959</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-2960"><a href="#L-2960"><span class="linenos">2960</span></a> <span class="k">if</span> <span class="n">key_block_size</span><span class="p">:</span> +</span><span id="L-2961"><a href="#L-2961"><span class="linenos">2961</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-2962"><a href="#L-2962"><span class="linenos">2962</span></a> +</span><span id="L-2963"><a href="#L-2963"><span class="linenos">2963</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-2964"><a href="#L-2964"><span class="linenos">2964</span></a> <span class="k">if</span> <span class="n">using</span><span class="p">:</span> +</span><span id="L-2965"><a href="#L-2965"><span class="linenos">2965</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-2966"><a href="#L-2966"><span class="linenos">2966</span></a> +</span><span id="L-2967"><a href="#L-2967"><span class="linenos">2967</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-2968"><a href="#L-2968"><span class="linenos">2968</span></a> <span class="k">if</span> <span class="n">parser</span><span class="p">:</span> +</span><span id="L-2969"><a href="#L-2969"><span class="linenos">2969</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-2970"><a href="#L-2970"><span class="linenos">2970</span></a> +</span><span id="L-2971"><a href="#L-2971"><span class="linenos">2971</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-2972"><a href="#L-2972"><span class="linenos">2972</span></a> <span class="k">if</span> <span class="n">comment</span><span class="p">:</span> +</span><span id="L-2973"><a href="#L-2973"><span class="linenos">2973</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-2974"><a href="#L-2974"><span class="linenos">2974</span></a> +</span><span id="L-2975"><a href="#L-2975"><span class="linenos">2975</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-2976"><a href="#L-2976"><span class="linenos">2976</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-2977"><a href="#L-2977"><span class="linenos">2977</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-2978"><a href="#L-2978"><span class="linenos">2978</span></a> +</span><span id="L-2979"><a href="#L-2979"><span class="linenos">2979</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-2980"><a href="#L-2980"><span class="linenos">2980</span></a> <span class="k">if</span> <span class="n">engine_attr</span><span class="p">:</span> +</span><span id="L-2981"><a href="#L-2981"><span class="linenos">2981</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-2982"><a href="#L-2982"><span class="linenos">2982</span></a> +</span><span id="L-2983"><a href="#L-2983"><span class="linenos">2983</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-2984"><a href="#L-2984"><span class="linenos">2984</span></a> <span class="k">if</span> <span class="n">secondary_engine_attr</span><span class="p">:</span> +</span><span id="L-2985"><a href="#L-2985"><span class="linenos">2985</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-2986"><a href="#L-2986"><span class="linenos">2986</span></a> +</span><span id="L-2987"><a href="#L-2987"><span class="linenos">2987</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-2988"><a href="#L-2988"><span class="linenos">2988</span></a> <span class="k">return</span> <span class="s2">""</span> </span><span id="L-2989"><a href="#L-2989"><span class="linenos">2989</span></a> -</span><span id="L-2990"><a href="#L-2990"><span class="linenos">2990</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-2991"><a href="#L-2991"><span class="linenos">2991</span></a> -</span><span id="L-2992"><a href="#L-2992"><span class="linenos">2992</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-2990"><a href="#L-2990"><span class="linenos">2990</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-2991"><a href="#L-2991"><span class="linenos">2991</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-2992"><a href="#L-2992"><span class="linenos">2992</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-2993"><a href="#L-2993"><span class="linenos">2993</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-2994"><a href="#L-2994"><span class="linenos">2994</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-2995"><a href="#L-2995"><span class="linenos">2995</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-2996"><a href="#L-2996"><span class="linenos">2996</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-2997"><a href="#L-2997"><span class="linenos">2997</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-2998"><a href="#L-2998"><span class="linenos">2998</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-2999"><a href="#L-2999"><span class="linenos">2999</span></a> -</span><span id="L-3000"><a href="#L-3000"><span class="linenos">3000</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-3001"><a href="#L-3001"><span class="linenos">3001</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-2994"><a href="#L-2994"><span class="linenos">2994</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-2995"><a href="#L-2995"><span class="linenos">2995</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-2996"><a href="#L-2996"><span class="linenos">2996</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-2997"><a href="#L-2997"><span class="linenos">2997</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-2998"><a href="#L-2998"><span class="linenos">2998</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-2999"><a href="#L-2999"><span class="linenos">2999</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-3000"><a href="#L-3000"><span class="linenos">3000</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-3001"><a href="#L-3001"><span class="linenos">3001</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-3002"><a href="#L-3002"><span class="linenos">3002</span></a> -</span><span id="L-3003"><a href="#L-3003"><span class="linenos">3003</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-3004"><a href="#L-3004"><span class="linenos">3004</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-3005"><a href="#L-3005"><span class="linenos">3005</span></a> -</span><span id="L-3006"><a href="#L-3006"><span class="linenos">3006</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-3007"><a href="#L-3007"><span class="linenos">3007</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-3008"><a href="#L-3008"><span class="linenos">3008</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-3009"><a href="#L-3009"><span class="linenos">3009</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-3010"><a href="#L-3010"><span class="linenos">3010</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-3011"><a href="#L-3011"><span class="linenos">3011</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-3012"><a href="#L-3012"><span class="linenos">3012</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-3013"><a href="#L-3013"><span class="linenos">3013</span></a> -</span><span id="L-3014"><a href="#L-3014"><span class="linenos">3014</span></a> <span class="k">def</span> <span class="nf">forin_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ForIn</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-3015"><a href="#L-3015"><span class="linenos">3015</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-3016"><a href="#L-3016"><span class="linenos">3016</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-3017"><a href="#L-3017"><span class="linenos">3017</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"FOR </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> DO </span><span class="si">{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-3018"><a href="#L-3018"><span class="linenos">3018</span></a> -</span><span id="L-3019"><a href="#L-3019"><span class="linenos">3019</span></a> <span class="k">def</span> <span class="nf">refresh_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Refresh</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-3020"><a href="#L-3020"><span class="linenos">3020</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-3021"><a href="#L-3021"><span class="linenos">3021</span></a> <span class="n">table</span> <span class="o">=</span> <span class="s2">""</span> <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">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="p">)</span> <span class="k">else</span> <span class="s2">"TABLE "</span> -</span><span id="L-3022"><a href="#L-3022"><span class="linenos">3022</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"REFRESH </span><span class="si">{</span><span class="n">table</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-3023"><a href="#L-3023"><span class="linenos">3023</span></a> -</span><span id="L-3024"><a href="#L-3024"><span class="linenos">3024</span></a> <span class="k">def</span> <span class="nf">operator_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Operator</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-3025"><a href="#L-3025"><span class="linenos">3025</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="sa">f</span><span class="s2">"OPERATOR(</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">'operator'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">)</span> -</span><span id="L-3026"><a href="#L-3026"><span class="linenos">3026</span></a> -</span><span id="L-3027"><a href="#L-3027"><span class="linenos">3027</span></a> <span class="k">def</span> <span class="nf">_simplify_unless_literal</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">E</span><span class="p">)</span> <span class="o">-></span> <span class="n">E</span><span class="p">:</span> -</span><span id="L-3028"><a href="#L-3028"><span class="linenos">3028</span></a> <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="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="p">):</span> -</span><span id="L-3029"><a href="#L-3029"><span class="linenos">3029</span></a> <span class="kn">from</span> <span class="nn">sqlglot.optimizer.simplify</span> <span class="kn">import</span> <span class="n">simplify</span> -</span><span id="L-3030"><a href="#L-3030"><span class="linenos">3030</span></a> -</span><span id="L-3031"><a href="#L-3031"><span class="linenos">3031</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">simplify</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="L-3032"><a href="#L-3032"><span class="linenos">3032</span></a> -</span><span id="L-3033"><a href="#L-3033"><span class="linenos">3033</span></a> <span class="k">return</span> <span class="n">expression</span> +</span><span id="L-3003"><a href="#L-3003"><span class="linenos">3003</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-3004"><a href="#L-3004"><span class="linenos">3004</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-3005"><a href="#L-3005"><span class="linenos">3005</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-3006"><a href="#L-3006"><span class="linenos">3006</span></a> +</span><span id="L-3007"><a href="#L-3007"><span class="linenos">3007</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-3008"><a href="#L-3008"><span class="linenos">3008</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-3009"><a href="#L-3009"><span class="linenos">3009</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><span id="L-3010"><a href="#L-3010"><span class="linenos">3010</span></a> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> +</span><span id="L-3011"><a href="#L-3011"><span class="linenos">3011</span></a> <span class="p">)</span> +</span><span id="L-3012"><a href="#L-3012"><span class="linenos">3012</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-3013"><a href="#L-3013"><span class="linenos">3013</span></a> <span class="k">if</span> <span class="n">else_cond</span><span class="p">:</span> +</span><span id="L-3014"><a href="#L-3014"><span class="linenos">3014</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="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</span><span id="L-3015"><a href="#L-3015"><span class="linenos">3015</span></a> +</span><span id="L-3016"><a href="#L-3016"><span class="linenos">3016</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-3017"><a href="#L-3017"><span class="linenos">3017</span></a> +</span><span id="L-3018"><a href="#L-3018"><span class="linenos">3018</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-3019"><a href="#L-3019"><span class="linenos">3019</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-3020"><a href="#L-3020"><span class="linenos">3020</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-3021"><a href="#L-3021"><span class="linenos">3021</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-3022"><a href="#L-3022"><span class="linenos">3022</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-3023"><a href="#L-3023"><span class="linenos">3023</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-3024"><a href="#L-3024"><span class="linenos">3024</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-3025"><a href="#L-3025"><span class="linenos">3025</span></a> +</span><span id="L-3026"><a href="#L-3026"><span class="linenos">3026</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-3027"><a href="#L-3027"><span class="linenos">3027</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-3028"><a href="#L-3028"><span class="linenos">3028</span></a> +</span><span id="L-3029"><a href="#L-3029"><span class="linenos">3029</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-3030"><a href="#L-3030"><span class="linenos">3030</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-3031"><a href="#L-3031"><span class="linenos">3031</span></a> +</span><span id="L-3032"><a href="#L-3032"><span class="linenos">3032</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-3033"><a href="#L-3033"><span class="linenos">3033</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-3034"><a href="#L-3034"><span class="linenos">3034</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-3035"><a href="#L-3035"><span class="linenos">3035</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-3036"><a href="#L-3036"><span class="linenos">3036</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-3037"><a href="#L-3037"><span class="linenos">3037</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-3038"><a href="#L-3038"><span class="linenos">3038</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-3039"><a href="#L-3039"><span class="linenos">3039</span></a> +</span><span id="L-3040"><a href="#L-3040"><span class="linenos">3040</span></a> <span class="k">def</span> <span class="nf">forin_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ForIn</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-3041"><a href="#L-3041"><span class="linenos">3041</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-3042"><a href="#L-3042"><span class="linenos">3042</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-3043"><a href="#L-3043"><span class="linenos">3043</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"FOR </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> DO </span><span class="si">{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-3044"><a href="#L-3044"><span class="linenos">3044</span></a> +</span><span id="L-3045"><a href="#L-3045"><span class="linenos">3045</span></a> <span class="k">def</span> <span class="nf">refresh_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Refresh</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-3046"><a href="#L-3046"><span class="linenos">3046</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-3047"><a href="#L-3047"><span class="linenos">3047</span></a> <span class="n">table</span> <span class="o">=</span> <span class="s2">""</span> <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">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="p">)</span> <span class="k">else</span> <span class="s2">"TABLE "</span> +</span><span id="L-3048"><a href="#L-3048"><span class="linenos">3048</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"REFRESH </span><span class="si">{</span><span class="n">table</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-3049"><a href="#L-3049"><span class="linenos">3049</span></a> +</span><span id="L-3050"><a href="#L-3050"><span class="linenos">3050</span></a> <span class="k">def</span> <span class="nf">operator_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Operator</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-3051"><a href="#L-3051"><span class="linenos">3051</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="sa">f</span><span class="s2">"OPERATOR(</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">'operator'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">)</span> +</span><span id="L-3052"><a href="#L-3052"><span class="linenos">3052</span></a> +</span><span id="L-3053"><a href="#L-3053"><span class="linenos">3053</span></a> <span class="k">def</span> <span class="nf">_simplify_unless_literal</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">E</span><span class="p">)</span> <span class="o">-></span> <span class="n">E</span><span class="p">:</span> +</span><span id="L-3054"><a href="#L-3054"><span class="linenos">3054</span></a> <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="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="p">):</span> +</span><span id="L-3055"><a href="#L-3055"><span class="linenos">3055</span></a> <span class="kn">from</span> <span class="nn">sqlglot.optimizer.simplify</span> <span class="kn">import</span> <span class="n">simplify</span> +</span><span id="L-3056"><a href="#L-3056"><span class="linenos">3056</span></a> +</span><span id="L-3057"><a href="#L-3057"><span class="linenos">3057</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">simplify</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-3058"><a href="#L-3058"><span class="linenos">3058</span></a> +</span><span id="L-3059"><a href="#L-3059"><span class="linenos">3059</span></a> <span class="k">return</span> <span class="n">expression</span> +</span><span id="L-3060"><a href="#L-3060"><span class="linenos">3060</span></a> +</span><span id="L-3061"><a href="#L-3061"><span class="linenos">3061</span></a> <span class="k">def</span> <span class="nf">_ensure_string_if_null</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">values</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">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">List</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]:</span> +</span><span id="L-3062"><a href="#L-3062"><span class="linenos">3062</span></a> <span class="k">return</span> <span class="p">[</span> +</span><span id="L-3063"><a href="#L-3063"><span class="linenos">3063</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"COALESCE"</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">value</span><span class="p">,</span> <span class="s2">"text"</span><span class="p">),</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="s2">""</span><span class="p">))</span> +</span><span id="L-3064"><a href="#L-3064"><span class="linenos">3064</span></a> <span class="k">for</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">values</span> +</span><span id="L-3065"><a href="#L-3065"><span class="linenos">3065</span></a> <span class="k">if</span> <span class="n">value</span> +</span><span id="L-3066"><a href="#L-3066"><span class="linenos">3066</span></a> <span class="p">]</span> </span></pre></div> @@ -4367,2809 +4412,2842 @@ </span><span id="Generator-229"><a href="#Generator-229"><span class="linenos"> 229</span></a> <span class="c1"># Whether or not the "RECURSIVE" keyword is required when defining recursive CTEs</span> </span><span id="Generator-230"><a href="#Generator-230"><span class="linenos"> 230</span></a> <span class="n">CTE_RECURSIVE_KEYWORD_REQUIRED</span> <span class="o">=</span> <span class="kc">True</span> </span><span id="Generator-231"><a href="#Generator-231"><span class="linenos"> 231</span></a> -</span><span id="Generator-232"><a href="#Generator-232"><span class="linenos"> 232</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Generator-233"><a href="#Generator-233"><span class="linenos"> 233</span></a> <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">NCHAR</span><span class="p">:</span> <span class="s2">"CHAR"</span><span class="p">,</span> -</span><span id="Generator-234"><a href="#Generator-234"><span class="linenos"> 234</span></a> <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">NVARCHAR</span><span class="p">:</span> <span class="s2">"VARCHAR"</span><span class="p">,</span> -</span><span id="Generator-235"><a href="#Generator-235"><span class="linenos"> 235</span></a> <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">MEDIUMTEXT</span><span class="p">:</span> <span class="s2">"TEXT"</span><span class="p">,</span> -</span><span id="Generator-236"><a href="#Generator-236"><span class="linenos"> 236</span></a> <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">LONGTEXT</span><span class="p">:</span> <span class="s2">"TEXT"</span><span class="p">,</span> -</span><span id="Generator-237"><a href="#Generator-237"><span class="linenos"> 237</span></a> <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">TINYTEXT</span><span class="p">:</span> <span class="s2">"TEXT"</span><span class="p">,</span> -</span><span id="Generator-238"><a href="#Generator-238"><span class="linenos"> 238</span></a> <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">MEDIUMBLOB</span><span class="p">:</span> <span class="s2">"BLOB"</span><span class="p">,</span> -</span><span id="Generator-239"><a href="#Generator-239"><span class="linenos"> 239</span></a> <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">LONGBLOB</span><span class="p">:</span> <span class="s2">"BLOB"</span><span class="p">,</span> -</span><span id="Generator-240"><a href="#Generator-240"><span class="linenos"> 240</span></a> <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">TINYBLOB</span><span class="p">:</span> <span class="s2">"BLOB"</span><span class="p">,</span> -</span><span id="Generator-241"><a href="#Generator-241"><span class="linenos"> 241</span></a> <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">INET</span><span class="p">:</span> <span class="s2">"INET"</span><span class="p">,</span> -</span><span id="Generator-242"><a href="#Generator-242"><span class="linenos"> 242</span></a> <span class="p">}</span> -</span><span id="Generator-243"><a href="#Generator-243"><span class="linenos"> 243</span></a> -</span><span id="Generator-244"><a href="#Generator-244"><span class="linenos"> 244</span></a> <span class="n">STAR_MAPPING</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Generator-245"><a href="#Generator-245"><span class="linenos"> 245</span></a> <span class="s2">"except"</span><span class="p">:</span> <span class="s2">"EXCEPT"</span><span class="p">,</span> -</span><span id="Generator-246"><a href="#Generator-246"><span class="linenos"> 246</span></a> <span class="s2">"replace"</span><span class="p">:</span> <span class="s2">"REPLACE"</span><span class="p">,</span> -</span><span id="Generator-247"><a href="#Generator-247"><span class="linenos"> 247</span></a> <span class="p">}</span> -</span><span id="Generator-248"><a href="#Generator-248"><span class="linenos"> 248</span></a> -</span><span id="Generator-249"><a href="#Generator-249"><span class="linenos"> 249</span></a> <span class="n">TIME_PART_SINGULARS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Generator-250"><a href="#Generator-250"><span class="linenos"> 250</span></a> <span class="s2">"microseconds"</span><span class="p">:</span> <span class="s2">"microsecond"</span><span class="p">,</span> -</span><span id="Generator-251"><a href="#Generator-251"><span class="linenos"> 251</span></a> <span class="s2">"seconds"</span><span class="p">:</span> <span class="s2">"second"</span><span class="p">,</span> -</span><span id="Generator-252"><a href="#Generator-252"><span class="linenos"> 252</span></a> <span class="s2">"minutes"</span><span class="p">:</span> <span class="s2">"minute"</span><span class="p">,</span> -</span><span id="Generator-253"><a href="#Generator-253"><span class="linenos"> 253</span></a> <span class="s2">"hours"</span><span class="p">:</span> <span class="s2">"hour"</span><span class="p">,</span> -</span><span id="Generator-254"><a href="#Generator-254"><span class="linenos"> 254</span></a> <span class="s2">"days"</span><span class="p">:</span> <span class="s2">"day"</span><span class="p">,</span> -</span><span id="Generator-255"><a href="#Generator-255"><span class="linenos"> 255</span></a> <span class="s2">"weeks"</span><span class="p">:</span> <span class="s2">"week"</span><span class="p">,</span> -</span><span id="Generator-256"><a href="#Generator-256"><span class="linenos"> 256</span></a> <span class="s2">"months"</span><span class="p">:</span> <span class="s2">"month"</span><span class="p">,</span> -</span><span id="Generator-257"><a href="#Generator-257"><span class="linenos"> 257</span></a> <span class="s2">"quarters"</span><span class="p">:</span> <span class="s2">"quarter"</span><span class="p">,</span> -</span><span id="Generator-258"><a href="#Generator-258"><span class="linenos"> 258</span></a> <span class="s2">"years"</span><span class="p">:</span> <span class="s2">"year"</span><span class="p">,</span> -</span><span id="Generator-259"><a href="#Generator-259"><span class="linenos"> 259</span></a> <span class="p">}</span> -</span><span id="Generator-260"><a href="#Generator-260"><span class="linenos"> 260</span></a> -</span><span id="Generator-261"><a href="#Generator-261"><span class="linenos"> 261</span></a> <span class="n">TOKEN_MAPPING</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="n">TokenType</span><span class="p">,</span> <span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> -</span><span id="Generator-262"><a href="#Generator-262"><span class="linenos"> 262</span></a> -</span><span id="Generator-263"><a href="#Generator-263"><span class="linenos"> 263</span></a> <span class="n">STRUCT_DELIMITER</span> <span class="o">=</span> <span class="p">(</span><span class="s2">"<"</span><span class="p">,</span> <span class="s2">">"</span><span class="p">)</span> -</span><span id="Generator-264"><a href="#Generator-264"><span class="linenos"> 264</span></a> -</span><span id="Generator-265"><a href="#Generator-265"><span class="linenos"> 265</span></a> <span class="n">PARAMETER_TOKEN</span> <span class="o">=</span> <span class="s2">"@"</span> -</span><span id="Generator-266"><a href="#Generator-266"><span class="linenos"> 266</span></a> -</span><span id="Generator-267"><a href="#Generator-267"><span class="linenos"> 267</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Generator-268"><a href="#Generator-268"><span class="linenos"> 268</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">AlgorithmProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">,</span> -</span><span id="Generator-269"><a href="#Generator-269"><span class="linenos"> 269</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">AutoIncrementProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="Generator-270"><a href="#Generator-270"><span class="linenos"> 270</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BlockCompressionProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> -</span><span id="Generator-271"><a href="#Generator-271"><span class="linenos"> 271</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CharacterSetProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="Generator-272"><a href="#Generator-272"><span class="linenos"> 272</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ChecksumProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> -</span><span id="Generator-273"><a href="#Generator-273"><span class="linenos"> 273</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CollateProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="Generator-274"><a href="#Generator-274"><span class="linenos"> 274</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CopyGrantsProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="Generator-275"><a href="#Generator-275"><span class="linenos"> 275</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Cluster</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="Generator-276"><a href="#Generator-276"><span class="linenos"> 276</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ClusteredByProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="Generator-277"><a href="#Generator-277"><span class="linenos"> 277</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataBlocksizeProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> -</span><span id="Generator-278"><a href="#Generator-278"><span class="linenos"> 278</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DefinerProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">,</span> -</span><span id="Generator-279"><a href="#Generator-279"><span class="linenos"> 279</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DictRange</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="Generator-280"><a href="#Generator-280"><span class="linenos"> 280</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DictProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="Generator-281"><a href="#Generator-281"><span class="linenos"> 281</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DistKeyProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="Generator-282"><a href="#Generator-282"><span class="linenos"> 282</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DistStyleProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="Generator-283"><a href="#Generator-283"><span class="linenos"> 283</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">EngineProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="Generator-284"><a href="#Generator-284"><span class="linenos"> 284</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ExecuteAsProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="Generator-285"><a href="#Generator-285"><span class="linenos"> 285</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ExternalProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">,</span> -</span><span id="Generator-286"><a href="#Generator-286"><span class="linenos"> 286</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FallbackProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> -</span><span id="Generator-287"><a href="#Generator-287"><span class="linenos"> 287</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FileFormatProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">,</span> -</span><span id="Generator-288"><a href="#Generator-288"><span class="linenos"> 288</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FreespaceProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> -</span><span id="Generator-289"><a href="#Generator-289"><span class="linenos"> 289</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">HeapProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">,</span> -</span><span id="Generator-290"><a href="#Generator-290"><span class="linenos"> 290</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">InputModelProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="Generator-291"><a href="#Generator-291"><span class="linenos"> 291</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">IsolatedLoadingProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> -</span><span id="Generator-292"><a href="#Generator-292"><span class="linenos"> 292</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JournalProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> -</span><span id="Generator-293"><a href="#Generator-293"><span class="linenos"> 293</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LanguageProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="Generator-294"><a href="#Generator-294"><span class="linenos"> 294</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LikeProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="Generator-295"><a href="#Generator-295"><span class="linenos"> 295</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LocationProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="Generator-296"><a href="#Generator-296"><span class="linenos"> 296</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LockingProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_ALIAS</span><span class="p">,</span> -</span><span id="Generator-297"><a href="#Generator-297"><span class="linenos"> 297</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LogProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> -</span><span id="Generator-298"><a href="#Generator-298"><span class="linenos"> 298</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MaterializedProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">,</span> -</span><span id="Generator-299"><a href="#Generator-299"><span class="linenos"> 299</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MergeBlockRatioProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> -</span><span id="Generator-300"><a href="#Generator-300"><span class="linenos"> 300</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">NoPrimaryIndexProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_EXPRESSION</span><span class="p">,</span> -</span><span id="Generator-301"><a href="#Generator-301"><span class="linenos"> 301</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">OnProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="Generator-302"><a href="#Generator-302"><span class="linenos"> 302</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">OnCommitProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_EXPRESSION</span><span class="p">,</span> -</span><span id="Generator-303"><a href="#Generator-303"><span class="linenos"> 303</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Order</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="Generator-304"><a href="#Generator-304"><span class="linenos"> 304</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">OutputModelProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="Generator-305"><a href="#Generator-305"><span class="linenos"> 305</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionedByProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">,</span> -</span><span id="Generator-306"><a href="#Generator-306"><span class="linenos"> 306</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionedOfProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="Generator-307"><a href="#Generator-307"><span class="linenos"> 307</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PrimaryKey</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="Generator-308"><a href="#Generator-308"><span class="linenos"> 308</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Property</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">,</span> -</span><span id="Generator-309"><a href="#Generator-309"><span class="linenos"> 309</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RemoteWithConnectionModelProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="Generator-310"><a href="#Generator-310"><span class="linenos"> 310</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ReturnsProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="Generator-311"><a href="#Generator-311"><span class="linenos"> 311</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RowFormatProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="Generator-312"><a href="#Generator-312"><span class="linenos"> 312</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RowFormatDelimitedProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="Generator-313"><a href="#Generator-313"><span class="linenos"> 313</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RowFormatSerdeProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="Generator-314"><a href="#Generator-314"><span class="linenos"> 314</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SampleProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="Generator-315"><a href="#Generator-315"><span class="linenos"> 315</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SchemaCommentProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="Generator-316"><a href="#Generator-316"><span class="linenos"> 316</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SerdeProperties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="Generator-317"><a href="#Generator-317"><span class="linenos"> 317</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Set</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="Generator-318"><a href="#Generator-318"><span class="linenos"> 318</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SettingsProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="Generator-319"><a href="#Generator-319"><span class="linenos"> 319</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SetProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">,</span> -</span><span id="Generator-320"><a href="#Generator-320"><span class="linenos"> 320</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SortKeyProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="Generator-321"><a href="#Generator-321"><span class="linenos"> 321</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SqlSecurityProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">,</span> -</span><span id="Generator-322"><a href="#Generator-322"><span class="linenos"> 322</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StabilityProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="Generator-323"><a href="#Generator-323"><span class="linenos"> 323</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TemporaryProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">,</span> -</span><span id="Generator-324"><a href="#Generator-324"><span class="linenos"> 324</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ToTableProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="Generator-325"><a href="#Generator-325"><span class="linenos"> 325</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TransientProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">,</span> -</span><span id="Generator-326"><a href="#Generator-326"><span class="linenos"> 326</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TransformModelProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="Generator-327"><a href="#Generator-327"><span class="linenos"> 327</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MergeTreeTTL</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="Generator-328"><a href="#Generator-328"><span class="linenos"> 328</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VolatileProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">,</span> -</span><span id="Generator-329"><a href="#Generator-329"><span class="linenos"> 329</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">WithDataProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_EXPRESSION</span><span class="p">,</span> -</span><span id="Generator-330"><a href="#Generator-330"><span class="linenos"> 330</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">WithJournalTableProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> -</span><span id="Generator-331"><a href="#Generator-331"><span class="linenos"> 331</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">WithSystemVersioningProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="Generator-332"><a href="#Generator-332"><span class="linenos"> 332</span></a> <span class="p">}</span> -</span><span id="Generator-333"><a href="#Generator-333"><span class="linenos"> 333</span></a> -</span><span id="Generator-334"><a href="#Generator-334"><span class="linenos"> 334</span></a> <span class="c1"># Keywords that can't be used as unquoted identifier names</span> -</span><span id="Generator-335"><a href="#Generator-335"><span class="linenos"> 335</span></a> <span class="n">RESERVED_KEYWORDS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Set</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="nb">set</span><span class="p">()</span> +</span><span id="Generator-232"><a href="#Generator-232"><span class="linenos"> 232</span></a> <span class="c1"># Whether or not CONCAT requires >1 arguments</span> +</span><span id="Generator-233"><a href="#Generator-233"><span class="linenos"> 233</span></a> <span class="n">SUPPORTS_SINGLE_ARG_CONCAT</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="Generator-234"><a href="#Generator-234"><span class="linenos"> 234</span></a> +</span><span id="Generator-235"><a href="#Generator-235"><span class="linenos"> 235</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Generator-236"><a href="#Generator-236"><span class="linenos"> 236</span></a> <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">NCHAR</span><span class="p">:</span> <span class="s2">"CHAR"</span><span class="p">,</span> +</span><span id="Generator-237"><a href="#Generator-237"><span class="linenos"> 237</span></a> <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">NVARCHAR</span><span class="p">:</span> <span class="s2">"VARCHAR"</span><span class="p">,</span> +</span><span id="Generator-238"><a href="#Generator-238"><span class="linenos"> 238</span></a> <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">MEDIUMTEXT</span><span class="p">:</span> <span class="s2">"TEXT"</span><span class="p">,</span> +</span><span id="Generator-239"><a href="#Generator-239"><span class="linenos"> 239</span></a> <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">LONGTEXT</span><span class="p">:</span> <span class="s2">"TEXT"</span><span class="p">,</span> +</span><span id="Generator-240"><a href="#Generator-240"><span class="linenos"> 240</span></a> <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">TINYTEXT</span><span class="p">:</span> <span class="s2">"TEXT"</span><span class="p">,</span> +</span><span id="Generator-241"><a href="#Generator-241"><span class="linenos"> 241</span></a> <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">MEDIUMBLOB</span><span class="p">:</span> <span class="s2">"BLOB"</span><span class="p">,</span> +</span><span id="Generator-242"><a href="#Generator-242"><span class="linenos"> 242</span></a> <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">LONGBLOB</span><span class="p">:</span> <span class="s2">"BLOB"</span><span class="p">,</span> +</span><span id="Generator-243"><a href="#Generator-243"><span class="linenos"> 243</span></a> <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">TINYBLOB</span><span class="p">:</span> <span class="s2">"BLOB"</span><span class="p">,</span> +</span><span id="Generator-244"><a href="#Generator-244"><span class="linenos"> 244</span></a> <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">INET</span><span class="p">:</span> <span class="s2">"INET"</span><span class="p">,</span> +</span><span id="Generator-245"><a href="#Generator-245"><span class="linenos"> 245</span></a> <span class="p">}</span> +</span><span id="Generator-246"><a href="#Generator-246"><span class="linenos"> 246</span></a> +</span><span id="Generator-247"><a href="#Generator-247"><span class="linenos"> 247</span></a> <span class="n">STAR_MAPPING</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Generator-248"><a href="#Generator-248"><span class="linenos"> 248</span></a> <span class="s2">"except"</span><span class="p">:</span> <span class="s2">"EXCEPT"</span><span class="p">,</span> +</span><span id="Generator-249"><a href="#Generator-249"><span class="linenos"> 249</span></a> <span class="s2">"replace"</span><span class="p">:</span> <span class="s2">"REPLACE"</span><span class="p">,</span> +</span><span id="Generator-250"><a href="#Generator-250"><span class="linenos"> 250</span></a> <span class="p">}</span> +</span><span id="Generator-251"><a href="#Generator-251"><span class="linenos"> 251</span></a> +</span><span id="Generator-252"><a href="#Generator-252"><span class="linenos"> 252</span></a> <span class="n">TIME_PART_SINGULARS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Generator-253"><a href="#Generator-253"><span class="linenos"> 253</span></a> <span class="s2">"microseconds"</span><span class="p">:</span> <span class="s2">"microsecond"</span><span class="p">,</span> +</span><span id="Generator-254"><a href="#Generator-254"><span class="linenos"> 254</span></a> <span class="s2">"seconds"</span><span class="p">:</span> <span class="s2">"second"</span><span class="p">,</span> +</span><span id="Generator-255"><a href="#Generator-255"><span class="linenos"> 255</span></a> <span class="s2">"minutes"</span><span class="p">:</span> <span class="s2">"minute"</span><span class="p">,</span> +</span><span id="Generator-256"><a href="#Generator-256"><span class="linenos"> 256</span></a> <span class="s2">"hours"</span><span class="p">:</span> <span class="s2">"hour"</span><span class="p">,</span> +</span><span id="Generator-257"><a href="#Generator-257"><span class="linenos"> 257</span></a> <span class="s2">"days"</span><span class="p">:</span> <span class="s2">"day"</span><span class="p">,</span> +</span><span id="Generator-258"><a href="#Generator-258"><span class="linenos"> 258</span></a> <span class="s2">"weeks"</span><span class="p">:</span> <span class="s2">"week"</span><span class="p">,</span> +</span><span id="Generator-259"><a href="#Generator-259"><span class="linenos"> 259</span></a> <span class="s2">"months"</span><span class="p">:</span> <span class="s2">"month"</span><span class="p">,</span> +</span><span id="Generator-260"><a href="#Generator-260"><span class="linenos"> 260</span></a> <span class="s2">"quarters"</span><span class="p">:</span> <span class="s2">"quarter"</span><span class="p">,</span> +</span><span id="Generator-261"><a href="#Generator-261"><span class="linenos"> 261</span></a> <span class="s2">"years"</span><span class="p">:</span> <span class="s2">"year"</span><span class="p">,</span> +</span><span id="Generator-262"><a href="#Generator-262"><span class="linenos"> 262</span></a> <span class="p">}</span> +</span><span id="Generator-263"><a href="#Generator-263"><span class="linenos"> 263</span></a> +</span><span id="Generator-264"><a href="#Generator-264"><span class="linenos"> 264</span></a> <span class="n">TOKEN_MAPPING</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="n">TokenType</span><span class="p">,</span> <span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> +</span><span id="Generator-265"><a href="#Generator-265"><span class="linenos"> 265</span></a> +</span><span id="Generator-266"><a href="#Generator-266"><span class="linenos"> 266</span></a> <span class="n">STRUCT_DELIMITER</span> <span class="o">=</span> <span class="p">(</span><span class="s2">"<"</span><span class="p">,</span> <span class="s2">">"</span><span class="p">)</span> +</span><span id="Generator-267"><a href="#Generator-267"><span class="linenos"> 267</span></a> +</span><span id="Generator-268"><a href="#Generator-268"><span class="linenos"> 268</span></a> <span class="n">PARAMETER_TOKEN</span> <span class="o">=</span> <span class="s2">"@"</span> +</span><span id="Generator-269"><a href="#Generator-269"><span class="linenos"> 269</span></a> +</span><span id="Generator-270"><a href="#Generator-270"><span class="linenos"> 270</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Generator-271"><a href="#Generator-271"><span class="linenos"> 271</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">AlgorithmProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">,</span> +</span><span id="Generator-272"><a href="#Generator-272"><span class="linenos"> 272</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">AutoIncrementProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="Generator-273"><a href="#Generator-273"><span class="linenos"> 273</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BlockCompressionProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> +</span><span id="Generator-274"><a href="#Generator-274"><span class="linenos"> 274</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CharacterSetProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="Generator-275"><a href="#Generator-275"><span class="linenos"> 275</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ChecksumProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> +</span><span id="Generator-276"><a href="#Generator-276"><span class="linenos"> 276</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CollateProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="Generator-277"><a href="#Generator-277"><span class="linenos"> 277</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CopyGrantsProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="Generator-278"><a href="#Generator-278"><span class="linenos"> 278</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Cluster</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="Generator-279"><a href="#Generator-279"><span class="linenos"> 279</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ClusteredByProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="Generator-280"><a href="#Generator-280"><span class="linenos"> 280</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataBlocksizeProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> +</span><span id="Generator-281"><a href="#Generator-281"><span class="linenos"> 281</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DefinerProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">,</span> +</span><span id="Generator-282"><a href="#Generator-282"><span class="linenos"> 282</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DictRange</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="Generator-283"><a href="#Generator-283"><span class="linenos"> 283</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DictProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="Generator-284"><a href="#Generator-284"><span class="linenos"> 284</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DistKeyProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="Generator-285"><a href="#Generator-285"><span class="linenos"> 285</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DistStyleProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="Generator-286"><a href="#Generator-286"><span class="linenos"> 286</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">EngineProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="Generator-287"><a href="#Generator-287"><span class="linenos"> 287</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ExecuteAsProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="Generator-288"><a href="#Generator-288"><span class="linenos"> 288</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ExternalProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">,</span> +</span><span id="Generator-289"><a href="#Generator-289"><span class="linenos"> 289</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FallbackProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> +</span><span id="Generator-290"><a href="#Generator-290"><span class="linenos"> 290</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FileFormatProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">,</span> +</span><span id="Generator-291"><a href="#Generator-291"><span class="linenos"> 291</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FreespaceProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> +</span><span id="Generator-292"><a href="#Generator-292"><span class="linenos"> 292</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">HeapProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">,</span> +</span><span id="Generator-293"><a href="#Generator-293"><span class="linenos"> 293</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">InputModelProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="Generator-294"><a href="#Generator-294"><span class="linenos"> 294</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">IsolatedLoadingProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> +</span><span id="Generator-295"><a href="#Generator-295"><span class="linenos"> 295</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JournalProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> +</span><span id="Generator-296"><a href="#Generator-296"><span class="linenos"> 296</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LanguageProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="Generator-297"><a href="#Generator-297"><span class="linenos"> 297</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LikeProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="Generator-298"><a href="#Generator-298"><span class="linenos"> 298</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LocationProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="Generator-299"><a href="#Generator-299"><span class="linenos"> 299</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LockingProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_ALIAS</span><span class="p">,</span> +</span><span id="Generator-300"><a href="#Generator-300"><span class="linenos"> 300</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LogProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> +</span><span id="Generator-301"><a href="#Generator-301"><span class="linenos"> 301</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MaterializedProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">,</span> +</span><span id="Generator-302"><a href="#Generator-302"><span class="linenos"> 302</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MergeBlockRatioProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> +</span><span id="Generator-303"><a href="#Generator-303"><span class="linenos"> 303</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">NoPrimaryIndexProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_EXPRESSION</span><span class="p">,</span> +</span><span id="Generator-304"><a href="#Generator-304"><span class="linenos"> 304</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">OnProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="Generator-305"><a href="#Generator-305"><span class="linenos"> 305</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">OnCommitProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_EXPRESSION</span><span class="p">,</span> +</span><span id="Generator-306"><a href="#Generator-306"><span class="linenos"> 306</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Order</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="Generator-307"><a href="#Generator-307"><span class="linenos"> 307</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">OutputModelProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="Generator-308"><a href="#Generator-308"><span class="linenos"> 308</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionedByProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">,</span> +</span><span id="Generator-309"><a href="#Generator-309"><span class="linenos"> 309</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionedOfProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="Generator-310"><a href="#Generator-310"><span class="linenos"> 310</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PrimaryKey</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="Generator-311"><a href="#Generator-311"><span class="linenos"> 311</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Property</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">,</span> +</span><span id="Generator-312"><a href="#Generator-312"><span class="linenos"> 312</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RemoteWithConnectionModelProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="Generator-313"><a href="#Generator-313"><span class="linenos"> 313</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ReturnsProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="Generator-314"><a href="#Generator-314"><span class="linenos"> 314</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RowFormatProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="Generator-315"><a href="#Generator-315"><span class="linenos"> 315</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RowFormatDelimitedProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="Generator-316"><a href="#Generator-316"><span class="linenos"> 316</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RowFormatSerdeProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="Generator-317"><a href="#Generator-317"><span class="linenos"> 317</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SampleProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="Generator-318"><a href="#Generator-318"><span class="linenos"> 318</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SchemaCommentProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="Generator-319"><a href="#Generator-319"><span class="linenos"> 319</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SerdeProperties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="Generator-320"><a href="#Generator-320"><span class="linenos"> 320</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Set</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="Generator-321"><a href="#Generator-321"><span class="linenos"> 321</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SettingsProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="Generator-322"><a href="#Generator-322"><span class="linenos"> 322</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SetProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">,</span> +</span><span id="Generator-323"><a href="#Generator-323"><span class="linenos"> 323</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SortKeyProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="Generator-324"><a href="#Generator-324"><span class="linenos"> 324</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SqlSecurityProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">,</span> +</span><span id="Generator-325"><a href="#Generator-325"><span class="linenos"> 325</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StabilityProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="Generator-326"><a href="#Generator-326"><span class="linenos"> 326</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TemporaryProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">,</span> +</span><span id="Generator-327"><a href="#Generator-327"><span class="linenos"> 327</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ToTableProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="Generator-328"><a href="#Generator-328"><span class="linenos"> 328</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TransientProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">,</span> +</span><span id="Generator-329"><a href="#Generator-329"><span class="linenos"> 329</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TransformModelProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="Generator-330"><a href="#Generator-330"><span class="linenos"> 330</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MergeTreeTTL</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="Generator-331"><a href="#Generator-331"><span class="linenos"> 331</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VolatileProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">,</span> +</span><span id="Generator-332"><a href="#Generator-332"><span class="linenos"> 332</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">WithDataProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_EXPRESSION</span><span class="p">,</span> +</span><span id="Generator-333"><a href="#Generator-333"><span class="linenos"> 333</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">WithJournalTableProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> +</span><span id="Generator-334"><a href="#Generator-334"><span class="linenos"> 334</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">WithSystemVersioningProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="Generator-335"><a href="#Generator-335"><span class="linenos"> 335</span></a> <span class="p">}</span> </span><span id="Generator-336"><a href="#Generator-336"><span class="linenos"> 336</span></a> -</span><span id="Generator-337"><a href="#Generator-337"><span class="linenos"> 337</span></a> <span class="c1"># Expressions whose comments are separated from them for better formatting</span> -</span><span id="Generator-338"><a href="#Generator-338"><span class="linenos"> 338</span></a> <span class="n">WITH_SEPARATED_COMMENTS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Type</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="p">]</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Generator-339"><a href="#Generator-339"><span class="linenos"> 339</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">,</span> -</span><span id="Generator-340"><a href="#Generator-340"><span class="linenos"> 340</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Delete</span><span class="p">,</span> -</span><span id="Generator-341"><a href="#Generator-341"><span class="linenos"> 341</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Drop</span><span class="p">,</span> -</span><span id="Generator-342"><a href="#Generator-342"><span class="linenos"> 342</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">From</span><span class="p">,</span> -</span><span id="Generator-343"><a href="#Generator-343"><span class="linenos"> 343</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Insert</span><span class="p">,</span> -</span><span id="Generator-344"><a href="#Generator-344"><span class="linenos"> 344</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Join</span><span class="p">,</span> -</span><span id="Generator-345"><a href="#Generator-345"><span class="linenos"> 345</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">,</span> -</span><span id="Generator-346"><a href="#Generator-346"><span class="linenos"> 346</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Update</span><span class="p">,</span> -</span><span id="Generator-347"><a href="#Generator-347"><span class="linenos"> 347</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Where</span><span class="p">,</span> -</span><span id="Generator-348"><a href="#Generator-348"><span class="linenos"> 348</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">With</span><span class="p">,</span> -</span><span id="Generator-349"><a href="#Generator-349"><span class="linenos"> 349</span></a> <span class="p">)</span> -</span><span id="Generator-350"><a href="#Generator-350"><span class="linenos"> 350</span></a> -</span><span id="Generator-351"><a href="#Generator-351"><span class="linenos"> 351</span></a> <span class="c1"># Expressions that should not have their comments generated in maybe_comment</span> -</span><span id="Generator-352"><a href="#Generator-352"><span class="linenos"> 352</span></a> <span class="n">EXCLUDE_COMMENTS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Type</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="p">]</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Generator-353"><a href="#Generator-353"><span class="linenos"> 353</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Binary</span><span class="p">,</span> -</span><span id="Generator-354"><a href="#Generator-354"><span class="linenos"> 354</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Union</span><span class="p">,</span> -</span><span id="Generator-355"><a href="#Generator-355"><span class="linenos"> 355</span></a> <span class="p">)</span> -</span><span id="Generator-356"><a href="#Generator-356"><span class="linenos"> 356</span></a> -</span><span id="Generator-357"><a href="#Generator-357"><span class="linenos"> 357</span></a> <span class="c1"># Expressions that can remain unwrapped when appearing in the context of an INTERVAL</span> -</span><span id="Generator-358"><a href="#Generator-358"><span class="linenos"> 358</span></a> <span class="n">UNWRAPPED_INTERVAL_VALUES</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Type</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="p">]</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Generator-359"><a href="#Generator-359"><span class="linenos"> 359</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">,</span> -</span><span id="Generator-360"><a href="#Generator-360"><span class="linenos"> 360</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="p">,</span> -</span><span id="Generator-361"><a href="#Generator-361"><span class="linenos"> 361</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Neg</span><span class="p">,</span> -</span><span id="Generator-362"><a href="#Generator-362"><span class="linenos"> 362</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Paren</span><span class="p">,</span> -</span><span id="Generator-363"><a href="#Generator-363"><span class="linenos"> 363</span></a> <span class="p">)</span> -</span><span id="Generator-364"><a href="#Generator-364"><span class="linenos"> 364</span></a> -</span><span id="Generator-365"><a href="#Generator-365"><span class="linenos"> 365</span></a> <span class="c1"># Expressions that need to have all CTEs under them bubbled up to them</span> -</span><span id="Generator-366"><a href="#Generator-366"><span class="linenos"> 366</span></a> <span class="n">EXPRESSIONS_WITHOUT_NESTED_CTES</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Set</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Type</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="nb">set</span><span class="p">()</span> +</span><span id="Generator-337"><a href="#Generator-337"><span class="linenos"> 337</span></a> <span class="c1"># Keywords that can't be used as unquoted identifier names</span> +</span><span id="Generator-338"><a href="#Generator-338"><span class="linenos"> 338</span></a> <span class="n">RESERVED_KEYWORDS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Set</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="nb">set</span><span class="p">()</span> +</span><span id="Generator-339"><a href="#Generator-339"><span class="linenos"> 339</span></a> +</span><span id="Generator-340"><a href="#Generator-340"><span class="linenos"> 340</span></a> <span class="c1"># Expressions whose comments are separated from them for better formatting</span> +</span><span id="Generator-341"><a href="#Generator-341"><span class="linenos"> 341</span></a> <span class="n">WITH_SEPARATED_COMMENTS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Type</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="p">]</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Generator-342"><a href="#Generator-342"><span class="linenos"> 342</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">,</span> +</span><span id="Generator-343"><a href="#Generator-343"><span class="linenos"> 343</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Delete</span><span class="p">,</span> +</span><span id="Generator-344"><a href="#Generator-344"><span class="linenos"> 344</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Drop</span><span class="p">,</span> +</span><span id="Generator-345"><a href="#Generator-345"><span class="linenos"> 345</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">From</span><span class="p">,</span> +</span><span id="Generator-346"><a href="#Generator-346"><span class="linenos"> 346</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Insert</span><span class="p">,</span> +</span><span id="Generator-347"><a href="#Generator-347"><span class="linenos"> 347</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Join</span><span class="p">,</span> +</span><span id="Generator-348"><a href="#Generator-348"><span class="linenos"> 348</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">,</span> +</span><span id="Generator-349"><a href="#Generator-349"><span class="linenos"> 349</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Update</span><span class="p">,</span> +</span><span id="Generator-350"><a href="#Generator-350"><span class="linenos"> 350</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Where</span><span class="p">,</span> +</span><span id="Generator-351"><a href="#Generator-351"><span class="linenos"> 351</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">With</span><span class="p">,</span> +</span><span id="Generator-352"><a href="#Generator-352"><span class="linenos"> 352</span></a> <span class="p">)</span> +</span><span id="Generator-353"><a href="#Generator-353"><span class="linenos"> 353</span></a> +</span><span id="Generator-354"><a href="#Generator-354"><span class="linenos"> 354</span></a> <span class="c1"># Expressions that should not have their comments generated in maybe_comment</span> +</span><span id="Generator-355"><a href="#Generator-355"><span class="linenos"> 355</span></a> <span class="n">EXCLUDE_COMMENTS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Type</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="p">]</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Generator-356"><a href="#Generator-356"><span class="linenos"> 356</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Binary</span><span class="p">,</span> +</span><span id="Generator-357"><a href="#Generator-357"><span class="linenos"> 357</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Union</span><span class="p">,</span> +</span><span id="Generator-358"><a href="#Generator-358"><span class="linenos"> 358</span></a> <span class="p">)</span> +</span><span id="Generator-359"><a href="#Generator-359"><span class="linenos"> 359</span></a> +</span><span id="Generator-360"><a href="#Generator-360"><span class="linenos"> 360</span></a> <span class="c1"># Expressions that can remain unwrapped when appearing in the context of an INTERVAL</span> +</span><span id="Generator-361"><a href="#Generator-361"><span class="linenos"> 361</span></a> <span class="n">UNWRAPPED_INTERVAL_VALUES</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Type</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="p">]</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Generator-362"><a href="#Generator-362"><span class="linenos"> 362</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">,</span> +</span><span id="Generator-363"><a href="#Generator-363"><span class="linenos"> 363</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="p">,</span> +</span><span id="Generator-364"><a href="#Generator-364"><span class="linenos"> 364</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Neg</span><span class="p">,</span> +</span><span id="Generator-365"><a href="#Generator-365"><span class="linenos"> 365</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Paren</span><span class="p">,</span> +</span><span id="Generator-366"><a href="#Generator-366"><span class="linenos"> 366</span></a> <span class="p">)</span> </span><span id="Generator-367"><a href="#Generator-367"><span class="linenos"> 367</span></a> -</span><span id="Generator-368"><a href="#Generator-368"><span class="linenos"> 368</span></a> <span class="n">KEY_VALUE_DEFINITONS</span> <span class="o">=</span> <span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Bracket</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="n">exp</span><span class="o">.</span><span class="n">PropertyEQ</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Slice</span><span class="p">)</span> -</span><span id="Generator-369"><a href="#Generator-369"><span class="linenos"> 369</span></a> -</span><span id="Generator-370"><a href="#Generator-370"><span class="linenos"> 370</span></a> <span class="n">SENTINEL_LINE_BREAK</span> <span class="o">=</span> <span class="s2">"__SQLGLOT__LB__"</span> -</span><span id="Generator-371"><a href="#Generator-371"><span class="linenos"> 371</span></a> -</span><span id="Generator-372"><a href="#Generator-372"><span class="linenos"> 372</span></a> <span class="vm">__slots__</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Generator-373"><a href="#Generator-373"><span class="linenos"> 373</span></a> <span class="s2">"pretty"</span><span class="p">,</span> -</span><span id="Generator-374"><a href="#Generator-374"><span class="linenos"> 374</span></a> <span class="s2">"identify"</span><span class="p">,</span> -</span><span id="Generator-375"><a href="#Generator-375"><span class="linenos"> 375</span></a> <span class="s2">"normalize"</span><span class="p">,</span> -</span><span id="Generator-376"><a href="#Generator-376"><span class="linenos"> 376</span></a> <span class="s2">"pad"</span><span class="p">,</span> -</span><span id="Generator-377"><a href="#Generator-377"><span class="linenos"> 377</span></a> <span class="s2">"_indent"</span><span class="p">,</span> -</span><span id="Generator-378"><a href="#Generator-378"><span class="linenos"> 378</span></a> <span class="s2">"normalize_functions"</span><span class="p">,</span> -</span><span id="Generator-379"><a href="#Generator-379"><span class="linenos"> 379</span></a> <span class="s2">"unsupported_level"</span><span class="p">,</span> -</span><span id="Generator-380"><a href="#Generator-380"><span class="linenos"> 380</span></a> <span class="s2">"max_unsupported"</span><span class="p">,</span> -</span><span id="Generator-381"><a href="#Generator-381"><span class="linenos"> 381</span></a> <span class="s2">"leading_comma"</span><span class="p">,</span> -</span><span id="Generator-382"><a href="#Generator-382"><span class="linenos"> 382</span></a> <span class="s2">"max_text_width"</span><span class="p">,</span> -</span><span id="Generator-383"><a href="#Generator-383"><span class="linenos"> 383</span></a> <span class="s2">"comments"</span><span class="p">,</span> -</span><span id="Generator-384"><a href="#Generator-384"><span class="linenos"> 384</span></a> <span class="s2">"dialect"</span><span class="p">,</span> -</span><span id="Generator-385"><a href="#Generator-385"><span class="linenos"> 385</span></a> <span class="s2">"unsupported_messages"</span><span class="p">,</span> -</span><span id="Generator-386"><a href="#Generator-386"><span class="linenos"> 386</span></a> <span class="s2">"_escaped_quote_end"</span><span class="p">,</span> -</span><span id="Generator-387"><a href="#Generator-387"><span class="linenos"> 387</span></a> <span class="s2">"_escaped_identifier_end"</span><span class="p">,</span> -</span><span id="Generator-388"><a href="#Generator-388"><span class="linenos"> 388</span></a> <span class="p">)</span> -</span><span id="Generator-389"><a href="#Generator-389"><span class="linenos"> 389</span></a> -</span><span id="Generator-390"><a href="#Generator-390"><span class="linenos"> 390</span></a> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span> -</span><span id="Generator-391"><a href="#Generator-391"><span class="linenos"> 391</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Generator-392"><a href="#Generator-392"><span class="linenos"> 392</span></a> <span class="n">pretty</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">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Generator-393"><a href="#Generator-393"><span class="linenos"> 393</span></a> <span class="n">identify</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="Generator-394"><a href="#Generator-394"><span class="linenos"> 394</span></a> <span class="n">normalize</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-395"><a href="#Generator-395"><span class="linenos"> 395</span></a> <span class="n">pad</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">2</span><span class="p">,</span> -</span><span id="Generator-396"><a href="#Generator-396"><span class="linenos"> 396</span></a> <span class="n">indent</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">2</span><span class="p">,</span> -</span><span id="Generator-397"><a href="#Generator-397"><span class="linenos"> 397</span></a> <span class="n">normalize_functions</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="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Generator-398"><a href="#Generator-398"><span class="linenos"> 398</span></a> <span class="n">unsupported_level</span><span class="p">:</span> <span class="n">ErrorLevel</span> <span class="o">=</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">WARN</span><span class="p">,</span> -</span><span id="Generator-399"><a href="#Generator-399"><span class="linenos"> 399</span></a> <span class="n">max_unsupported</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">3</span><span class="p">,</span> -</span><span id="Generator-400"><a href="#Generator-400"><span class="linenos"> 400</span></a> <span class="n">leading_comma</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-401"><a href="#Generator-401"><span class="linenos"> 401</span></a> <span class="n">max_text_width</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">80</span><span class="p">,</span> -</span><span id="Generator-402"><a href="#Generator-402"><span class="linenos"> 402</span></a> <span class="n">comments</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-403"><a href="#Generator-403"><span class="linenos"> 403</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Generator-404"><a href="#Generator-404"><span class="linenos"> 404</span></a> <span class="p">):</span> -</span><span id="Generator-405"><a href="#Generator-405"><span class="linenos"> 405</span></a> <span class="kn">import</span> <span class="nn">sqlglot</span> -</span><span id="Generator-406"><a href="#Generator-406"><span class="linenos"> 406</span></a> <span class="kn">from</span> <span class="nn">sqlglot.dialects</span> <span class="kn">import</span> <span class="n">Dialect</span> -</span><span id="Generator-407"><a href="#Generator-407"><span class="linenos"> 407</span></a> -</span><span id="Generator-408"><a href="#Generator-408"><span class="linenos"> 408</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span> <span class="o">=</span> <span class="n">pretty</span> <span class="k">if</span> <span class="n">pretty</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">sqlglot</span><span class="o">.</span><span class="n">pretty</span> -</span><span id="Generator-409"><a href="#Generator-409"><span class="linenos"> 409</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">identify</span> <span class="o">=</span> <span class="n">identify</span> -</span><span id="Generator-410"><a href="#Generator-410"><span class="linenos"> 410</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">normalize</span> <span class="o">=</span> <span class="n">normalize</span> -</span><span id="Generator-411"><a href="#Generator-411"><span class="linenos"> 411</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">pad</span> <span class="o">=</span> <span class="n">pad</span> -</span><span id="Generator-412"><a href="#Generator-412"><span class="linenos"> 412</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_indent</span> <span class="o">=</span> <span class="n">indent</span> -</span><span id="Generator-413"><a href="#Generator-413"><span class="linenos"> 413</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_level</span> <span class="o">=</span> <span class="n">unsupported_level</span> -</span><span id="Generator-414"><a href="#Generator-414"><span class="linenos"> 414</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">max_unsupported</span> <span class="o">=</span> <span class="n">max_unsupported</span> -</span><span id="Generator-415"><a href="#Generator-415"><span class="linenos"> 415</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">leading_comma</span> <span class="o">=</span> <span class="n">leading_comma</span> -</span><span id="Generator-416"><a href="#Generator-416"><span class="linenos"> 416</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">max_text_width</span> <span class="o">=</span> <span class="n">max_text_width</span> -</span><span id="Generator-417"><a href="#Generator-417"><span class="linenos"> 417</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">comments</span> <span class="o">=</span> <span class="n">comments</span> -</span><span id="Generator-418"><a href="#Generator-418"><span class="linenos"> 418</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span> <span class="o">=</span> <span class="n">Dialect</span><span class="o">.</span><span class="n">get_or_raise</span><span class="p">(</span><span class="n">dialect</span><span class="p">)</span> -</span><span id="Generator-419"><a href="#Generator-419"><span class="linenos"> 419</span></a> -</span><span id="Generator-420"><a href="#Generator-420"><span class="linenos"> 420</span></a> <span class="c1"># This is both a Dialect property and a Generator argument, so we prioritize the latter</span> -</span><span id="Generator-421"><a href="#Generator-421"><span class="linenos"> 421</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">normalize_functions</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Generator-422"><a href="#Generator-422"><span class="linenos"> 422</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">NORMALIZE_FUNCTIONS</span> <span class="k">if</span> <span class="n">normalize_functions</span> <span class="ow">is</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">normalize_functions</span> -</span><span id="Generator-423"><a href="#Generator-423"><span class="linenos"> 423</span></a> <span class="p">)</span> -</span><span id="Generator-424"><a href="#Generator-424"><span class="linenos"> 424</span></a> -</span><span id="Generator-425"><a href="#Generator-425"><span class="linenos"> 425</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_messages</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="Generator-426"><a href="#Generator-426"><span class="linenos"> 426</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_escaped_quote_end</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Generator-427"><a href="#Generator-427"><span class="linenos"> 427</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">tokenizer_class</span><span class="o">.</span><span class="n">STRING_ESCAPES</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">QUOTE_END</span> -</span><span id="Generator-428"><a href="#Generator-428"><span class="linenos"> 428</span></a> <span class="p">)</span> -</span><span id="Generator-429"><a href="#Generator-429"><span class="linenos"> 429</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_escaped_identifier_end</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Generator-430"><a href="#Generator-430"><span class="linenos"> 430</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">tokenizer_class</span><span class="o">.</span><span class="n">IDENTIFIER_ESCAPES</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">IDENTIFIER_END</span> +</span><span id="Generator-368"><a href="#Generator-368"><span class="linenos"> 368</span></a> <span class="c1"># Expressions that need to have all CTEs under them bubbled up to them</span> +</span><span id="Generator-369"><a href="#Generator-369"><span class="linenos"> 369</span></a> <span class="n">EXPRESSIONS_WITHOUT_NESTED_CTES</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Set</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Type</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="nb">set</span><span class="p">()</span> +</span><span id="Generator-370"><a href="#Generator-370"><span class="linenos"> 370</span></a> +</span><span id="Generator-371"><a href="#Generator-371"><span class="linenos"> 371</span></a> <span class="n">KEY_VALUE_DEFINITONS</span> <span class="o">=</span> <span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Bracket</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="n">exp</span><span class="o">.</span><span class="n">PropertyEQ</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Slice</span><span class="p">)</span> +</span><span id="Generator-372"><a href="#Generator-372"><span class="linenos"> 372</span></a> +</span><span id="Generator-373"><a href="#Generator-373"><span class="linenos"> 373</span></a> <span class="n">SENTINEL_LINE_BREAK</span> <span class="o">=</span> <span class="s2">"__SQLGLOT__LB__"</span> +</span><span id="Generator-374"><a href="#Generator-374"><span class="linenos"> 374</span></a> +</span><span id="Generator-375"><a href="#Generator-375"><span class="linenos"> 375</span></a> <span class="vm">__slots__</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Generator-376"><a href="#Generator-376"><span class="linenos"> 376</span></a> <span class="s2">"pretty"</span><span class="p">,</span> +</span><span id="Generator-377"><a href="#Generator-377"><span class="linenos"> 377</span></a> <span class="s2">"identify"</span><span class="p">,</span> +</span><span id="Generator-378"><a href="#Generator-378"><span class="linenos"> 378</span></a> <span class="s2">"normalize"</span><span class="p">,</span> +</span><span id="Generator-379"><a href="#Generator-379"><span class="linenos"> 379</span></a> <span class="s2">"pad"</span><span class="p">,</span> +</span><span id="Generator-380"><a href="#Generator-380"><span class="linenos"> 380</span></a> <span class="s2">"_indent"</span><span class="p">,</span> +</span><span id="Generator-381"><a href="#Generator-381"><span class="linenos"> 381</span></a> <span class="s2">"normalize_functions"</span><span class="p">,</span> +</span><span id="Generator-382"><a href="#Generator-382"><span class="linenos"> 382</span></a> <span class="s2">"unsupported_level"</span><span class="p">,</span> +</span><span id="Generator-383"><a href="#Generator-383"><span class="linenos"> 383</span></a> <span class="s2">"max_unsupported"</span><span class="p">,</span> +</span><span id="Generator-384"><a href="#Generator-384"><span class="linenos"> 384</span></a> <span class="s2">"leading_comma"</span><span class="p">,</span> +</span><span id="Generator-385"><a href="#Generator-385"><span class="linenos"> 385</span></a> <span class="s2">"max_text_width"</span><span class="p">,</span> +</span><span id="Generator-386"><a href="#Generator-386"><span class="linenos"> 386</span></a> <span class="s2">"comments"</span><span class="p">,</span> +</span><span id="Generator-387"><a href="#Generator-387"><span class="linenos"> 387</span></a> <span class="s2">"dialect"</span><span class="p">,</span> +</span><span id="Generator-388"><a href="#Generator-388"><span class="linenos"> 388</span></a> <span class="s2">"unsupported_messages"</span><span class="p">,</span> +</span><span id="Generator-389"><a href="#Generator-389"><span class="linenos"> 389</span></a> <span class="s2">"_escaped_quote_end"</span><span class="p">,</span> +</span><span id="Generator-390"><a href="#Generator-390"><span class="linenos"> 390</span></a> <span class="s2">"_escaped_identifier_end"</span><span class="p">,</span> +</span><span id="Generator-391"><a href="#Generator-391"><span class="linenos"> 391</span></a> <span class="p">)</span> +</span><span id="Generator-392"><a href="#Generator-392"><span class="linenos"> 392</span></a> +</span><span id="Generator-393"><a href="#Generator-393"><span class="linenos"> 393</span></a> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span> +</span><span id="Generator-394"><a href="#Generator-394"><span class="linenos"> 394</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Generator-395"><a href="#Generator-395"><span class="linenos"> 395</span></a> <span class="n">pretty</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">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Generator-396"><a href="#Generator-396"><span class="linenos"> 396</span></a> <span class="n">identify</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="Generator-397"><a href="#Generator-397"><span class="linenos"> 397</span></a> <span class="n">normalize</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-398"><a href="#Generator-398"><span class="linenos"> 398</span></a> <span class="n">pad</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">2</span><span class="p">,</span> +</span><span id="Generator-399"><a href="#Generator-399"><span class="linenos"> 399</span></a> <span class="n">indent</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">2</span><span class="p">,</span> +</span><span id="Generator-400"><a href="#Generator-400"><span class="linenos"> 400</span></a> <span class="n">normalize_functions</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="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Generator-401"><a href="#Generator-401"><span class="linenos"> 401</span></a> <span class="n">unsupported_level</span><span class="p">:</span> <span class="n">ErrorLevel</span> <span class="o">=</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">WARN</span><span class="p">,</span> +</span><span id="Generator-402"><a href="#Generator-402"><span class="linenos"> 402</span></a> <span class="n">max_unsupported</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">3</span><span class="p">,</span> +</span><span id="Generator-403"><a href="#Generator-403"><span class="linenos"> 403</span></a> <span class="n">leading_comma</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-404"><a href="#Generator-404"><span class="linenos"> 404</span></a> <span class="n">max_text_width</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">80</span><span class="p">,</span> +</span><span id="Generator-405"><a href="#Generator-405"><span class="linenos"> 405</span></a> <span class="n">comments</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-406"><a href="#Generator-406"><span class="linenos"> 406</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Generator-407"><a href="#Generator-407"><span class="linenos"> 407</span></a> <span class="p">):</span> +</span><span id="Generator-408"><a href="#Generator-408"><span class="linenos"> 408</span></a> <span class="kn">import</span> <span class="nn">sqlglot</span> +</span><span id="Generator-409"><a href="#Generator-409"><span class="linenos"> 409</span></a> <span class="kn">from</span> <span class="nn">sqlglot.dialects</span> <span class="kn">import</span> <span class="n">Dialect</span> +</span><span id="Generator-410"><a href="#Generator-410"><span class="linenos"> 410</span></a> +</span><span id="Generator-411"><a href="#Generator-411"><span class="linenos"> 411</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span> <span class="o">=</span> <span class="n">pretty</span> <span class="k">if</span> <span class="n">pretty</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">sqlglot</span><span class="o">.</span><span class="n">pretty</span> +</span><span id="Generator-412"><a href="#Generator-412"><span class="linenos"> 412</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">identify</span> <span class="o">=</span> <span class="n">identify</span> +</span><span id="Generator-413"><a href="#Generator-413"><span class="linenos"> 413</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">normalize</span> <span class="o">=</span> <span class="n">normalize</span> +</span><span id="Generator-414"><a href="#Generator-414"><span class="linenos"> 414</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">pad</span> <span class="o">=</span> <span class="n">pad</span> +</span><span id="Generator-415"><a href="#Generator-415"><span class="linenos"> 415</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_indent</span> <span class="o">=</span> <span class="n">indent</span> +</span><span id="Generator-416"><a href="#Generator-416"><span class="linenos"> 416</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_level</span> <span class="o">=</span> <span class="n">unsupported_level</span> +</span><span id="Generator-417"><a href="#Generator-417"><span class="linenos"> 417</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">max_unsupported</span> <span class="o">=</span> <span class="n">max_unsupported</span> +</span><span id="Generator-418"><a href="#Generator-418"><span class="linenos"> 418</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">leading_comma</span> <span class="o">=</span> <span class="n">leading_comma</span> +</span><span id="Generator-419"><a href="#Generator-419"><span class="linenos"> 419</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">max_text_width</span> <span class="o">=</span> <span class="n">max_text_width</span> +</span><span id="Generator-420"><a href="#Generator-420"><span class="linenos"> 420</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">comments</span> <span class="o">=</span> <span class="n">comments</span> +</span><span id="Generator-421"><a href="#Generator-421"><span class="linenos"> 421</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span> <span class="o">=</span> <span class="n">Dialect</span><span class="o">.</span><span class="n">get_or_raise</span><span class="p">(</span><span class="n">dialect</span><span class="p">)</span> +</span><span id="Generator-422"><a href="#Generator-422"><span class="linenos"> 422</span></a> +</span><span id="Generator-423"><a href="#Generator-423"><span class="linenos"> 423</span></a> <span class="c1"># This is both a Dialect property and a Generator argument, so we prioritize the latter</span> +</span><span id="Generator-424"><a href="#Generator-424"><span class="linenos"> 424</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">normalize_functions</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Generator-425"><a href="#Generator-425"><span class="linenos"> 425</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">NORMALIZE_FUNCTIONS</span> <span class="k">if</span> <span class="n">normalize_functions</span> <span class="ow">is</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">normalize_functions</span> +</span><span id="Generator-426"><a href="#Generator-426"><span class="linenos"> 426</span></a> <span class="p">)</span> +</span><span id="Generator-427"><a href="#Generator-427"><span class="linenos"> 427</span></a> +</span><span id="Generator-428"><a href="#Generator-428"><span class="linenos"> 428</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_messages</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="Generator-429"><a href="#Generator-429"><span class="linenos"> 429</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_escaped_quote_end</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Generator-430"><a href="#Generator-430"><span class="linenos"> 430</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">tokenizer_class</span><span class="o">.</span><span class="n">STRING_ESCAPES</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">QUOTE_END</span> </span><span id="Generator-431"><a href="#Generator-431"><span class="linenos"> 431</span></a> <span class="p">)</span> -</span><span id="Generator-432"><a href="#Generator-432"><span class="linenos"> 432</span></a> -</span><span id="Generator-433"><a href="#Generator-433"><span class="linenos"> 433</span></a> <span class="k">def</span> <span class="nf">generate</span><span class="p">(</span><span class="bp">self</span><span 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">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-434"><a href="#Generator-434"><span class="linenos"> 434</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Generator-435"><a href="#Generator-435"><span class="linenos"> 435</span></a><span class="sd"> Generates the SQL string corresponding to the given syntax tree.</span> -</span><span id="Generator-436"><a href="#Generator-436"><span class="linenos"> 436</span></a> -</span><span id="Generator-437"><a href="#Generator-437"><span class="linenos"> 437</span></a><span class="sd"> Args:</span> -</span><span id="Generator-438"><a href="#Generator-438"><span class="linenos"> 438</span></a><span class="sd"> expression: The syntax tree.</span> -</span><span id="Generator-439"><a href="#Generator-439"><span class="linenos"> 439</span></a><span class="sd"> copy: Whether or not to copy the expression. The generator performs mutations so</span> -</span><span id="Generator-440"><a href="#Generator-440"><span class="linenos"> 440</span></a><span class="sd"> it is safer to copy.</span> -</span><span id="Generator-441"><a href="#Generator-441"><span class="linenos"> 441</span></a> -</span><span id="Generator-442"><a href="#Generator-442"><span class="linenos"> 442</span></a><span class="sd"> Returns:</span> -</span><span id="Generator-443"><a href="#Generator-443"><span class="linenos"> 443</span></a><span class="sd"> The SQL string corresponding to `expression`.</span> -</span><span id="Generator-444"><a href="#Generator-444"><span class="linenos"> 444</span></a><span class="sd"> """</span> -</span><span id="Generator-445"><a href="#Generator-445"><span class="linenos"> 445</span></a> <span class="k">if</span> <span class="n">copy</span><span class="p">:</span> -</span><span id="Generator-446"><a href="#Generator-446"><span class="linenos"> 446</span></a> <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-447"><a href="#Generator-447"><span class="linenos"> 447</span></a> -</span><span id="Generator-448"><a href="#Generator-448"><span class="linenos"> 448</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">preprocess</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Generator-449"><a href="#Generator-449"><span class="linenos"> 449</span></a> -</span><span id="Generator-450"><a href="#Generator-450"><span class="linenos"> 450</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_messages</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="Generator-451"><a href="#Generator-451"><span class="linenos"> 451</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">expression</span><span class="p">)</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> +</span><span id="Generator-432"><a href="#Generator-432"><span class="linenos"> 432</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_escaped_identifier_end</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Generator-433"><a href="#Generator-433"><span class="linenos"> 433</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">tokenizer_class</span><span class="o">.</span><span class="n">IDENTIFIER_ESCAPES</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">IDENTIFIER_END</span> +</span><span id="Generator-434"><a href="#Generator-434"><span class="linenos"> 434</span></a> <span class="p">)</span> +</span><span id="Generator-435"><a href="#Generator-435"><span class="linenos"> 435</span></a> +</span><span id="Generator-436"><a href="#Generator-436"><span class="linenos"> 436</span></a> <span class="k">def</span> <span class="nf">generate</span><span class="p">(</span><span class="bp">self</span><span 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">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-437"><a href="#Generator-437"><span class="linenos"> 437</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Generator-438"><a href="#Generator-438"><span class="linenos"> 438</span></a><span class="sd"> Generates the SQL string corresponding to the given syntax tree.</span> +</span><span id="Generator-439"><a href="#Generator-439"><span class="linenos"> 439</span></a> +</span><span id="Generator-440"><a href="#Generator-440"><span class="linenos"> 440</span></a><span class="sd"> Args:</span> +</span><span id="Generator-441"><a href="#Generator-441"><span class="linenos"> 441</span></a><span class="sd"> expression: The syntax tree.</span> +</span><span id="Generator-442"><a href="#Generator-442"><span class="linenos"> 442</span></a><span class="sd"> copy: Whether or not to copy the expression. The generator performs mutations so</span> +</span><span id="Generator-443"><a href="#Generator-443"><span class="linenos"> 443</span></a><span class="sd"> it is safer to copy.</span> +</span><span id="Generator-444"><a href="#Generator-444"><span class="linenos"> 444</span></a> +</span><span id="Generator-445"><a href="#Generator-445"><span class="linenos"> 445</span></a><span class="sd"> Returns:</span> +</span><span id="Generator-446"><a href="#Generator-446"><span class="linenos"> 446</span></a><span class="sd"> The SQL string corresponding to `expression`.</span> +</span><span id="Generator-447"><a href="#Generator-447"><span class="linenos"> 447</span></a><span class="sd"> """</span> +</span><span id="Generator-448"><a href="#Generator-448"><span class="linenos"> 448</span></a> <span class="k">if</span> <span class="n">copy</span><span class="p">:</span> +</span><span id="Generator-449"><a href="#Generator-449"><span class="linenos"> 449</span></a> <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-450"><a href="#Generator-450"><span class="linenos"> 450</span></a> +</span><span id="Generator-451"><a href="#Generator-451"><span class="linenos"> 451</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">preprocess</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> </span><span id="Generator-452"><a href="#Generator-452"><span class="linenos"> 452</span></a> -</span><span id="Generator-453"><a href="#Generator-453"><span class="linenos"> 453</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-454"><a href="#Generator-454"><span class="linenos"> 454</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="n">sql</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">SENTINEL_LINE_BREAK</span><span class="p">,</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">)</span> +</span><span id="Generator-453"><a href="#Generator-453"><span class="linenos"> 453</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_messages</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="Generator-454"><a href="#Generator-454"><span class="linenos"> 454</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">expression</span><span class="p">)</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> </span><span id="Generator-455"><a href="#Generator-455"><span class="linenos"> 455</span></a> -</span><span id="Generator-456"><a href="#Generator-456"><span class="linenos"> 456</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_level</span> <span class="o">==</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">IGNORE</span><span class="p">:</span> -</span><span id="Generator-457"><a href="#Generator-457"><span class="linenos"> 457</span></a> <span class="k">return</span> <span class="n">sql</span> +</span><span id="Generator-456"><a href="#Generator-456"><span class="linenos"> 456</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-457"><a href="#Generator-457"><span class="linenos"> 457</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="n">sql</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">SENTINEL_LINE_BREAK</span><span class="p">,</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">)</span> </span><span id="Generator-458"><a href="#Generator-458"><span class="linenos"> 458</span></a> -</span><span id="Generator-459"><a href="#Generator-459"><span class="linenos"> 459</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_level</span> <span class="o">==</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">WARN</span><span class="p">:</span> -</span><span id="Generator-460"><a href="#Generator-460"><span class="linenos"> 460</span></a> <span class="k">for</span> <span class="n">msg</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_messages</span><span class="p">:</span> -</span><span id="Generator-461"><a href="#Generator-461"><span class="linenos"> 461</span></a> <span class="n">logger</span><span class="o">.</span><span class="n">warning</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span> -</span><span id="Generator-462"><a href="#Generator-462"><span class="linenos"> 462</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_level</span> <span class="o">==</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">RAISE</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_messages</span><span class="p">:</span> -</span><span id="Generator-463"><a href="#Generator-463"><span class="linenos"> 463</span></a> <span class="k">raise</span> <span class="n">UnsupportedError</span><span class="p">(</span><span class="n">concat_messages</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">unsupported_messages</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">max_unsupported</span><span class="p">))</span> -</span><span id="Generator-464"><a href="#Generator-464"><span class="linenos"> 464</span></a> -</span><span id="Generator-465"><a href="#Generator-465"><span class="linenos"> 465</span></a> <span class="k">return</span> <span class="n">sql</span> -</span><span id="Generator-466"><a href="#Generator-466"><span class="linenos"> 466</span></a> -</span><span id="Generator-467"><a href="#Generator-467"><span class="linenos"> 467</span></a> <span class="k">def</span> <span class="nf">preprocess</span><span class="p">(</span><span class="bp">self</span><span 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">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">:</span> -</span><span id="Generator-468"><a href="#Generator-468"><span class="linenos"> 468</span></a><span class="w"> </span><span class="sd">"""Apply generic preprocessing transformations to a given expression."""</span> -</span><span id="Generator-469"><a href="#Generator-469"><span class="linenos"> 469</span></a> <span class="k">if</span> <span class="p">(</span> -</span><span id="Generator-470"><a href="#Generator-470"><span class="linenos"> 470</span></a> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">parent</span> -</span><span id="Generator-471"><a href="#Generator-471"><span class="linenos"> 471</span></a> <span class="ow">and</span> <span class="nb">type</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">EXPRESSIONS_WITHOUT_NESTED_CTES</span> -</span><span id="Generator-472"><a href="#Generator-472"><span class="linenos"> 472</span></a> <span class="ow">and</span> <span class="nb">any</span><span class="p">(</span><span class="n">node</span><span class="o">.</span><span class="n">parent</span> <span class="ow">is</span> <span class="ow">not</span> <span class="n">expression</span> <span class="k">for</span> <span class="n">node</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">find_all</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">With</span><span class="p">))</span> -</span><span id="Generator-473"><a href="#Generator-473"><span class="linenos"> 473</span></a> <span class="p">):</span> -</span><span id="Generator-474"><a href="#Generator-474"><span class="linenos"> 474</span></a> <span class="kn">from</span> <span class="nn">sqlglot.transforms</span> <span class="kn">import</span> <span class="n">move_ctes_to_top_level</span> -</span><span id="Generator-475"><a href="#Generator-475"><span class="linenos"> 475</span></a> -</span><span id="Generator-476"><a href="#Generator-476"><span class="linenos"> 476</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">move_ctes_to_top_level</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Generator-477"><a href="#Generator-477"><span class="linenos"> 477</span></a> -</span><span id="Generator-478"><a href="#Generator-478"><span class="linenos"> 478</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">ENSURE_BOOLS</span><span class="p">:</span> -</span><span id="Generator-479"><a href="#Generator-479"><span class="linenos"> 479</span></a> <span class="kn">from</span> <span class="nn">sqlglot.transforms</span> <span class="kn">import</span> <span class="n">ensure_bools</span> +</span><span id="Generator-459"><a href="#Generator-459"><span class="linenos"> 459</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_level</span> <span class="o">==</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">IGNORE</span><span class="p">:</span> +</span><span id="Generator-460"><a href="#Generator-460"><span class="linenos"> 460</span></a> <span class="k">return</span> <span class="n">sql</span> +</span><span id="Generator-461"><a href="#Generator-461"><span class="linenos"> 461</span></a> +</span><span id="Generator-462"><a href="#Generator-462"><span class="linenos"> 462</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_level</span> <span class="o">==</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">WARN</span><span class="p">:</span> +</span><span id="Generator-463"><a href="#Generator-463"><span class="linenos"> 463</span></a> <span class="k">for</span> <span class="n">msg</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_messages</span><span class="p">:</span> +</span><span id="Generator-464"><a href="#Generator-464"><span class="linenos"> 464</span></a> <span class="n">logger</span><span class="o">.</span><span class="n">warning</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span> +</span><span id="Generator-465"><a href="#Generator-465"><span class="linenos"> 465</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_level</span> <span class="o">==</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">RAISE</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_messages</span><span class="p">:</span> +</span><span id="Generator-466"><a href="#Generator-466"><span class="linenos"> 466</span></a> <span class="k">raise</span> <span class="n">UnsupportedError</span><span class="p">(</span><span class="n">concat_messages</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">unsupported_messages</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">max_unsupported</span><span class="p">))</span> +</span><span id="Generator-467"><a href="#Generator-467"><span class="linenos"> 467</span></a> +</span><span id="Generator-468"><a href="#Generator-468"><span class="linenos"> 468</span></a> <span class="k">return</span> <span class="n">sql</span> +</span><span id="Generator-469"><a href="#Generator-469"><span class="linenos"> 469</span></a> +</span><span id="Generator-470"><a href="#Generator-470"><span class="linenos"> 470</span></a> <span class="k">def</span> <span class="nf">preprocess</span><span class="p">(</span><span class="bp">self</span><span 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">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">:</span> +</span><span id="Generator-471"><a href="#Generator-471"><span class="linenos"> 471</span></a><span class="w"> </span><span class="sd">"""Apply generic preprocessing transformations to a given expression."""</span> +</span><span id="Generator-472"><a href="#Generator-472"><span class="linenos"> 472</span></a> <span class="k">if</span> <span class="p">(</span> +</span><span id="Generator-473"><a href="#Generator-473"><span class="linenos"> 473</span></a> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">parent</span> +</span><span id="Generator-474"><a href="#Generator-474"><span class="linenos"> 474</span></a> <span class="ow">and</span> <span class="nb">type</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">EXPRESSIONS_WITHOUT_NESTED_CTES</span> +</span><span id="Generator-475"><a href="#Generator-475"><span class="linenos"> 475</span></a> <span class="ow">and</span> <span class="nb">any</span><span class="p">(</span><span class="n">node</span><span class="o">.</span><span class="n">parent</span> <span class="ow">is</span> <span class="ow">not</span> <span class="n">expression</span> <span class="k">for</span> <span class="n">node</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">find_all</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">With</span><span class="p">))</span> +</span><span id="Generator-476"><a href="#Generator-476"><span class="linenos"> 476</span></a> <span class="p">):</span> +</span><span id="Generator-477"><a href="#Generator-477"><span class="linenos"> 477</span></a> <span class="kn">from</span> <span class="nn">sqlglot.transforms</span> <span class="kn">import</span> <span class="n">move_ctes_to_top_level</span> +</span><span id="Generator-478"><a href="#Generator-478"><span class="linenos"> 478</span></a> +</span><span id="Generator-479"><a href="#Generator-479"><span class="linenos"> 479</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">move_ctes_to_top_level</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> </span><span id="Generator-480"><a href="#Generator-480"><span class="linenos"> 480</span></a> -</span><span id="Generator-481"><a href="#Generator-481"><span class="linenos"> 481</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">ensure_bools</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Generator-482"><a href="#Generator-482"><span class="linenos"> 482</span></a> -</span><span id="Generator-483"><a href="#Generator-483"><span class="linenos"> 483</span></a> <span class="k">return</span> <span class="n">expression</span> -</span><span id="Generator-484"><a href="#Generator-484"><span class="linenos"> 484</span></a> -</span><span id="Generator-485"><a href="#Generator-485"><span class="linenos"> 485</span></a> <span class="k">def</span> <span class="nf">unsupported</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">message</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-486"><a href="#Generator-486"><span class="linenos"> 486</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_level</span> <span class="o">==</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">IMMEDIATE</span><span class="p">:</span> -</span><span id="Generator-487"><a href="#Generator-487"><span class="linenos"> 487</span></a> <span class="k">raise</span> <span class="n">UnsupportedError</span><span class="p">(</span><span class="n">message</span><span class="p">)</span> -</span><span id="Generator-488"><a href="#Generator-488"><span class="linenos"> 488</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_messages</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">message</span><span class="p">)</span> -</span><span id="Generator-489"><a href="#Generator-489"><span class="linenos"> 489</span></a> -</span><span id="Generator-490"><a href="#Generator-490"><span class="linenos"> 490</span></a> <span class="k">def</span> <span class="nf">sep</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <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 class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-491"><a href="#Generator-491"><span class="linenos"> 491</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="o">.</span><span class="n">strip</span><span class="p">()</span><span class="si">}</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">pretty</span> <span class="k">else</span> <span class="n">sep</span> +</span><span id="Generator-481"><a href="#Generator-481"><span class="linenos"> 481</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">ENSURE_BOOLS</span><span class="p">:</span> +</span><span id="Generator-482"><a href="#Generator-482"><span class="linenos"> 482</span></a> <span class="kn">from</span> <span class="nn">sqlglot.transforms</span> <span class="kn">import</span> <span class="n">ensure_bools</span> +</span><span id="Generator-483"><a href="#Generator-483"><span class="linenos"> 483</span></a> +</span><span id="Generator-484"><a href="#Generator-484"><span class="linenos"> 484</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">ensure_bools</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Generator-485"><a href="#Generator-485"><span class="linenos"> 485</span></a> +</span><span id="Generator-486"><a href="#Generator-486"><span class="linenos"> 486</span></a> <span class="k">return</span> <span class="n">expression</span> +</span><span id="Generator-487"><a href="#Generator-487"><span class="linenos"> 487</span></a> +</span><span id="Generator-488"><a href="#Generator-488"><span class="linenos"> 488</span></a> <span class="k">def</span> <span class="nf">unsupported</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">message</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-489"><a href="#Generator-489"><span class="linenos"> 489</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_level</span> <span class="o">==</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">IMMEDIATE</span><span class="p">:</span> +</span><span id="Generator-490"><a href="#Generator-490"><span class="linenos"> 490</span></a> <span class="k">raise</span> <span class="n">UnsupportedError</span><span class="p">(</span><span class="n">message</span><span class="p">)</span> +</span><span id="Generator-491"><a href="#Generator-491"><span class="linenos"> 491</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_messages</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">message</span><span class="p">)</span> </span><span id="Generator-492"><a href="#Generator-492"><span class="linenos"> 492</span></a> -</span><span id="Generator-493"><a href="#Generator-493"><span class="linenos"> 493</span></a> <span class="k">def</span> <span class="nf">seg</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sql</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <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 class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-494"><a href="#Generator-494"><span class="linenos"> 494</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">sep</span><span class="p">(</span><span class="n">sep</span><span class="p">)</span><span class="si">}{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-493"><a href="#Generator-493"><span class="linenos"> 493</span></a> <span class="k">def</span> <span class="nf">sep</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <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 class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-494"><a href="#Generator-494"><span class="linenos"> 494</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="o">.</span><span class="n">strip</span><span class="p">()</span><span class="si">}</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">pretty</span> <span class="k">else</span> <span class="n">sep</span> </span><span id="Generator-495"><a href="#Generator-495"><span class="linenos"> 495</span></a> -</span><span id="Generator-496"><a href="#Generator-496"><span class="linenos"> 496</span></a> <span class="k">def</span> <span class="nf">pad_comment</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">comment</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-497"><a href="#Generator-497"><span class="linenos"> 497</span></a> <span class="n">comment</span> <span class="o">=</span> <span class="s2">" "</span> <span class="o">+</span> <span class="n">comment</span> <span class="k">if</span> <span class="n">comment</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> <span class="k">else</span> <span class="n">comment</span> -</span><span id="Generator-498"><a href="#Generator-498"><span class="linenos"> 498</span></a> <span class="n">comment</span> <span class="o">=</span> <span class="n">comment</span> <span class="o">+</span> <span class="s2">" "</span> <span class="k">if</span> <span class="n">comment</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> <span class="k">else</span> <span class="n">comment</span> -</span><span id="Generator-499"><a href="#Generator-499"><span class="linenos"> 499</span></a> <span class="k">return</span> <span class="n">comment</span> -</span><span id="Generator-500"><a href="#Generator-500"><span class="linenos"> 500</span></a> -</span><span id="Generator-501"><a href="#Generator-501"><span class="linenos"> 501</span></a> <span class="k">def</span> <span class="nf">maybe_comment</span><span class="p">(</span> -</span><span id="Generator-502"><a href="#Generator-502"><span class="linenos"> 502</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Generator-503"><a href="#Generator-503"><span class="linenos"> 503</span></a> <span class="n">sql</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> -</span><span id="Generator-504"><a href="#Generator-504"><span class="linenos"> 504</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-505"><a href="#Generator-505"><span class="linenos"> 505</span></a> <span class="n">comments</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">List</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-506"><a href="#Generator-506"><span class="linenos"> 506</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-507"><a href="#Generator-507"><span class="linenos"> 507</span></a> <span class="n">comments</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Generator-508"><a href="#Generator-508"><span class="linenos"> 508</span></a> <span class="p">((</span><span class="n">expression</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">comments</span><span class="p">)</span> <span class="k">if</span> <span class="n">comments</span> <span class="ow">is</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">comments</span><span class="p">)</span> <span class="c1"># type: ignore</span> -</span><span id="Generator-509"><a href="#Generator-509"><span class="linenos"> 509</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">comments</span> -</span><span id="Generator-510"><a href="#Generator-510"><span class="linenos"> 510</span></a> <span class="k">else</span> <span class="kc">None</span> -</span><span id="Generator-511"><a href="#Generator-511"><span class="linenos"> 511</span></a> <span class="p">)</span> -</span><span id="Generator-512"><a href="#Generator-512"><span class="linenos"> 512</span></a> -</span><span id="Generator-513"><a href="#Generator-513"><span class="linenos"> 513</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">comments</span> <span class="ow">or</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">EXCLUDE_COMMENTS</span><span class="p">):</span> -</span><span id="Generator-514"><a href="#Generator-514"><span class="linenos"> 514</span></a> <span class="k">return</span> <span class="n">sql</span> +</span><span id="Generator-496"><a href="#Generator-496"><span class="linenos"> 496</span></a> <span class="k">def</span> <span class="nf">seg</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sql</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <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 class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-497"><a href="#Generator-497"><span class="linenos"> 497</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">sep</span><span class="p">(</span><span class="n">sep</span><span class="p">)</span><span class="si">}{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-498"><a href="#Generator-498"><span class="linenos"> 498</span></a> +</span><span id="Generator-499"><a href="#Generator-499"><span class="linenos"> 499</span></a> <span class="k">def</span> <span class="nf">pad_comment</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">comment</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-500"><a href="#Generator-500"><span class="linenos"> 500</span></a> <span class="n">comment</span> <span class="o">=</span> <span class="s2">" "</span> <span class="o">+</span> <span class="n">comment</span> <span class="k">if</span> <span class="n">comment</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> <span class="k">else</span> <span class="n">comment</span> +</span><span id="Generator-501"><a href="#Generator-501"><span class="linenos"> 501</span></a> <span class="n">comment</span> <span class="o">=</span> <span class="n">comment</span> <span class="o">+</span> <span class="s2">" "</span> <span class="k">if</span> <span class="n">comment</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> <span class="k">else</span> <span class="n">comment</span> +</span><span id="Generator-502"><a href="#Generator-502"><span class="linenos"> 502</span></a> <span class="k">return</span> <span class="n">comment</span> +</span><span id="Generator-503"><a href="#Generator-503"><span class="linenos"> 503</span></a> +</span><span id="Generator-504"><a href="#Generator-504"><span class="linenos"> 504</span></a> <span class="k">def</span> <span class="nf">maybe_comment</span><span class="p">(</span> +</span><span id="Generator-505"><a href="#Generator-505"><span class="linenos"> 505</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Generator-506"><a href="#Generator-506"><span class="linenos"> 506</span></a> <span class="n">sql</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> +</span><span id="Generator-507"><a href="#Generator-507"><span class="linenos"> 507</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-508"><a href="#Generator-508"><span class="linenos"> 508</span></a> <span class="n">comments</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">List</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-509"><a href="#Generator-509"><span class="linenos"> 509</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-510"><a href="#Generator-510"><span class="linenos"> 510</span></a> <span class="n">comments</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Generator-511"><a href="#Generator-511"><span class="linenos"> 511</span></a> <span class="p">((</span><span class="n">expression</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">comments</span><span class="p">)</span> <span class="k">if</span> <span class="n">comments</span> <span class="ow">is</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">comments</span><span class="p">)</span> <span class="c1"># type: ignore</span> +</span><span id="Generator-512"><a href="#Generator-512"><span class="linenos"> 512</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">comments</span> +</span><span id="Generator-513"><a href="#Generator-513"><span class="linenos"> 513</span></a> <span class="k">else</span> <span class="kc">None</span> +</span><span id="Generator-514"><a href="#Generator-514"><span class="linenos"> 514</span></a> <span class="p">)</span> </span><span id="Generator-515"><a href="#Generator-515"><span class="linenos"> 515</span></a> -</span><span id="Generator-516"><a href="#Generator-516"><span class="linenos"> 516</span></a> <span class="n">comments_sql</span> <span class="o">=</span> <span class="s2">" "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> -</span><span id="Generator-517"><a href="#Generator-517"><span class="linenos"> 517</span></a> <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">pad_comment</span><span class="p">(</span><span class="n">comment</span><span class="p">)</span><span class="si">}</span><span class="s2">*/"</span> <span class="k">for</span> <span class="n">comment</span> <span class="ow">in</span> <span class="n">comments</span> <span class="k">if</span> <span class="n">comment</span> -</span><span id="Generator-518"><a href="#Generator-518"><span class="linenos"> 518</span></a> <span class="p">)</span> -</span><span id="Generator-519"><a href="#Generator-519"><span class="linenos"> 519</span></a> -</span><span id="Generator-520"><a href="#Generator-520"><span class="linenos"> 520</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">comments_sql</span><span class="p">:</span> -</span><span id="Generator-521"><a href="#Generator-521"><span class="linenos"> 521</span></a> <span class="k">return</span> <span class="n">sql</span> +</span><span id="Generator-516"><a href="#Generator-516"><span class="linenos"> 516</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">comments</span> <span class="ow">or</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">EXCLUDE_COMMENTS</span><span class="p">):</span> +</span><span id="Generator-517"><a href="#Generator-517"><span class="linenos"> 517</span></a> <span class="k">return</span> <span class="n">sql</span> +</span><span id="Generator-518"><a href="#Generator-518"><span class="linenos"> 518</span></a> +</span><span id="Generator-519"><a href="#Generator-519"><span class="linenos"> 519</span></a> <span class="n">comments_sql</span> <span class="o">=</span> <span class="s2">" "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> +</span><span id="Generator-520"><a href="#Generator-520"><span class="linenos"> 520</span></a> <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">pad_comment</span><span class="p">(</span><span class="n">comment</span><span class="p">)</span><span class="si">}</span><span class="s2">*/"</span> <span class="k">for</span> <span class="n">comment</span> <span class="ow">in</span> <span class="n">comments</span> <span class="k">if</span> <span class="n">comment</span> +</span><span id="Generator-521"><a href="#Generator-521"><span class="linenos"> 521</span></a> <span class="p">)</span> </span><span id="Generator-522"><a href="#Generator-522"><span class="linenos"> 522</span></a> -</span><span id="Generator-523"><a href="#Generator-523"><span class="linenos"> 523</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">WITH_SEPARATED_COMMENTS</span><span class="p">):</span> -</span><span id="Generator-524"><a href="#Generator-524"><span class="linenos"> 524</span></a> <span class="k">return</span> <span class="p">(</span> -</span><span id="Generator-525"><a href="#Generator-525"><span class="linenos"> 525</span></a> <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="si">}{</span><span class="n">comments_sql</span><span class="si">}{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-526"><a href="#Generator-526"><span class="linenos"> 526</span></a> <span class="k">if</span> <span class="n">sql</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">isspace</span><span class="p">()</span> -</span><span id="Generator-527"><a href="#Generator-527"><span class="linenos"> 527</span></a> <span class="k">else</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">comments_sql</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="n">sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-528"><a href="#Generator-528"><span class="linenos"> 528</span></a> <span class="p">)</span> -</span><span id="Generator-529"><a href="#Generator-529"><span class="linenos"> 529</span></a> -</span><span id="Generator-530"><a href="#Generator-530"><span class="linenos"> 530</span></a> <span class="k">return</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="s2"> </span><span class="si">{</span><span class="n">comments_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-531"><a href="#Generator-531"><span class="linenos"> 531</span></a> -</span><span id="Generator-532"><a href="#Generator-532"><span class="linenos"> 532</span></a> <span class="k">def</span> <span class="nf">wrap</span><span class="p">(</span><span class="bp">self</span><span 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="o">|</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-533"><a href="#Generator-533"><span class="linenos"> 533</span></a> <span class="n">this_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span> -</span><span id="Generator-534"><a href="#Generator-534"><span class="linenos"> 534</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><span id="Generator-535"><a href="#Generator-535"><span class="linenos"> 535</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Union</span><span class="p">))</span> -</span><span id="Generator-536"><a href="#Generator-536"><span class="linenos"> 536</span></a> <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">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">),</span> -</span><span id="Generator-537"><a href="#Generator-537"><span class="linenos"> 537</span></a> <span class="n">level</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> -</span><span id="Generator-538"><a href="#Generator-538"><span class="linenos"> 538</span></a> <span class="n">pad</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> -</span><span id="Generator-539"><a href="#Generator-539"><span class="linenos"> 539</span></a> <span class="p">)</span> -</span><span id="Generator-540"><a href="#Generator-540"><span class="linenos"> 540</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">sep</span><span class="p">(</span><span class="s1">''</span><span class="p">)</span><span class="si">}{</span><span class="n">this_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-541"><a href="#Generator-541"><span class="linenos"> 541</span></a> -</span><span id="Generator-542"><a href="#Generator-542"><span class="linenos"> 542</span></a> <span class="k">def</span> <span class="nf">no_identify</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">func</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">[</span><span class="o">...</span><span class="p">,</span> <span class="nb">str</span><span class="p">],</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-543"><a href="#Generator-543"><span class="linenos"> 543</span></a> <span class="n">original</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">identify</span> -</span><span id="Generator-544"><a href="#Generator-544"><span class="linenos"> 544</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">identify</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Generator-545"><a href="#Generator-545"><span class="linenos"> 545</span></a> <span class="n">result</span> <span class="o">=</span> <span class="n">func</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> -</span><span id="Generator-546"><a href="#Generator-546"><span class="linenos"> 546</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">identify</span> <span class="o">=</span> <span class="n">original</span> -</span><span id="Generator-547"><a href="#Generator-547"><span class="linenos"> 547</span></a> <span class="k">return</span> <span class="n">result</span> -</span><span id="Generator-548"><a href="#Generator-548"><span class="linenos"> 548</span></a> -</span><span id="Generator-549"><a href="#Generator-549"><span class="linenos"> 549</span></a> <span class="k">def</span> <span class="nf">normalize_func</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</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-550"><a href="#Generator-550"><span class="linenos"> 550</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">normalize_functions</span> <span class="o">==</span> <span class="s2">"upper"</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">normalize_functions</span> <span class="ow">is</span> <span class="kc">True</span><span class="p">:</span> -</span><span id="Generator-551"><a href="#Generator-551"><span class="linenos"> 551</span></a> <span class="k">return</span> <span class="n">name</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> -</span><span id="Generator-552"><a href="#Generator-552"><span class="linenos"> 552</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">normalize_functions</span> <span class="o">==</span> <span class="s2">"lower"</span><span class="p">:</span> -</span><span id="Generator-553"><a href="#Generator-553"><span class="linenos"> 553</span></a> <span class="k">return</span> <span class="n">name</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> -</span><span id="Generator-554"><a href="#Generator-554"><span class="linenos"> 554</span></a> <span class="k">return</span> <span class="n">name</span> -</span><span id="Generator-555"><a href="#Generator-555"><span class="linenos"> 555</span></a> -</span><span id="Generator-556"><a href="#Generator-556"><span class="linenos"> 556</span></a> <span class="k">def</span> <span class="nf">indent</span><span class="p">(</span> -</span><span id="Generator-557"><a href="#Generator-557"><span class="linenos"> 557</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Generator-558"><a href="#Generator-558"><span class="linenos"> 558</span></a> <span class="n">sql</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> -</span><span id="Generator-559"><a href="#Generator-559"><span class="linenos"> 559</span></a> <span class="n">level</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span> -</span><span id="Generator-560"><a href="#Generator-560"><span class="linenos"> 560</span></a> <span class="n">pad</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">int</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Generator-561"><a href="#Generator-561"><span class="linenos"> 561</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-562"><a href="#Generator-562"><span class="linenos"> 562</span></a> <span class="n">skip_last</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-563"><a href="#Generator-563"><span class="linenos"> 563</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-564"><a href="#Generator-564"><span class="linenos"> 564</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-565"><a href="#Generator-565"><span class="linenos"> 565</span></a> <span class="k">return</span> <span class="n">sql</span> -</span><span id="Generator-566"><a href="#Generator-566"><span class="linenos"> 566</span></a> -</span><span id="Generator-567"><a href="#Generator-567"><span class="linenos"> 567</span></a> <span class="n">pad</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">pad</span> <span class="k">if</span> <span class="n">pad</span> <span class="ow">is</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">pad</span> -</span><span id="Generator-568"><a href="#Generator-568"><span class="linenos"> 568</span></a> <span class="n">lines</span> <span class="o">=</span> <span class="n">sql</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">)</span> +</span><span id="Generator-523"><a href="#Generator-523"><span class="linenos"> 523</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">comments_sql</span><span class="p">:</span> +</span><span id="Generator-524"><a href="#Generator-524"><span class="linenos"> 524</span></a> <span class="k">return</span> <span class="n">sql</span> +</span><span id="Generator-525"><a href="#Generator-525"><span class="linenos"> 525</span></a> +</span><span id="Generator-526"><a href="#Generator-526"><span class="linenos"> 526</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">WITH_SEPARATED_COMMENTS</span><span class="p">):</span> +</span><span id="Generator-527"><a href="#Generator-527"><span class="linenos"> 527</span></a> <span class="k">return</span> <span class="p">(</span> +</span><span id="Generator-528"><a href="#Generator-528"><span class="linenos"> 528</span></a> <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="si">}{</span><span class="n">comments_sql</span><span class="si">}{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-529"><a href="#Generator-529"><span class="linenos"> 529</span></a> <span class="k">if</span> <span class="n">sql</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">isspace</span><span class="p">()</span> +</span><span id="Generator-530"><a href="#Generator-530"><span class="linenos"> 530</span></a> <span class="k">else</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">comments_sql</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="n">sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-531"><a href="#Generator-531"><span class="linenos"> 531</span></a> <span class="p">)</span> +</span><span id="Generator-532"><a href="#Generator-532"><span class="linenos"> 532</span></a> +</span><span id="Generator-533"><a href="#Generator-533"><span class="linenos"> 533</span></a> <span class="k">return</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="s2"> </span><span class="si">{</span><span class="n">comments_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-534"><a href="#Generator-534"><span class="linenos"> 534</span></a> +</span><span id="Generator-535"><a href="#Generator-535"><span class="linenos"> 535</span></a> <span class="k">def</span> <span class="nf">wrap</span><span class="p">(</span><span class="bp">self</span><span 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="o">|</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-536"><a href="#Generator-536"><span class="linenos"> 536</span></a> <span class="n">this_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span> +</span><span id="Generator-537"><a href="#Generator-537"><span class="linenos"> 537</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><span id="Generator-538"><a href="#Generator-538"><span class="linenos"> 538</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Union</span><span class="p">))</span> +</span><span id="Generator-539"><a href="#Generator-539"><span class="linenos"> 539</span></a> <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">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">),</span> +</span><span id="Generator-540"><a href="#Generator-540"><span class="linenos"> 540</span></a> <span class="n">level</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> +</span><span id="Generator-541"><a href="#Generator-541"><span class="linenos"> 541</span></a> <span class="n">pad</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> +</span><span id="Generator-542"><a href="#Generator-542"><span class="linenos"> 542</span></a> <span class="p">)</span> +</span><span id="Generator-543"><a href="#Generator-543"><span class="linenos"> 543</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">sep</span><span class="p">(</span><span class="s1">''</span><span class="p">)</span><span class="si">}{</span><span class="n">this_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-544"><a href="#Generator-544"><span class="linenos"> 544</span></a> +</span><span id="Generator-545"><a href="#Generator-545"><span class="linenos"> 545</span></a> <span class="k">def</span> <span class="nf">no_identify</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">func</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">[</span><span class="o">...</span><span class="p">,</span> <span class="nb">str</span><span class="p">],</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-546"><a href="#Generator-546"><span class="linenos"> 546</span></a> <span class="n">original</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">identify</span> +</span><span id="Generator-547"><a href="#Generator-547"><span class="linenos"> 547</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">identify</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Generator-548"><a href="#Generator-548"><span class="linenos"> 548</span></a> <span class="n">result</span> <span class="o">=</span> <span class="n">func</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> +</span><span id="Generator-549"><a href="#Generator-549"><span class="linenos"> 549</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">identify</span> <span class="o">=</span> <span class="n">original</span> +</span><span id="Generator-550"><a href="#Generator-550"><span class="linenos"> 550</span></a> <span class="k">return</span> <span class="n">result</span> +</span><span id="Generator-551"><a href="#Generator-551"><span class="linenos"> 551</span></a> +</span><span id="Generator-552"><a href="#Generator-552"><span class="linenos"> 552</span></a> <span class="k">def</span> <span class="nf">normalize_func</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</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-553"><a href="#Generator-553"><span class="linenos"> 553</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">normalize_functions</span> <span class="o">==</span> <span class="s2">"upper"</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">normalize_functions</span> <span class="ow">is</span> <span class="kc">True</span><span class="p">:</span> +</span><span id="Generator-554"><a href="#Generator-554"><span class="linenos"> 554</span></a> <span class="k">return</span> <span class="n">name</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> +</span><span id="Generator-555"><a href="#Generator-555"><span class="linenos"> 555</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">normalize_functions</span> <span class="o">==</span> <span class="s2">"lower"</span><span class="p">:</span> +</span><span id="Generator-556"><a href="#Generator-556"><span class="linenos"> 556</span></a> <span class="k">return</span> <span class="n">name</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> +</span><span id="Generator-557"><a href="#Generator-557"><span class="linenos"> 557</span></a> <span class="k">return</span> <span class="n">name</span> +</span><span id="Generator-558"><a href="#Generator-558"><span class="linenos"> 558</span></a> +</span><span id="Generator-559"><a href="#Generator-559"><span class="linenos"> 559</span></a> <span class="k">def</span> <span class="nf">indent</span><span class="p">(</span> +</span><span id="Generator-560"><a href="#Generator-560"><span class="linenos"> 560</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Generator-561"><a href="#Generator-561"><span class="linenos"> 561</span></a> <span class="n">sql</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> +</span><span id="Generator-562"><a href="#Generator-562"><span class="linenos"> 562</span></a> <span class="n">level</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span> +</span><span id="Generator-563"><a href="#Generator-563"><span class="linenos"> 563</span></a> <span class="n">pad</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">int</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Generator-564"><a href="#Generator-564"><span class="linenos"> 564</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-565"><a href="#Generator-565"><span class="linenos"> 565</span></a> <span class="n">skip_last</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-566"><a href="#Generator-566"><span class="linenos"> 566</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-567"><a href="#Generator-567"><span class="linenos"> 567</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-568"><a href="#Generator-568"><span class="linenos"> 568</span></a> <span class="k">return</span> <span class="n">sql</span> </span><span id="Generator-569"><a href="#Generator-569"><span class="linenos"> 569</span></a> -</span><span id="Generator-570"><a href="#Generator-570"><span class="linenos"> 570</span></a> <span class="k">return</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><span id="Generator-571"><a href="#Generator-571"><span class="linenos"> 571</span></a> <span class="n">line</span> -</span><span id="Generator-572"><a href="#Generator-572"><span class="linenos"> 572</span></a> <span class="k">if</span> <span class="p">(</span><span class="n">skip_first</span> <span class="ow">and</span> <span class="n">i</span> <span class="o">==</span> <span class="mi">0</span><span class="p">)</span> <span class="ow">or</span> <span class="p">(</span><span class="n">skip_last</span> <span class="ow">and</span> <span class="n">i</span> <span class="o">==</span> <span class="nb">len</span><span class="p">(</span><span class="n">lines</span><span class="p">)</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> -</span><span id="Generator-573"><a href="#Generator-573"><span class="linenos"> 573</span></a> <span class="k">else</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="s1">' '</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="p">(</span><span class="n">level</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="bp">self</span><span class="o">.</span><span class="n">_indent</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">pad</span><span class="p">)</span><span class="si">}{</span><span class="n">line</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-574"><a href="#Generator-574"><span class="linenos"> 574</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">line</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">lines</span><span class="p">)</span> -</span><span id="Generator-575"><a href="#Generator-575"><span class="linenos"> 575</span></a> <span class="p">)</span> -</span><span id="Generator-576"><a href="#Generator-576"><span class="linenos"> 576</span></a> -</span><span id="Generator-577"><a href="#Generator-577"><span class="linenos"> 577</span></a> <span class="k">def</span> <span class="nf">sql</span><span class="p">(</span> -</span><span id="Generator-578"><a href="#Generator-578"><span class="linenos"> 578</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Generator-579"><a href="#Generator-579"><span class="linenos"> 579</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="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><span id="Generator-580"><a href="#Generator-580"><span class="linenos"> 580</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-581"><a href="#Generator-581"><span class="linenos"> 581</span></a> <span class="n">comment</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-582"><a href="#Generator-582"><span class="linenos"> 582</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-583"><a href="#Generator-583"><span class="linenos"> 583</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expression</span><span class="p">:</span> -</span><span id="Generator-584"><a href="#Generator-584"><span class="linenos"> 584</span></a> <span class="k">return</span> <span class="s2">""</span> -</span><span id="Generator-585"><a href="#Generator-585"><span class="linenos"> 585</span></a> -</span><span id="Generator-586"><a href="#Generator-586"><span class="linenos"> 586</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span> -</span><span id="Generator-587"><a href="#Generator-587"><span class="linenos"> 587</span></a> <span class="k">return</span> <span class="n">expression</span> +</span><span id="Generator-570"><a href="#Generator-570"><span class="linenos"> 570</span></a> <span class="n">pad</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">pad</span> <span class="k">if</span> <span class="n">pad</span> <span class="ow">is</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">pad</span> +</span><span id="Generator-571"><a href="#Generator-571"><span class="linenos"> 571</span></a> <span class="n">lines</span> <span class="o">=</span> <span class="n">sql</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">)</span> +</span><span id="Generator-572"><a href="#Generator-572"><span class="linenos"> 572</span></a> +</span><span id="Generator-573"><a href="#Generator-573"><span class="linenos"> 573</span></a> <span class="k">return</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><span id="Generator-574"><a href="#Generator-574"><span class="linenos"> 574</span></a> <span class="n">line</span> +</span><span id="Generator-575"><a href="#Generator-575"><span class="linenos"> 575</span></a> <span class="k">if</span> <span class="p">(</span><span class="n">skip_first</span> <span class="ow">and</span> <span class="n">i</span> <span class="o">==</span> <span class="mi">0</span><span class="p">)</span> <span class="ow">or</span> <span class="p">(</span><span class="n">skip_last</span> <span class="ow">and</span> <span class="n">i</span> <span class="o">==</span> <span class="nb">len</span><span class="p">(</span><span class="n">lines</span><span class="p">)</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> +</span><span id="Generator-576"><a href="#Generator-576"><span class="linenos"> 576</span></a> <span class="k">else</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="s1">' '</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="p">(</span><span class="n">level</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="bp">self</span><span class="o">.</span><span class="n">_indent</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">pad</span><span class="p">)</span><span class="si">}{</span><span class="n">line</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-577"><a href="#Generator-577"><span class="linenos"> 577</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">line</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">lines</span><span class="p">)</span> +</span><span id="Generator-578"><a href="#Generator-578"><span class="linenos"> 578</span></a> <span class="p">)</span> +</span><span id="Generator-579"><a href="#Generator-579"><span class="linenos"> 579</span></a> +</span><span id="Generator-580"><a href="#Generator-580"><span class="linenos"> 580</span></a> <span class="k">def</span> <span class="nf">sql</span><span class="p">(</span> +</span><span id="Generator-581"><a href="#Generator-581"><span class="linenos"> 581</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Generator-582"><a href="#Generator-582"><span class="linenos"> 582</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="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><span id="Generator-583"><a href="#Generator-583"><span class="linenos"> 583</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-584"><a href="#Generator-584"><span class="linenos"> 584</span></a> <span class="n">comment</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-585"><a href="#Generator-585"><span class="linenos"> 585</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-586"><a href="#Generator-586"><span class="linenos"> 586</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expression</span><span class="p">:</span> +</span><span id="Generator-587"><a href="#Generator-587"><span class="linenos"> 587</span></a> <span class="k">return</span> <span class="s2">""</span> </span><span id="Generator-588"><a href="#Generator-588"><span class="linenos"> 588</span></a> -</span><span id="Generator-589"><a href="#Generator-589"><span class="linenos"> 589</span></a> <span class="k">if</span> <span class="n">key</span><span class="p">:</span> -</span><span id="Generator-590"><a href="#Generator-590"><span class="linenos"> 590</span></a> <span class="n">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-591"><a href="#Generator-591"><span class="linenos"> 591</span></a> <span class="k">if</span> <span class="n">value</span><span class="p">:</span> -</span><span id="Generator-592"><a href="#Generator-592"><span class="linenos"> 592</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">value</span><span class="p">)</span> -</span><span id="Generator-593"><a href="#Generator-593"><span class="linenos"> 593</span></a> <span class="k">return</span> <span class="s2">""</span> -</span><span id="Generator-594"><a href="#Generator-594"><span class="linenos"> 594</span></a> -</span><span id="Generator-595"><a href="#Generator-595"><span class="linenos"> 595</span></a> <span class="n">transform</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">TRANSFORMS</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-596"><a href="#Generator-596"><span class="linenos"> 596</span></a> -</span><span id="Generator-597"><a href="#Generator-597"><span class="linenos"> 597</span></a> <span class="k">if</span> <span class="nb">callable</span><span class="p">(</span><span class="n">transform</span><span class="p">):</span> -</span><span id="Generator-598"><a href="#Generator-598"><span class="linenos"> 598</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="n">transform</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> -</span><span id="Generator-599"><a href="#Generator-599"><span class="linenos"> 599</span></a> <span class="k">elif</span> <span class="n">transform</span><span class="p">:</span> -</span><span id="Generator-600"><a href="#Generator-600"><span class="linenos"> 600</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="n">transform</span> -</span><span id="Generator-601"><a href="#Generator-601"><span class="linenos"> 601</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="Generator-602"><a href="#Generator-602"><span class="linenos"> 602</span></a> <span class="n">exp_handler_name</span> <span class="o">=</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">key</span><span class="si">}</span><span class="s2">_sql"</span> -</span><span id="Generator-603"><a href="#Generator-603"><span class="linenos"> 603</span></a> -</span><span id="Generator-604"><a href="#Generator-604"><span class="linenos"> 604</span></a> <span class="k">if</span> <span class="nb">hasattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">exp_handler_name</span><span class="p">):</span> -</span><span id="Generator-605"><a href="#Generator-605"><span class="linenos"> 605</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">exp_handler_name</span><span class="p">)(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Generator-606"><a href="#Generator-606"><span class="linenos"> 606</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Func</span><span class="p">):</span> -</span><span id="Generator-607"><a href="#Generator-607"><span class="linenos"> 607</span></a> <span class="n">sql</span> <span class="o">=</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-608"><a href="#Generator-608"><span class="linenos"> 608</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Property</span><span class="p">):</span> -</span><span id="Generator-609"><a href="#Generator-609"><span class="linenos"> 609</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">property_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Generator-610"><a href="#Generator-610"><span class="linenos"> 610</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator-611"><a href="#Generator-611"><span class="linenos"> 611</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unsupported expression type </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-612"><a href="#Generator-612"><span class="linenos"> 612</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator-613"><a href="#Generator-613"><span class="linenos"> 613</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Expected an Expression. Received </span><span class="si">{</span><span class="nb">type</span><span class="p">(</span><span class="n">expression</span><span class="p">)</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 class="p">)</span> -</span><span id="Generator-614"><a href="#Generator-614"><span class="linenos"> 614</span></a> -</span><span id="Generator-615"><a href="#Generator-615"><span class="linenos"> 615</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">maybe_comment</span><span class="p">(</span><span class="n">sql</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">comments</span> <span class="ow">and</span> <span class="n">comment</span> <span class="k">else</span> <span class="n">sql</span> -</span><span id="Generator-616"><a href="#Generator-616"><span class="linenos"> 616</span></a> -</span><span id="Generator-617"><a href="#Generator-617"><span class="linenos"> 617</span></a> <span class="k">def</span> <span class="nf">uncache_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Uncache</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-618"><a href="#Generator-618"><span class="linenos"> 618</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">"this"</span><span class="p">)</span> -</span><span id="Generator-619"><a href="#Generator-619"><span class="linenos"> 619</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-620"><a href="#Generator-620"><span class="linenos"> 620</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"UNCACHE TABLE</span><span class="si">{</span><span class="n">exists_sql</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">table</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-621"><a href="#Generator-621"><span class="linenos"> 621</span></a> -</span><span id="Generator-622"><a href="#Generator-622"><span class="linenos"> 622</span></a> <span class="k">def</span> <span class="nf">cache_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cache</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-623"><a href="#Generator-623"><span class="linenos"> 623</span></a> <span class="n">lazy</span> <span class="o">=</span> <span class="s2">" LAZY"</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">"lazy"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-624"><a href="#Generator-624"><span class="linenos"> 624</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">"this"</span><span class="p">)</span> -</span><span id="Generator-625"><a href="#Generator-625"><span class="linenos"> 625</span></a> <span class="n">options</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">"options"</span><span class="p">)</span> -</span><span id="Generator-626"><a href="#Generator-626"><span class="linenos"> 626</span></a> <span class="n">options</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" OPTIONS(</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">options</span><span class="p">[</span><span class="mi">0</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">options</span><span class="p">[</span><span class="mi">1</span><span class="p">])</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-627"><a href="#Generator-627"><span class="linenos"> 627</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">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> -</span><span id="Generator-628"><a href="#Generator-628"><span class="linenos"> 628</span></a> <span class="n">sql</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">sep</span><span class="p">()</span><span class="si">}{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">sql</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-629"><a href="#Generator-629"><span class="linenos"> 629</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"CACHE</span><span class="si">{</span><span class="n">lazy</span><span class="si">}</span><span class="s2"> TABLE </span><span class="si">{</span><span class="n">table</span><span class="si">}{</span><span class="n">options</span><span class="si">}{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-630"><a href="#Generator-630"><span class="linenos"> 630</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-631"><a href="#Generator-631"><span class="linenos"> 631</span></a> -</span><span id="Generator-632"><a href="#Generator-632"><span class="linenos"> 632</span></a> <span class="k">def</span> <span class="nf">characterset_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">CharacterSet</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-633"><a href="#Generator-633"><span class="linenos"> 633</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">parent</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">):</span> -</span><span id="Generator-634"><a href="#Generator-634"><span class="linenos"> 634</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CHAR CHARACTER SET </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-635"><a href="#Generator-635"><span class="linenos"> 635</span></a> <span class="n">default</span> <span class="o">=</span> <span class="s2">"DEFAULT "</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">"default"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-636"><a href="#Generator-636"><span class="linenos"> 636</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">default</span><span class="si">}</span><span class="s2">CHARACTER SET=</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-637"><a href="#Generator-637"><span class="linenos"> 637</span></a> -</span><span id="Generator-638"><a href="#Generator-638"><span class="linenos"> 638</span></a> <span class="k">def</span> <span class="nf">column_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-639"><a href="#Generator-639"><span class="linenos"> 639</span></a> <span class="n">join_mark</span> <span class="o">=</span> <span class="s2">" (+)"</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">"join_mark"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-589"><a href="#Generator-589"><span class="linenos"> 589</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span> +</span><span id="Generator-590"><a href="#Generator-590"><span class="linenos"> 590</span></a> <span class="k">return</span> <span class="n">expression</span> +</span><span id="Generator-591"><a href="#Generator-591"><span class="linenos"> 591</span></a> +</span><span id="Generator-592"><a href="#Generator-592"><span class="linenos"> 592</span></a> <span class="k">if</span> <span class="n">key</span><span class="p">:</span> +</span><span id="Generator-593"><a href="#Generator-593"><span class="linenos"> 593</span></a> <span class="n">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-594"><a href="#Generator-594"><span class="linenos"> 594</span></a> <span class="k">if</span> <span class="n">value</span><span class="p">:</span> +</span><span id="Generator-595"><a href="#Generator-595"><span class="linenos"> 595</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">value</span><span class="p">)</span> +</span><span id="Generator-596"><a href="#Generator-596"><span class="linenos"> 596</span></a> <span class="k">return</span> <span class="s2">""</span> +</span><span id="Generator-597"><a href="#Generator-597"><span class="linenos"> 597</span></a> +</span><span id="Generator-598"><a href="#Generator-598"><span class="linenos"> 598</span></a> <span class="n">transform</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">TRANSFORMS</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-599"><a href="#Generator-599"><span class="linenos"> 599</span></a> +</span><span id="Generator-600"><a href="#Generator-600"><span class="linenos"> 600</span></a> <span class="k">if</span> <span class="nb">callable</span><span class="p">(</span><span class="n">transform</span><span class="p">):</span> +</span><span id="Generator-601"><a href="#Generator-601"><span class="linenos"> 601</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="n">transform</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> +</span><span id="Generator-602"><a href="#Generator-602"><span class="linenos"> 602</span></a> <span class="k">elif</span> <span class="n">transform</span><span class="p">:</span> +</span><span id="Generator-603"><a href="#Generator-603"><span class="linenos"> 603</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="n">transform</span> +</span><span id="Generator-604"><a href="#Generator-604"><span class="linenos"> 604</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="Generator-605"><a href="#Generator-605"><span class="linenos"> 605</span></a> <span class="n">exp_handler_name</span> <span class="o">=</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">key</span><span class="si">}</span><span class="s2">_sql"</span> +</span><span id="Generator-606"><a href="#Generator-606"><span class="linenos"> 606</span></a> +</span><span id="Generator-607"><a href="#Generator-607"><span class="linenos"> 607</span></a> <span class="k">if</span> <span class="nb">hasattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">exp_handler_name</span><span class="p">):</span> +</span><span id="Generator-608"><a href="#Generator-608"><span class="linenos"> 608</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">exp_handler_name</span><span class="p">)(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Generator-609"><a href="#Generator-609"><span class="linenos"> 609</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Func</span><span class="p">):</span> +</span><span id="Generator-610"><a href="#Generator-610"><span class="linenos"> 610</span></a> <span class="n">sql</span> <span class="o">=</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-611"><a href="#Generator-611"><span class="linenos"> 611</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Property</span><span class="p">):</span> +</span><span id="Generator-612"><a href="#Generator-612"><span class="linenos"> 612</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">property_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Generator-613"><a href="#Generator-613"><span class="linenos"> 613</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator-614"><a href="#Generator-614"><span class="linenos"> 614</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unsupported expression type </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-615"><a href="#Generator-615"><span class="linenos"> 615</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator-616"><a href="#Generator-616"><span class="linenos"> 616</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Expected an Expression. Received </span><span class="si">{</span><span class="nb">type</span><span class="p">(</span><span class="n">expression</span><span class="p">)</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 class="p">)</span> +</span><span id="Generator-617"><a href="#Generator-617"><span class="linenos"> 617</span></a> +</span><span id="Generator-618"><a href="#Generator-618"><span class="linenos"> 618</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">maybe_comment</span><span class="p">(</span><span class="n">sql</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">comments</span> <span class="ow">and</span> <span class="n">comment</span> <span class="k">else</span> <span class="n">sql</span> +</span><span id="Generator-619"><a href="#Generator-619"><span class="linenos"> 619</span></a> +</span><span id="Generator-620"><a href="#Generator-620"><span class="linenos"> 620</span></a> <span class="k">def</span> <span class="nf">uncache_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Uncache</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-621"><a href="#Generator-621"><span class="linenos"> 621</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">"this"</span><span class="p">)</span> +</span><span id="Generator-622"><a href="#Generator-622"><span class="linenos"> 622</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-623"><a href="#Generator-623"><span class="linenos"> 623</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"UNCACHE TABLE</span><span class="si">{</span><span class="n">exists_sql</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">table</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-624"><a href="#Generator-624"><span class="linenos"> 624</span></a> +</span><span id="Generator-625"><a href="#Generator-625"><span class="linenos"> 625</span></a> <span class="k">def</span> <span class="nf">cache_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cache</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-626"><a href="#Generator-626"><span class="linenos"> 626</span></a> <span class="n">lazy</span> <span class="o">=</span> <span class="s2">" LAZY"</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">"lazy"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-627"><a href="#Generator-627"><span class="linenos"> 627</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">"this"</span><span class="p">)</span> +</span><span id="Generator-628"><a href="#Generator-628"><span class="linenos"> 628</span></a> <span class="n">options</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">"options"</span><span class="p">)</span> +</span><span id="Generator-629"><a href="#Generator-629"><span class="linenos"> 629</span></a> <span class="n">options</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" OPTIONS(</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">options</span><span class="p">[</span><span class="mi">0</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">options</span><span class="p">[</span><span class="mi">1</span><span class="p">])</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-630"><a href="#Generator-630"><span class="linenos"> 630</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">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> +</span><span id="Generator-631"><a href="#Generator-631"><span class="linenos"> 631</span></a> <span class="n">sql</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">sep</span><span class="p">()</span><span class="si">}{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">sql</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-632"><a href="#Generator-632"><span class="linenos"> 632</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"CACHE</span><span class="si">{</span><span class="n">lazy</span><span class="si">}</span><span class="s2"> TABLE </span><span class="si">{</span><span class="n">table</span><span class="si">}{</span><span class="n">options</span><span class="si">}{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-633"><a href="#Generator-633"><span class="linenos"> 633</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-634"><a href="#Generator-634"><span class="linenos"> 634</span></a> +</span><span id="Generator-635"><a href="#Generator-635"><span class="linenos"> 635</span></a> <span class="k">def</span> <span class="nf">characterset_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">CharacterSet</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-636"><a href="#Generator-636"><span class="linenos"> 636</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">parent</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">):</span> +</span><span id="Generator-637"><a href="#Generator-637"><span class="linenos"> 637</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CHAR CHARACTER SET </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-638"><a href="#Generator-638"><span class="linenos"> 638</span></a> <span class="n">default</span> <span class="o">=</span> <span class="s2">"DEFAULT "</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">"default"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-639"><a href="#Generator-639"><span class="linenos"> 639</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">default</span><span class="si">}</span><span class="s2">CHARACTER SET=</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-640"><a href="#Generator-640"><span class="linenos"> 640</span></a> -</span><span id="Generator-641"><a href="#Generator-641"><span class="linenos"> 641</span></a> <span class="k">if</span> <span class="n">join_mark</span> <span class="ow">and</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">COLUMN_JOIN_MARKS_SUPPORTED</span><span class="p">:</span> -</span><span id="Generator-642"><a href="#Generator-642"><span class="linenos"> 642</span></a> <span class="n">join_mark</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator-643"><a href="#Generator-643"><span class="linenos"> 643</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Outer join syntax using the (+) operator is not supported."</span><span class="p">)</span> -</span><span id="Generator-644"><a href="#Generator-644"><span class="linenos"> 644</span></a> -</span><span id="Generator-645"><a href="#Generator-645"><span class="linenos"> 645</span></a> <span class="n">column</span> <span class="o">=</span> <span class="s2">"."</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> -</span><span id="Generator-646"><a href="#Generator-646"><span class="linenos"> 646</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">part</span><span class="p">)</span> -</span><span id="Generator-647"><a href="#Generator-647"><span class="linenos"> 647</span></a> <span class="k">for</span> <span class="n">part</span> <span class="ow">in</span> <span class="p">(</span> -</span><span id="Generator-648"><a href="#Generator-648"><span class="linenos"> 648</span></a> <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">"catalog"</span><span class="p">),</span> -</span><span id="Generator-649"><a href="#Generator-649"><span class="linenos"> 649</span></a> <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">"db"</span><span class="p">),</span> -</span><span id="Generator-650"><a href="#Generator-650"><span class="linenos"> 650</span></a> <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">"table"</span><span class="p">),</span> -</span><span id="Generator-651"><a href="#Generator-651"><span class="linenos"> 651</span></a> <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">"this"</span><span class="p">),</span> -</span><span id="Generator-652"><a href="#Generator-652"><span class="linenos"> 652</span></a> <span class="p">)</span> -</span><span id="Generator-653"><a href="#Generator-653"><span class="linenos"> 653</span></a> <span class="k">if</span> <span class="n">part</span> -</span><span id="Generator-654"><a href="#Generator-654"><span class="linenos"> 654</span></a> <span class="p">)</span> -</span><span id="Generator-655"><a href="#Generator-655"><span class="linenos"> 655</span></a> -</span><span id="Generator-656"><a href="#Generator-656"><span class="linenos"> 656</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">column</span><span class="si">}{</span><span class="n">join_mark</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-657"><a href="#Generator-657"><span class="linenos"> 657</span></a> -</span><span id="Generator-658"><a href="#Generator-658"><span class="linenos"> 658</span></a> <span class="k">def</span> <span class="nf">columnposition_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ColumnPosition</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-659"><a href="#Generator-659"><span class="linenos"> 659</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-660"><a href="#Generator-660"><span class="linenos"> 660</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-661"><a href="#Generator-661"><span class="linenos"> 661</span></a> <span class="n">position</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"position"</span><span class="p">)</span> -</span><span id="Generator-662"><a href="#Generator-662"><span class="linenos"> 662</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">position</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-663"><a href="#Generator-663"><span class="linenos"> 663</span></a> -</span><span id="Generator-664"><a href="#Generator-664"><span class="linenos"> 664</span></a> <span class="k">def</span> <span class="nf">columndef_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ColumnDef</span><span class="p">,</span> <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 class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-665"><a href="#Generator-665"><span class="linenos"> 665</span></a> <span class="n">column</span> <span class="o">=</span> <span class="bp">self</span><span 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-666"><a href="#Generator-666"><span class="linenos"> 666</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-667"><a href="#Generator-667"><span class="linenos"> 667</span></a> <span class="n">constraints</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">"constraints"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</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-668"><a href="#Generator-668"><span class="linenos"> 668</span></a> <span class="n">exists</span> <span class="o">=</span> <span class="s2">"IF NOT 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-669"><a href="#Generator-669"><span class="linenos"> 669</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">sep</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-670"><a href="#Generator-670"><span class="linenos"> 670</span></a> <span class="n">constraints</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">constraints</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">constraints</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-671"><a href="#Generator-671"><span class="linenos"> 671</span></a> <span class="n">position</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"position"</span><span class="p">)</span> -</span><span id="Generator-672"><a href="#Generator-672"><span class="linenos"> 672</span></a> <span class="n">position</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">position</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">position</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-673"><a href="#Generator-673"><span class="linenos"> 673</span></a> -</span><span id="Generator-674"><a href="#Generator-674"><span class="linenos"> 674</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">find</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">ComputedColumnConstraint</span><span class="p">)</span> <span class="ow">and</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">COMPUTED_COLUMN_WITH_TYPE</span><span class="p">:</span> -</span><span id="Generator-675"><a href="#Generator-675"><span class="linenos"> 675</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator-641"><a href="#Generator-641"><span class="linenos"> 641</span></a> <span class="k">def</span> <span class="nf">column_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-642"><a href="#Generator-642"><span class="linenos"> 642</span></a> <span class="n">join_mark</span> <span class="o">=</span> <span class="s2">" (+)"</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">"join_mark"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-643"><a href="#Generator-643"><span class="linenos"> 643</span></a> +</span><span id="Generator-644"><a href="#Generator-644"><span class="linenos"> 644</span></a> <span class="k">if</span> <span class="n">join_mark</span> <span class="ow">and</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">COLUMN_JOIN_MARKS_SUPPORTED</span><span class="p">:</span> +</span><span id="Generator-645"><a href="#Generator-645"><span class="linenos"> 645</span></a> <span class="n">join_mark</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator-646"><a href="#Generator-646"><span class="linenos"> 646</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Outer join syntax using the (+) operator is not supported."</span><span class="p">)</span> +</span><span id="Generator-647"><a href="#Generator-647"><span class="linenos"> 647</span></a> +</span><span id="Generator-648"><a href="#Generator-648"><span class="linenos"> 648</span></a> <span class="n">column</span> <span class="o">=</span> <span class="s2">"."</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> +</span><span id="Generator-649"><a href="#Generator-649"><span class="linenos"> 649</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">part</span><span class="p">)</span> +</span><span id="Generator-650"><a href="#Generator-650"><span class="linenos"> 650</span></a> <span class="k">for</span> <span class="n">part</span> <span class="ow">in</span> <span class="p">(</span> +</span><span id="Generator-651"><a href="#Generator-651"><span class="linenos"> 651</span></a> <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">"catalog"</span><span class="p">),</span> +</span><span id="Generator-652"><a href="#Generator-652"><span class="linenos"> 652</span></a> <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">"db"</span><span class="p">),</span> +</span><span id="Generator-653"><a href="#Generator-653"><span class="linenos"> 653</span></a> <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">"table"</span><span class="p">),</span> +</span><span id="Generator-654"><a href="#Generator-654"><span class="linenos"> 654</span></a> <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">"this"</span><span class="p">),</span> +</span><span id="Generator-655"><a href="#Generator-655"><span class="linenos"> 655</span></a> <span class="p">)</span> +</span><span id="Generator-656"><a href="#Generator-656"><span class="linenos"> 656</span></a> <span class="k">if</span> <span class="n">part</span> +</span><span id="Generator-657"><a href="#Generator-657"><span class="linenos"> 657</span></a> <span class="p">)</span> +</span><span id="Generator-658"><a href="#Generator-658"><span class="linenos"> 658</span></a> +</span><span id="Generator-659"><a href="#Generator-659"><span class="linenos"> 659</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">column</span><span class="si">}{</span><span class="n">join_mark</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-660"><a href="#Generator-660"><span class="linenos"> 660</span></a> +</span><span id="Generator-661"><a href="#Generator-661"><span class="linenos"> 661</span></a> <span class="k">def</span> <span class="nf">columnposition_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ColumnPosition</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-662"><a href="#Generator-662"><span class="linenos"> 662</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-663"><a href="#Generator-663"><span class="linenos"> 663</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-664"><a href="#Generator-664"><span class="linenos"> 664</span></a> <span class="n">position</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"position"</span><span class="p">)</span> +</span><span id="Generator-665"><a href="#Generator-665"><span class="linenos"> 665</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">position</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-666"><a href="#Generator-666"><span class="linenos"> 666</span></a> +</span><span id="Generator-667"><a href="#Generator-667"><span class="linenos"> 667</span></a> <span class="k">def</span> <span class="nf">columndef_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ColumnDef</span><span class="p">,</span> <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 class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-668"><a href="#Generator-668"><span class="linenos"> 668</span></a> <span class="n">column</span> <span class="o">=</span> <span class="bp">self</span><span 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-669"><a href="#Generator-669"><span class="linenos"> 669</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-670"><a href="#Generator-670"><span class="linenos"> 670</span></a> <span class="n">constraints</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">"constraints"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</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-671"><a href="#Generator-671"><span class="linenos"> 671</span></a> <span class="n">exists</span> <span class="o">=</span> <span class="s2">"IF NOT 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-672"><a href="#Generator-672"><span class="linenos"> 672</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">sep</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-673"><a href="#Generator-673"><span class="linenos"> 673</span></a> <span class="n">constraints</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">constraints</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">constraints</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-674"><a href="#Generator-674"><span class="linenos"> 674</span></a> <span class="n">position</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"position"</span><span class="p">)</span> +</span><span id="Generator-675"><a href="#Generator-675"><span class="linenos"> 675</span></a> <span class="n">position</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">position</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">position</span> <span class="k">else</span> <span class="s2">""</span> </span><span id="Generator-676"><a href="#Generator-676"><span class="linenos"> 676</span></a> -</span><span id="Generator-677"><a href="#Generator-677"><span class="linenos"> 677</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">exists</span><span class="si">}{</span><span class="n">column</span><span class="si">}{</span><span class="n">kind</span><span class="si">}{</span><span class="n">constraints</span><span class="si">}{</span><span class="n">position</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-678"><a href="#Generator-678"><span class="linenos"> 678</span></a> -</span><span id="Generator-679"><a href="#Generator-679"><span class="linenos"> 679</span></a> <span class="k">def</span> <span class="nf">columnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-680"><a href="#Generator-680"><span class="linenos"> 680</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-681"><a href="#Generator-681"><span class="linenos"> 681</span></a> <span class="n">kind_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">"kind"</span><span class="p">)</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> -</span><span id="Generator-682"><a href="#Generator-682"><span class="linenos"> 682</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CONSTRAINT </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_sql</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="n">kind_sql</span> -</span><span id="Generator-683"><a href="#Generator-683"><span class="linenos"> 683</span></a> -</span><span id="Generator-684"><a href="#Generator-684"><span class="linenos"> 684</span></a> <span class="k">def</span> <span class="nf">computedcolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ComputedColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-685"><a href="#Generator-685"><span class="linenos"> 685</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-686"><a href="#Generator-686"><span class="linenos"> 686</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">"not_null"</span><span class="p">):</span> -</span><span id="Generator-687"><a href="#Generator-687"><span class="linenos"> 687</span></a> <span class="n">persisted</span> <span class="o">=</span> <span class="s2">" PERSISTED NOT NULL"</span> -</span><span id="Generator-688"><a href="#Generator-688"><span class="linenos"> 688</span></a> <span class="k">elif</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">"persisted"</span><span class="p">):</span> -</span><span id="Generator-689"><a href="#Generator-689"><span class="linenos"> 689</span></a> <span class="n">persisted</span> <span class="o">=</span> <span class="s2">" PERSISTED"</span> -</span><span id="Generator-690"><a href="#Generator-690"><span class="linenos"> 690</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator-691"><a href="#Generator-691"><span class="linenos"> 691</span></a> <span class="n">persisted</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator-692"><a href="#Generator-692"><span class="linenos"> 692</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"AS </span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">persisted</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-693"><a href="#Generator-693"><span class="linenos"> 693</span></a> -</span><span id="Generator-694"><a href="#Generator-694"><span class="linenos"> 694</span></a> <span class="k">def</span> <span class="nf">autoincrementcolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">_</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-695"><a href="#Generator-695"><span class="linenos"> 695</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">token_sql</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">AUTO_INCREMENT</span><span class="p">)</span> +</span><span id="Generator-677"><a href="#Generator-677"><span class="linenos"> 677</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">find</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">ComputedColumnConstraint</span><span class="p">)</span> <span class="ow">and</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">COMPUTED_COLUMN_WITH_TYPE</span><span class="p">:</span> +</span><span id="Generator-678"><a href="#Generator-678"><span class="linenos"> 678</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator-679"><a href="#Generator-679"><span class="linenos"> 679</span></a> +</span><span id="Generator-680"><a href="#Generator-680"><span class="linenos"> 680</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">exists</span><span class="si">}{</span><span class="n">column</span><span class="si">}{</span><span class="n">kind</span><span class="si">}{</span><span class="n">constraints</span><span class="si">}{</span><span class="n">position</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-681"><a href="#Generator-681"><span class="linenos"> 681</span></a> +</span><span id="Generator-682"><a href="#Generator-682"><span class="linenos"> 682</span></a> <span class="k">def</span> <span class="nf">columnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-683"><a href="#Generator-683"><span class="linenos"> 683</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-684"><a href="#Generator-684"><span class="linenos"> 684</span></a> <span class="n">kind_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">"kind"</span><span class="p">)</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> +</span><span id="Generator-685"><a href="#Generator-685"><span class="linenos"> 685</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CONSTRAINT </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_sql</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="n">kind_sql</span> +</span><span id="Generator-686"><a href="#Generator-686"><span class="linenos"> 686</span></a> +</span><span id="Generator-687"><a href="#Generator-687"><span class="linenos"> 687</span></a> <span class="k">def</span> <span class="nf">computedcolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ComputedColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-688"><a href="#Generator-688"><span class="linenos"> 688</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-689"><a href="#Generator-689"><span class="linenos"> 689</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">"not_null"</span><span class="p">):</span> +</span><span id="Generator-690"><a href="#Generator-690"><span class="linenos"> 690</span></a> <span class="n">persisted</span> <span class="o">=</span> <span class="s2">" PERSISTED NOT NULL"</span> +</span><span id="Generator-691"><a href="#Generator-691"><span class="linenos"> 691</span></a> <span class="k">elif</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">"persisted"</span><span class="p">):</span> +</span><span id="Generator-692"><a href="#Generator-692"><span class="linenos"> 692</span></a> <span class="n">persisted</span> <span class="o">=</span> <span class="s2">" PERSISTED"</span> +</span><span id="Generator-693"><a href="#Generator-693"><span class="linenos"> 693</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator-694"><a href="#Generator-694"><span class="linenos"> 694</span></a> <span class="n">persisted</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator-695"><a href="#Generator-695"><span class="linenos"> 695</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"AS </span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">persisted</span><span class="si">}</span><span class="s2">"</span> </span><span id="Generator-696"><a href="#Generator-696"><span class="linenos"> 696</span></a> -</span><span id="Generator-697"><a href="#Generator-697"><span class="linenos"> 697</span></a> <span class="k">def</span> <span class="nf">compresscolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">CompressColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-698"><a href="#Generator-698"><span class="linenos"> 698</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">this</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span> -</span><span id="Generator-699"><a href="#Generator-699"><span class="linenos"> 699</span></a> <span class="n">this</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="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">"this"</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-700"><a href="#Generator-700"><span class="linenos"> 700</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator-701"><a href="#Generator-701"><span class="linenos"> 701</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-702"><a href="#Generator-702"><span class="linenos"> 702</span></a> -</span><span id="Generator-703"><a href="#Generator-703"><span class="linenos"> 703</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"COMPRESS </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-704"><a href="#Generator-704"><span class="linenos"> 704</span></a> -</span><span id="Generator-705"><a href="#Generator-705"><span class="linenos"> 705</span></a> <span class="k">def</span> <span class="nf">generatedasidentitycolumnconstraint_sql</span><span class="p">(</span> -</span><span id="Generator-706"><a href="#Generator-706"><span class="linenos"> 706</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GeneratedAsIdentityColumnConstraint</span> -</span><span id="Generator-707"><a href="#Generator-707"><span class="linenos"> 707</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-708"><a href="#Generator-708"><span class="linenos"> 708</span></a> <span class="n">this</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator-709"><a href="#Generator-709"><span class="linenos"> 709</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Generator-710"><a href="#Generator-710"><span class="linenos"> 710</span></a> <span class="n">on_null</span> <span class="o">=</span> <span class="s2">" ON NULL"</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">"on_null"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-711"><a href="#Generator-711"><span class="linenos"> 711</span></a> <span class="n">this</span> <span class="o">=</span> <span class="s2">" ALWAYS"</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="sa">f</span><span class="s2">" BY DEFAULT</span><span class="si">{</span><span class="n">on_null</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-712"><a href="#Generator-712"><span class="linenos"> 712</span></a> -</span><span id="Generator-713"><a href="#Generator-713"><span class="linenos"> 713</span></a> <span class="n">start</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">"start"</span><span class="p">)</span> -</span><span id="Generator-714"><a href="#Generator-714"><span class="linenos"> 714</span></a> <span class="n">start</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"START WITH </span><span class="si">{</span><span class="n">start</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">start</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-715"><a href="#Generator-715"><span class="linenos"> 715</span></a> <span class="n">increment</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">"increment"</span><span class="p">)</span> -</span><span id="Generator-716"><a href="#Generator-716"><span class="linenos"> 716</span></a> <span class="n">increment</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" INCREMENT BY </span><span class="si">{</span><span class="n">increment</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">increment</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-717"><a href="#Generator-717"><span class="linenos"> 717</span></a> <span class="n">minvalue</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">"minvalue"</span><span class="p">)</span> -</span><span id="Generator-718"><a href="#Generator-718"><span class="linenos"> 718</span></a> <span class="n">minvalue</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" MINVALUE </span><span class="si">{</span><span class="n">minvalue</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">minvalue</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-719"><a href="#Generator-719"><span class="linenos"> 719</span></a> <span class="n">maxvalue</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">"maxvalue"</span><span class="p">)</span> -</span><span id="Generator-720"><a href="#Generator-720"><span class="linenos"> 720</span></a> <span class="n">maxvalue</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" MAXVALUE </span><span class="si">{</span><span class="n">maxvalue</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">maxvalue</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-721"><a href="#Generator-721"><span class="linenos"> 721</span></a> <span class="n">cycle</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">"cycle"</span><span class="p">)</span> -</span><span id="Generator-722"><a href="#Generator-722"><span class="linenos"> 722</span></a> <span class="n">cycle_sql</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator-723"><a href="#Generator-723"><span class="linenos"> 723</span></a> -</span><span id="Generator-724"><a href="#Generator-724"><span class="linenos"> 724</span></a> <span class="k">if</span> <span class="n">cycle</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Generator-725"><a href="#Generator-725"><span class="linenos"> 725</span></a> <span class="n">cycle_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="s1">' NO'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="ow">not</span><span class="w"> </span><span class="n">cycle</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"> CYCLE"</span> -</span><span id="Generator-726"><a href="#Generator-726"><span class="linenos"> 726</span></a> <span class="n">cycle_sql</span> <span class="o">=</span> <span class="n">cycle_sql</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> <span class="k">if</span> <span class="ow">not</span> <span class="n">start</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">increment</span> <span class="k">else</span> <span class="n">cycle_sql</span> -</span><span id="Generator-727"><a href="#Generator-727"><span class="linenos"> 727</span></a> -</span><span id="Generator-728"><a href="#Generator-728"><span class="linenos"> 728</span></a> <span class="n">sequence_opts</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator-729"><a href="#Generator-729"><span class="linenos"> 729</span></a> <span class="k">if</span> <span class="n">start</span> <span class="ow">or</span> <span class="n">increment</span> <span class="ow">or</span> <span class="n">cycle_sql</span><span class="p">:</span> -</span><span id="Generator-730"><a href="#Generator-730"><span class="linenos"> 730</span></a> <span class="n">sequence_opts</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">start</span><span class="si">}{</span><span class="n">increment</span><span class="si">}{</span><span class="n">minvalue</span><span class="si">}{</span><span class="n">maxvalue</span><span class="si">}{</span><span class="n">cycle_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-731"><a href="#Generator-731"><span class="linenos"> 731</span></a> <span class="n">sequence_opts</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" (</span><span class="si">{</span><span class="n">sequence_opts</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-732"><a href="#Generator-732"><span class="linenos"> 732</span></a> -</span><span id="Generator-733"><a href="#Generator-733"><span class="linenos"> 733</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-734"><a href="#Generator-734"><span class="linenos"> 734</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">expr</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">expr</span> <span class="k">else</span> <span class="s2">"IDENTITY"</span> +</span><span id="Generator-697"><a href="#Generator-697"><span class="linenos"> 697</span></a> <span class="k">def</span> <span class="nf">autoincrementcolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">_</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-698"><a href="#Generator-698"><span class="linenos"> 698</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">token_sql</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">AUTO_INCREMENT</span><span class="p">)</span> +</span><span id="Generator-699"><a href="#Generator-699"><span class="linenos"> 699</span></a> +</span><span id="Generator-700"><a href="#Generator-700"><span class="linenos"> 700</span></a> <span class="k">def</span> <span class="nf">compresscolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">CompressColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-701"><a href="#Generator-701"><span class="linenos"> 701</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">this</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span> +</span><span id="Generator-702"><a href="#Generator-702"><span class="linenos"> 702</span></a> <span class="n">this</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="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">"this"</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-703"><a href="#Generator-703"><span class="linenos"> 703</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator-704"><a href="#Generator-704"><span class="linenos"> 704</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-705"><a href="#Generator-705"><span class="linenos"> 705</span></a> +</span><span id="Generator-706"><a href="#Generator-706"><span class="linenos"> 706</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"COMPRESS </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-707"><a href="#Generator-707"><span class="linenos"> 707</span></a> +</span><span id="Generator-708"><a href="#Generator-708"><span class="linenos"> 708</span></a> <span class="k">def</span> <span class="nf">generatedasidentitycolumnconstraint_sql</span><span class="p">(</span> +</span><span id="Generator-709"><a href="#Generator-709"><span class="linenos"> 709</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GeneratedAsIdentityColumnConstraint</span> +</span><span id="Generator-710"><a href="#Generator-710"><span class="linenos"> 710</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-711"><a href="#Generator-711"><span class="linenos"> 711</span></a> <span class="n">this</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator-712"><a href="#Generator-712"><span class="linenos"> 712</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Generator-713"><a href="#Generator-713"><span class="linenos"> 713</span></a> <span class="n">on_null</span> <span class="o">=</span> <span class="s2">" ON NULL"</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">"on_null"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-714"><a href="#Generator-714"><span class="linenos"> 714</span></a> <span class="n">this</span> <span class="o">=</span> <span class="s2">" ALWAYS"</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="sa">f</span><span class="s2">" BY DEFAULT</span><span class="si">{</span><span class="n">on_null</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-715"><a href="#Generator-715"><span class="linenos"> 715</span></a> +</span><span id="Generator-716"><a href="#Generator-716"><span class="linenos"> 716</span></a> <span class="n">start</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">"start"</span><span class="p">)</span> +</span><span id="Generator-717"><a href="#Generator-717"><span class="linenos"> 717</span></a> <span class="n">start</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"START WITH </span><span class="si">{</span><span class="n">start</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">start</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-718"><a href="#Generator-718"><span class="linenos"> 718</span></a> <span class="n">increment</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">"increment"</span><span class="p">)</span> +</span><span id="Generator-719"><a href="#Generator-719"><span class="linenos"> 719</span></a> <span class="n">increment</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" INCREMENT BY </span><span class="si">{</span><span class="n">increment</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">increment</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-720"><a href="#Generator-720"><span class="linenos"> 720</span></a> <span class="n">minvalue</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">"minvalue"</span><span class="p">)</span> +</span><span id="Generator-721"><a href="#Generator-721"><span class="linenos"> 721</span></a> <span class="n">minvalue</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" MINVALUE </span><span class="si">{</span><span class="n">minvalue</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">minvalue</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-722"><a href="#Generator-722"><span class="linenos"> 722</span></a> <span class="n">maxvalue</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">"maxvalue"</span><span class="p">)</span> +</span><span id="Generator-723"><a href="#Generator-723"><span class="linenos"> 723</span></a> <span class="n">maxvalue</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" MAXVALUE </span><span class="si">{</span><span class="n">maxvalue</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">maxvalue</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-724"><a href="#Generator-724"><span class="linenos"> 724</span></a> <span class="n">cycle</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">"cycle"</span><span class="p">)</span> +</span><span id="Generator-725"><a href="#Generator-725"><span class="linenos"> 725</span></a> <span class="n">cycle_sql</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator-726"><a href="#Generator-726"><span class="linenos"> 726</span></a> +</span><span id="Generator-727"><a href="#Generator-727"><span class="linenos"> 727</span></a> <span class="k">if</span> <span class="n">cycle</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Generator-728"><a href="#Generator-728"><span class="linenos"> 728</span></a> <span class="n">cycle_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="s1">' NO'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="ow">not</span><span class="w"> </span><span class="n">cycle</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"> CYCLE"</span> +</span><span id="Generator-729"><a href="#Generator-729"><span class="linenos"> 729</span></a> <span class="n">cycle_sql</span> <span class="o">=</span> <span class="n">cycle_sql</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> <span class="k">if</span> <span class="ow">not</span> <span class="n">start</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">increment</span> <span class="k">else</span> <span class="n">cycle_sql</span> +</span><span id="Generator-730"><a href="#Generator-730"><span class="linenos"> 730</span></a> +</span><span id="Generator-731"><a href="#Generator-731"><span class="linenos"> 731</span></a> <span class="n">sequence_opts</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator-732"><a href="#Generator-732"><span class="linenos"> 732</span></a> <span class="k">if</span> <span class="n">start</span> <span class="ow">or</span> <span class="n">increment</span> <span class="ow">or</span> <span class="n">cycle_sql</span><span class="p">:</span> +</span><span id="Generator-733"><a href="#Generator-733"><span class="linenos"> 733</span></a> <span class="n">sequence_opts</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">start</span><span class="si">}{</span><span class="n">increment</span><span class="si">}{</span><span class="n">minvalue</span><span class="si">}{</span><span class="n">maxvalue</span><span class="si">}{</span><span class="n">cycle_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-734"><a href="#Generator-734"><span class="linenos"> 734</span></a> <span class="n">sequence_opts</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" (</span><span class="si">{</span><span class="n">sequence_opts</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-735"><a href="#Generator-735"><span class="linenos"> 735</span></a> -</span><span id="Generator-736"><a href="#Generator-736"><span class="linenos"> 736</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"GENERATED</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> AS </span><span class="si">{</span><span class="n">expr</span><span class="si">}{</span><span class="n">sequence_opts</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-737"><a href="#Generator-737"><span class="linenos"> 737</span></a> -</span><span id="Generator-738"><a href="#Generator-738"><span class="linenos"> 738</span></a> <span class="k">def</span> <span class="nf">generatedasrowcolumnconstraint_sql</span><span class="p">(</span> -</span><span id="Generator-739"><a href="#Generator-739"><span class="linenos"> 739</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GeneratedAsRowColumnConstraint</span> -</span><span id="Generator-740"><a href="#Generator-740"><span class="linenos"> 740</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-741"><a href="#Generator-741"><span class="linenos"> 741</span></a> <span class="n">start</span> <span class="o">=</span> <span class="s2">"START"</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">"start"</span><span class="p">]</span> <span class="k">else</span> <span class="s2">"END"</span> -</span><span id="Generator-742"><a href="#Generator-742"><span class="linenos"> 742</span></a> <span class="n">hidden</span> <span class="o">=</span> <span class="s2">" HIDDEN"</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">"hidden"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-743"><a href="#Generator-743"><span class="linenos"> 743</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"GENERATED ALWAYS AS ROW </span><span class="si">{</span><span class="n">start</span><span class="si">}{</span><span class="n">hidden</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-744"><a href="#Generator-744"><span class="linenos"> 744</span></a> -</span><span id="Generator-745"><a href="#Generator-745"><span class="linenos"> 745</span></a> <span class="k">def</span> <span class="nf">periodforsystemtimeconstraint_sql</span><span class="p">(</span> -</span><span id="Generator-746"><a href="#Generator-746"><span class="linenos"> 746</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">PeriodForSystemTimeConstraint</span> -</span><span id="Generator-747"><a href="#Generator-747"><span class="linenos"> 747</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-748"><a href="#Generator-748"><span class="linenos"> 748</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PERIOD FOR SYSTEM_TIME (</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-749"><a href="#Generator-749"><span class="linenos"> 749</span></a> -</span><span id="Generator-750"><a href="#Generator-750"><span class="linenos"> 750</span></a> <span class="k">def</span> <span class="nf">notnullcolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">NotNullColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-751"><a href="#Generator-751"><span class="linenos"> 751</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="s1">''</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">'allow_null'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">'NOT '</span><span class="si">}</span><span class="s2">NULL"</span> +</span><span id="Generator-736"><a href="#Generator-736"><span class="linenos"> 736</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-737"><a href="#Generator-737"><span class="linenos"> 737</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">expr</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">expr</span> <span class="k">else</span> <span class="s2">"IDENTITY"</span> +</span><span id="Generator-738"><a href="#Generator-738"><span class="linenos"> 738</span></a> +</span><span id="Generator-739"><a href="#Generator-739"><span class="linenos"> 739</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"GENERATED</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> AS </span><span class="si">{</span><span class="n">expr</span><span class="si">}{</span><span class="n">sequence_opts</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-740"><a href="#Generator-740"><span class="linenos"> 740</span></a> +</span><span id="Generator-741"><a href="#Generator-741"><span class="linenos"> 741</span></a> <span class="k">def</span> <span class="nf">generatedasrowcolumnconstraint_sql</span><span class="p">(</span> +</span><span id="Generator-742"><a href="#Generator-742"><span class="linenos"> 742</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GeneratedAsRowColumnConstraint</span> +</span><span id="Generator-743"><a href="#Generator-743"><span class="linenos"> 743</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-744"><a href="#Generator-744"><span class="linenos"> 744</span></a> <span class="n">start</span> <span class="o">=</span> <span class="s2">"START"</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">"start"</span><span class="p">]</span> <span class="k">else</span> <span class="s2">"END"</span> +</span><span id="Generator-745"><a href="#Generator-745"><span class="linenos"> 745</span></a> <span class="n">hidden</span> <span class="o">=</span> <span class="s2">" HIDDEN"</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">"hidden"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-746"><a href="#Generator-746"><span class="linenos"> 746</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"GENERATED ALWAYS AS ROW </span><span class="si">{</span><span class="n">start</span><span class="si">}{</span><span class="n">hidden</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-747"><a href="#Generator-747"><span class="linenos"> 747</span></a> +</span><span id="Generator-748"><a href="#Generator-748"><span class="linenos"> 748</span></a> <span class="k">def</span> <span class="nf">periodforsystemtimeconstraint_sql</span><span class="p">(</span> +</span><span id="Generator-749"><a href="#Generator-749"><span class="linenos"> 749</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">PeriodForSystemTimeConstraint</span> +</span><span id="Generator-750"><a href="#Generator-750"><span class="linenos"> 750</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-751"><a href="#Generator-751"><span class="linenos"> 751</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PERIOD FOR SYSTEM_TIME (</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-752"><a href="#Generator-752"><span class="linenos"> 752</span></a> -</span><span id="Generator-753"><a href="#Generator-753"><span class="linenos"> 753</span></a> <span class="k">def</span> <span class="nf">transformcolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TransformColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-754"><a href="#Generator-754"><span class="linenos"> 754</span></a> <span class="k">return</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">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-753"><a href="#Generator-753"><span class="linenos"> 753</span></a> <span class="k">def</span> <span class="nf">notnullcolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">NotNullColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-754"><a href="#Generator-754"><span class="linenos"> 754</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="s1">''</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">'allow_null'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">'NOT '</span><span class="si">}</span><span class="s2">NULL"</span> </span><span id="Generator-755"><a href="#Generator-755"><span class="linenos"> 755</span></a> -</span><span id="Generator-756"><a href="#Generator-756"><span class="linenos"> 756</span></a> <span class="k">def</span> <span class="nf">primarykeycolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">PrimaryKeyColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-757"><a href="#Generator-757"><span class="linenos"> 757</span></a> <span class="n">desc</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">"desc"</span><span class="p">)</span> -</span><span id="Generator-758"><a href="#Generator-758"><span class="linenos"> 758</span></a> <span class="k">if</span> <span class="n">desc</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Generator-759"><a href="#Generator-759"><span class="linenos"> 759</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PRIMARY KEY</span><span class="si">{</span><span class="s1">' DESC'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">desc</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">' ASC'</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-760"><a href="#Generator-760"><span class="linenos"> 760</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PRIMARY KEY"</span> -</span><span id="Generator-761"><a href="#Generator-761"><span class="linenos"> 761</span></a> -</span><span id="Generator-762"><a href="#Generator-762"><span class="linenos"> 762</span></a> <span class="k">def</span> <span class="nf">uniquecolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">UniqueColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-763"><a href="#Generator-763"><span class="linenos"> 763</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-764"><a href="#Generator-764"><span class="linenos"> 764</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-765"><a href="#Generator-765"><span class="linenos"> 765</span></a> <span class="n">index_type</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">"index_type"</span><span class="p">)</span> -</span><span id="Generator-766"><a href="#Generator-766"><span class="linenos"> 766</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-767"><a href="#Generator-767"><span class="linenos"> 767</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"UNIQUE</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="s2">"</span> -</span><span id="Generator-768"><a href="#Generator-768"><span class="linenos"> 768</span></a> -</span><span id="Generator-769"><a href="#Generator-769"><span class="linenos"> 769</span></a> <span class="k">def</span> <span class="nf">createable_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">,</span> <span class="n">locations</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">DefaultDict</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-770"><a href="#Generator-770"><span class="linenos"> 770</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">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-756"><a href="#Generator-756"><span class="linenos"> 756</span></a> <span class="k">def</span> <span class="nf">transformcolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TransformColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-757"><a href="#Generator-757"><span class="linenos"> 757</span></a> <span class="k">return</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">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-758"><a href="#Generator-758"><span class="linenos"> 758</span></a> +</span><span id="Generator-759"><a href="#Generator-759"><span class="linenos"> 759</span></a> <span class="k">def</span> <span class="nf">primarykeycolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">PrimaryKeyColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-760"><a href="#Generator-760"><span class="linenos"> 760</span></a> <span class="n">desc</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">"desc"</span><span class="p">)</span> +</span><span id="Generator-761"><a href="#Generator-761"><span class="linenos"> 761</span></a> <span class="k">if</span> <span class="n">desc</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Generator-762"><a href="#Generator-762"><span class="linenos"> 762</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PRIMARY KEY</span><span class="si">{</span><span class="s1">' DESC'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">desc</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">' ASC'</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-763"><a href="#Generator-763"><span class="linenos"> 763</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PRIMARY KEY"</span> +</span><span id="Generator-764"><a href="#Generator-764"><span class="linenos"> 764</span></a> +</span><span id="Generator-765"><a href="#Generator-765"><span class="linenos"> 765</span></a> <span class="k">def</span> <span class="nf">uniquecolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">UniqueColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-766"><a href="#Generator-766"><span class="linenos"> 766</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-767"><a href="#Generator-767"><span class="linenos"> 767</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-768"><a href="#Generator-768"><span class="linenos"> 768</span></a> <span class="n">index_type</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">"index_type"</span><span class="p">)</span> +</span><span id="Generator-769"><a href="#Generator-769"><span class="linenos"> 769</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-770"><a href="#Generator-770"><span class="linenos"> 770</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"UNIQUE</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="s2">"</span> </span><span id="Generator-771"><a href="#Generator-771"><span class="linenos"> 771</span></a> -</span><span id="Generator-772"><a href="#Generator-772"><span class="linenos"> 772</span></a> <span class="k">def</span> <span class="nf">create_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-773"><a href="#Generator-773"><span class="linenos"> 773</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 class="o">.</span><span class="n">upper</span><span class="p">()</span> -</span><span id="Generator-774"><a href="#Generator-774"><span class="linenos"> 774</span></a> <span class="n">properties</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">"properties"</span><span class="p">)</span> -</span><span id="Generator-775"><a href="#Generator-775"><span class="linenos"> 775</span></a> <span class="n">properties_locs</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">locate_properties</span><span class="p">(</span><span class="n">properties</span><span class="p">)</span> <span class="k">if</span> <span class="n">properties</span> <span class="k">else</span> <span class="n">defaultdict</span><span class="p">()</span> -</span><span id="Generator-776"><a href="#Generator-776"><span class="linenos"> 776</span></a> -</span><span id="Generator-777"><a href="#Generator-777"><span class="linenos"> 777</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">createable_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">properties_locs</span><span class="p">)</span> -</span><span id="Generator-778"><a href="#Generator-778"><span class="linenos"> 778</span></a> -</span><span id="Generator-779"><a href="#Generator-779"><span class="linenos"> 779</span></a> <span class="n">properties_sql</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator-780"><a href="#Generator-780"><span class="linenos"> 780</span></a> <span class="k">if</span> <span class="n">properties_locs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">)</span> <span class="ow">or</span> <span class="n">properties_locs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span> -</span><span id="Generator-781"><a href="#Generator-781"><span class="linenos"> 781</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span> -</span><span id="Generator-782"><a href="#Generator-782"><span class="linenos"> 782</span></a> <span class="p">):</span> -</span><span id="Generator-783"><a href="#Generator-783"><span class="linenos"> 783</span></a> <span class="n">properties_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><span id="Generator-784"><a href="#Generator-784"><span class="linenos"> 784</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span> -</span><span id="Generator-785"><a href="#Generator-785"><span class="linenos"> 785</span></a> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span> -</span><span id="Generator-786"><a href="#Generator-786"><span class="linenos"> 786</span></a> <span class="o">*</span><span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">],</span> -</span><span id="Generator-787"><a href="#Generator-787"><span class="linenos"> 787</span></a> <span class="o">*</span><span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">],</span> -</span><span id="Generator-788"><a href="#Generator-788"><span class="linenos"> 788</span></a> <span class="p">]</span> -</span><span id="Generator-789"><a href="#Generator-789"><span class="linenos"> 789</span></a> <span class="p">)</span> -</span><span id="Generator-790"><a href="#Generator-790"><span class="linenos"> 790</span></a> <span class="p">)</span> -</span><span id="Generator-791"><a href="#Generator-791"><span class="linenos"> 791</span></a> -</span><span id="Generator-792"><a href="#Generator-792"><span class="linenos"> 792</span></a> <span class="n">begin</span> <span class="o">=</span> <span class="s2">" BEGIN"</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">"begin"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-793"><a href="#Generator-793"><span class="linenos"> 793</span></a> <span class="n">end</span> <span class="o">=</span> <span class="s2">" END"</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">"end"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-772"><a href="#Generator-772"><span class="linenos"> 772</span></a> <span class="k">def</span> <span class="nf">createable_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">,</span> <span class="n">locations</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">DefaultDict</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-773"><a href="#Generator-773"><span class="linenos"> 773</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">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-774"><a href="#Generator-774"><span class="linenos"> 774</span></a> +</span><span id="Generator-775"><a href="#Generator-775"><span class="linenos"> 775</span></a> <span class="k">def</span> <span class="nf">create_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-776"><a href="#Generator-776"><span class="linenos"> 776</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 class="o">.</span><span class="n">upper</span><span class="p">()</span> +</span><span id="Generator-777"><a href="#Generator-777"><span class="linenos"> 777</span></a> <span class="n">properties</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">"properties"</span><span class="p">)</span> +</span><span id="Generator-778"><a href="#Generator-778"><span class="linenos"> 778</span></a> <span class="n">properties_locs</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">locate_properties</span><span class="p">(</span><span class="n">properties</span><span class="p">)</span> <span class="k">if</span> <span class="n">properties</span> <span class="k">else</span> <span class="n">defaultdict</span><span class="p">()</span> +</span><span id="Generator-779"><a href="#Generator-779"><span class="linenos"> 779</span></a> +</span><span id="Generator-780"><a href="#Generator-780"><span class="linenos"> 780</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">createable_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">properties_locs</span><span class="p">)</span> +</span><span id="Generator-781"><a href="#Generator-781"><span class="linenos"> 781</span></a> +</span><span id="Generator-782"><a href="#Generator-782"><span class="linenos"> 782</span></a> <span class="n">properties_sql</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator-783"><a href="#Generator-783"><span class="linenos"> 783</span></a> <span class="k">if</span> <span class="n">properties_locs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">)</span> <span class="ow">or</span> <span class="n">properties_locs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span> +</span><span id="Generator-784"><a href="#Generator-784"><span class="linenos"> 784</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span> +</span><span id="Generator-785"><a href="#Generator-785"><span class="linenos"> 785</span></a> <span class="p">):</span> +</span><span id="Generator-786"><a href="#Generator-786"><span class="linenos"> 786</span></a> <span class="n">properties_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><span id="Generator-787"><a href="#Generator-787"><span class="linenos"> 787</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span> +</span><span id="Generator-788"><a href="#Generator-788"><span class="linenos"> 788</span></a> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span> +</span><span id="Generator-789"><a href="#Generator-789"><span class="linenos"> 789</span></a> <span class="o">*</span><span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">],</span> +</span><span id="Generator-790"><a href="#Generator-790"><span class="linenos"> 790</span></a> <span class="o">*</span><span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">],</span> +</span><span id="Generator-791"><a href="#Generator-791"><span class="linenos"> 791</span></a> <span class="p">]</span> +</span><span id="Generator-792"><a href="#Generator-792"><span class="linenos"> 792</span></a> <span class="p">)</span> +</span><span id="Generator-793"><a href="#Generator-793"><span class="linenos"> 793</span></a> <span class="p">)</span> </span><span id="Generator-794"><a href="#Generator-794"><span class="linenos"> 794</span></a> -</span><span id="Generator-795"><a href="#Generator-795"><span class="linenos"> 795</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-796"><a href="#Generator-796"><span class="linenos"> 796</span></a> <span class="k">if</span> <span class="n">expression_sql</span><span class="p">:</span> -</span><span id="Generator-797"><a href="#Generator-797"><span class="linenos"> 797</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">begin</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="n">expression_sql</span><span class="si">}{</span><span class="n">end</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-798"><a href="#Generator-798"><span class="linenos"> 798</span></a> -</span><span id="Generator-799"><a href="#Generator-799"><span class="linenos"> 799</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">CREATE_FUNCTION_RETURN_AS</span> <span class="ow">or</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">Return</span><span class="p">):</span> -</span><span id="Generator-800"><a href="#Generator-800"><span class="linenos"> 800</span></a> <span class="k">if</span> <span class="n">properties_locs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_ALIAS</span><span class="p">):</span> -</span><span id="Generator-801"><a href="#Generator-801"><span class="linenos"> 801</span></a> <span class="n">postalias_props_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span> -</span><span id="Generator-802"><a href="#Generator-802"><span class="linenos"> 802</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span> -</span><span id="Generator-803"><a href="#Generator-803"><span class="linenos"> 803</span></a> <span class="n">expressions</span><span class="o">=</span><span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_ALIAS</span><span class="p">]</span> -</span><span id="Generator-804"><a href="#Generator-804"><span class="linenos"> 804</span></a> <span class="p">),</span> -</span><span id="Generator-805"><a href="#Generator-805"><span class="linenos"> 805</span></a> <span class="n">wrapped</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> -</span><span id="Generator-806"><a href="#Generator-806"><span class="linenos"> 806</span></a> <span class="p">)</span> -</span><span id="Generator-807"><a href="#Generator-807"><span class="linenos"> 807</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="n">postalias_props_sql</span><span class="si">}{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-808"><a href="#Generator-808"><span class="linenos"> 808</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator-809"><a href="#Generator-809"><span class="linenos"> 809</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS</span><span class="si">{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-810"><a href="#Generator-810"><span class="linenos"> 810</span></a> -</span><span id="Generator-811"><a href="#Generator-811"><span class="linenos"> 811</span></a> <span class="n">postindex_props_sql</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator-812"><a href="#Generator-812"><span class="linenos"> 812</span></a> <span class="k">if</span> <span class="n">properties_locs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_INDEX</span><span class="p">):</span> -</span><span id="Generator-813"><a href="#Generator-813"><span class="linenos"> 813</span></a> <span class="n">postindex_props_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span> -</span><span id="Generator-814"><a href="#Generator-814"><span class="linenos"> 814</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_INDEX</span><span class="p">]),</span> -</span><span id="Generator-815"><a href="#Generator-815"><span class="linenos"> 815</span></a> <span class="n">wrapped</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> -</span><span id="Generator-816"><a href="#Generator-816"><span class="linenos"> 816</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> -</span><span id="Generator-817"><a href="#Generator-817"><span class="linenos"> 817</span></a> <span class="p">)</span> -</span><span id="Generator-818"><a href="#Generator-818"><span class="linenos"> 818</span></a> -</span><span id="Generator-819"><a href="#Generator-819"><span class="linenos"> 819</span></a> <span class="n">indexes</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">"indexes"</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="kc">False</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-820"><a href="#Generator-820"><span class="linenos"> 820</span></a> <span class="n">indexes</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">indexes</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">indexes</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-821"><a href="#Generator-821"><span class="linenos"> 821</span></a> <span class="n">index_sql</span> <span class="o">=</span> <span class="n">indexes</span> <span class="o">+</span> <span class="n">postindex_props_sql</span> -</span><span id="Generator-822"><a href="#Generator-822"><span class="linenos"> 822</span></a> -</span><span id="Generator-823"><a href="#Generator-823"><span class="linenos"> 823</span></a> <span class="n">replace</span> <span class="o">=</span> <span class="s2">" OR REPLACE"</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">"replace"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-824"><a href="#Generator-824"><span class="linenos"> 824</span></a> <span class="n">unique</span> <span class="o">=</span> <span class="s2">" UNIQUE"</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">"unique"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-795"><a href="#Generator-795"><span class="linenos"> 795</span></a> <span class="n">begin</span> <span class="o">=</span> <span class="s2">" BEGIN"</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">"begin"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-796"><a href="#Generator-796"><span class="linenos"> 796</span></a> <span class="n">end</span> <span class="o">=</span> <span class="s2">" END"</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">"end"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-797"><a href="#Generator-797"><span class="linenos"> 797</span></a> +</span><span id="Generator-798"><a href="#Generator-798"><span class="linenos"> 798</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-799"><a href="#Generator-799"><span class="linenos"> 799</span></a> <span class="k">if</span> <span class="n">expression_sql</span><span class="p">:</span> +</span><span id="Generator-800"><a href="#Generator-800"><span class="linenos"> 800</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">begin</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="n">expression_sql</span><span class="si">}{</span><span class="n">end</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-801"><a href="#Generator-801"><span class="linenos"> 801</span></a> +</span><span id="Generator-802"><a href="#Generator-802"><span class="linenos"> 802</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">CREATE_FUNCTION_RETURN_AS</span> <span class="ow">or</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">Return</span><span class="p">):</span> +</span><span id="Generator-803"><a href="#Generator-803"><span class="linenos"> 803</span></a> <span class="k">if</span> <span class="n">properties_locs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_ALIAS</span><span class="p">):</span> +</span><span id="Generator-804"><a href="#Generator-804"><span class="linenos"> 804</span></a> <span class="n">postalias_props_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span> +</span><span id="Generator-805"><a href="#Generator-805"><span class="linenos"> 805</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span> +</span><span id="Generator-806"><a href="#Generator-806"><span class="linenos"> 806</span></a> <span class="n">expressions</span><span class="o">=</span><span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_ALIAS</span><span class="p">]</span> +</span><span id="Generator-807"><a href="#Generator-807"><span class="linenos"> 807</span></a> <span class="p">),</span> +</span><span id="Generator-808"><a href="#Generator-808"><span class="linenos"> 808</span></a> <span class="n">wrapped</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> +</span><span id="Generator-809"><a href="#Generator-809"><span class="linenos"> 809</span></a> <span class="p">)</span> +</span><span id="Generator-810"><a href="#Generator-810"><span class="linenos"> 810</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="n">postalias_props_sql</span><span class="si">}{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-811"><a href="#Generator-811"><span class="linenos"> 811</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator-812"><a href="#Generator-812"><span class="linenos"> 812</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS</span><span class="si">{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-813"><a href="#Generator-813"><span class="linenos"> 813</span></a> +</span><span id="Generator-814"><a href="#Generator-814"><span class="linenos"> 814</span></a> <span class="n">postindex_props_sql</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator-815"><a href="#Generator-815"><span class="linenos"> 815</span></a> <span class="k">if</span> <span class="n">properties_locs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_INDEX</span><span class="p">):</span> +</span><span id="Generator-816"><a href="#Generator-816"><span class="linenos"> 816</span></a> <span class="n">postindex_props_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span> +</span><span id="Generator-817"><a href="#Generator-817"><span class="linenos"> 817</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_INDEX</span><span class="p">]),</span> +</span><span id="Generator-818"><a href="#Generator-818"><span class="linenos"> 818</span></a> <span class="n">wrapped</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> +</span><span id="Generator-819"><a href="#Generator-819"><span class="linenos"> 819</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> +</span><span id="Generator-820"><a href="#Generator-820"><span class="linenos"> 820</span></a> <span class="p">)</span> +</span><span id="Generator-821"><a href="#Generator-821"><span class="linenos"> 821</span></a> +</span><span id="Generator-822"><a href="#Generator-822"><span class="linenos"> 822</span></a> <span class="n">indexes</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">"indexes"</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="kc">False</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-823"><a href="#Generator-823"><span class="linenos"> 823</span></a> <span class="n">indexes</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">indexes</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">indexes</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-824"><a href="#Generator-824"><span class="linenos"> 824</span></a> <span class="n">index_sql</span> <span class="o">=</span> <span class="n">indexes</span> <span class="o">+</span> <span class="n">postindex_props_sql</span> </span><span id="Generator-825"><a href="#Generator-825"><span class="linenos"> 825</span></a> -</span><span id="Generator-826"><a href="#Generator-826"><span class="linenos"> 826</span></a> <span class="n">postcreate_props_sql</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator-827"><a href="#Generator-827"><span class="linenos"> 827</span></a> <span class="k">if</span> <span class="n">properties_locs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">):</span> -</span><span id="Generator-828"><a href="#Generator-828"><span class="linenos"> 828</span></a> <span class="n">postcreate_props_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span> -</span><span id="Generator-829"><a href="#Generator-829"><span class="linenos"> 829</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">]),</span> -</span><span id="Generator-830"><a href="#Generator-830"><span class="linenos"> 830</span></a> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> -</span><span id="Generator-831"><a href="#Generator-831"><span class="linenos"> 831</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> -</span><span id="Generator-832"><a href="#Generator-832"><span class="linenos"> 832</span></a> <span class="n">wrapped</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> -</span><span id="Generator-833"><a href="#Generator-833"><span class="linenos"> 833</span></a> <span class="p">)</span> -</span><span id="Generator-834"><a href="#Generator-834"><span class="linenos"> 834</span></a> -</span><span id="Generator-835"><a href="#Generator-835"><span class="linenos"> 835</span></a> <span class="n">modifiers</span> <span class="o">=</span> <span class="s2">""</span><span class="o">.</span><span class="n">join</span><span class="p">((</span><span class="n">replace</span><span class="p">,</span> <span class="n">unique</span><span class="p">,</span> <span class="n">postcreate_props_sql</span><span class="p">))</span> -</span><span id="Generator-836"><a href="#Generator-836"><span class="linenos"> 836</span></a> -</span><span id="Generator-837"><a href="#Generator-837"><span class="linenos"> 837</span></a> <span class="n">postexpression_props_sql</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator-838"><a href="#Generator-838"><span class="linenos"> 838</span></a> <span class="k">if</span> <span class="n">properties_locs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_EXPRESSION</span><span class="p">):</span> -</span><span id="Generator-839"><a href="#Generator-839"><span class="linenos"> 839</span></a> <span class="n">postexpression_props_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span> -</span><span id="Generator-840"><a href="#Generator-840"><span class="linenos"> 840</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span> -</span><span id="Generator-841"><a href="#Generator-841"><span class="linenos"> 841</span></a> <span class="n">expressions</span><span class="o">=</span><span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_EXPRESSION</span><span class="p">]</span> -</span><span id="Generator-842"><a href="#Generator-842"><span class="linenos"> 842</span></a> <span class="p">),</span> -</span><span id="Generator-843"><a href="#Generator-843"><span class="linenos"> 843</span></a> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> -</span><span id="Generator-844"><a href="#Generator-844"><span class="linenos"> 844</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> -</span><span id="Generator-845"><a href="#Generator-845"><span class="linenos"> 845</span></a> <span class="n">wrapped</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> -</span><span id="Generator-846"><a href="#Generator-846"><span class="linenos"> 846</span></a> <span class="p">)</span> -</span><span id="Generator-847"><a href="#Generator-847"><span class="linenos"> 847</span></a> -</span><span id="Generator-848"><a href="#Generator-848"><span class="linenos"> 848</span></a> <span class="n">exists_sql</span> <span class="o">=</span> <span class="s2">" IF NOT 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-849"><a href="#Generator-849"><span class="linenos"> 849</span></a> <span class="n">no_schema_binding</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Generator-850"><a href="#Generator-850"><span class="linenos"> 850</span></a> <span class="s2">" WITH NO SCHEMA BINDING"</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">"no_schema_binding"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-851"><a href="#Generator-851"><span class="linenos"> 851</span></a> <span class="p">)</span> -</span><span id="Generator-852"><a href="#Generator-852"><span class="linenos"> 852</span></a> -</span><span id="Generator-853"><a href="#Generator-853"><span class="linenos"> 853</span></a> <span class="n">clone</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"clone"</span><span class="p">)</span> -</span><span id="Generator-854"><a href="#Generator-854"><span class="linenos"> 854</span></a> <span class="n">clone</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">clone</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">clone</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-826"><a href="#Generator-826"><span class="linenos"> 826</span></a> <span class="n">replace</span> <span class="o">=</span> <span class="s2">" OR REPLACE"</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">"replace"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-827"><a href="#Generator-827"><span class="linenos"> 827</span></a> <span class="n">unique</span> <span class="o">=</span> <span class="s2">" UNIQUE"</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">"unique"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-828"><a href="#Generator-828"><span class="linenos"> 828</span></a> +</span><span id="Generator-829"><a href="#Generator-829"><span class="linenos"> 829</span></a> <span class="n">postcreate_props_sql</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator-830"><a href="#Generator-830"><span class="linenos"> 830</span></a> <span class="k">if</span> <span class="n">properties_locs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">):</span> +</span><span id="Generator-831"><a href="#Generator-831"><span class="linenos"> 831</span></a> <span class="n">postcreate_props_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span> +</span><span id="Generator-832"><a href="#Generator-832"><span class="linenos"> 832</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">]),</span> +</span><span id="Generator-833"><a href="#Generator-833"><span class="linenos"> 833</span></a> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> +</span><span id="Generator-834"><a href="#Generator-834"><span class="linenos"> 834</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> +</span><span id="Generator-835"><a href="#Generator-835"><span class="linenos"> 835</span></a> <span class="n">wrapped</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> +</span><span id="Generator-836"><a href="#Generator-836"><span class="linenos"> 836</span></a> <span class="p">)</span> +</span><span id="Generator-837"><a href="#Generator-837"><span class="linenos"> 837</span></a> +</span><span id="Generator-838"><a href="#Generator-838"><span class="linenos"> 838</span></a> <span class="n">modifiers</span> <span class="o">=</span> <span class="s2">""</span><span class="o">.</span><span class="n">join</span><span class="p">((</span><span class="n">replace</span><span class="p">,</span> <span class="n">unique</span><span class="p">,</span> <span class="n">postcreate_props_sql</span><span class="p">))</span> +</span><span id="Generator-839"><a href="#Generator-839"><span class="linenos"> 839</span></a> +</span><span id="Generator-840"><a href="#Generator-840"><span class="linenos"> 840</span></a> <span class="n">postexpression_props_sql</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator-841"><a href="#Generator-841"><span class="linenos"> 841</span></a> <span class="k">if</span> <span class="n">properties_locs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_EXPRESSION</span><span class="p">):</span> +</span><span id="Generator-842"><a href="#Generator-842"><span class="linenos"> 842</span></a> <span class="n">postexpression_props_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span> +</span><span id="Generator-843"><a href="#Generator-843"><span class="linenos"> 843</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span> +</span><span id="Generator-844"><a href="#Generator-844"><span class="linenos"> 844</span></a> <span class="n">expressions</span><span class="o">=</span><span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_EXPRESSION</span><span class="p">]</span> +</span><span id="Generator-845"><a href="#Generator-845"><span class="linenos"> 845</span></a> <span class="p">),</span> +</span><span id="Generator-846"><a href="#Generator-846"><span class="linenos"> 846</span></a> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> +</span><span id="Generator-847"><a href="#Generator-847"><span class="linenos"> 847</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> +</span><span id="Generator-848"><a href="#Generator-848"><span class="linenos"> 848</span></a> <span class="n">wrapped</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> +</span><span id="Generator-849"><a href="#Generator-849"><span class="linenos"> 849</span></a> <span class="p">)</span> +</span><span id="Generator-850"><a href="#Generator-850"><span class="linenos"> 850</span></a> +</span><span id="Generator-851"><a href="#Generator-851"><span class="linenos"> 851</span></a> <span class="n">exists_sql</span> <span class="o">=</span> <span class="s2">" IF NOT 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-852"><a href="#Generator-852"><span class="linenos"> 852</span></a> <span class="n">no_schema_binding</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Generator-853"><a href="#Generator-853"><span class="linenos"> 853</span></a> <span class="s2">" WITH NO SCHEMA BINDING"</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">"no_schema_binding"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-854"><a href="#Generator-854"><span class="linenos"> 854</span></a> <span class="p">)</span> </span><span id="Generator-855"><a href="#Generator-855"><span class="linenos"> 855</span></a> -</span><span id="Generator-856"><a href="#Generator-856"><span class="linenos"> 856</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"CREATE</span><span class="si">{</span><span class="n">modifiers</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">exists_sql</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">properties_sql</span><span class="si">}{</span><span class="n">expression_sql</span><span class="si">}{</span><span class="n">postexpression_props_sql</span><span class="si">}{</span><span class="n">index_sql</span><span class="si">}{</span><span class="n">no_schema_binding</span><span class="si">}{</span><span class="n">clone</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-857"><a href="#Generator-857"><span class="linenos"> 857</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">expression_sql</span><span class="p">)</span> +</span><span id="Generator-856"><a href="#Generator-856"><span class="linenos"> 856</span></a> <span class="n">clone</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"clone"</span><span class="p">)</span> +</span><span id="Generator-857"><a href="#Generator-857"><span class="linenos"> 857</span></a> <span class="n">clone</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">clone</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">clone</span> <span class="k">else</span> <span class="s2">""</span> </span><span id="Generator-858"><a href="#Generator-858"><span class="linenos"> 858</span></a> -</span><span id="Generator-859"><a href="#Generator-859"><span class="linenos"> 859</span></a> <span class="k">def</span> <span class="nf">clone_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Clone</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-860"><a href="#Generator-860"><span class="linenos"> 860</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-861"><a href="#Generator-861"><span class="linenos"> 861</span></a> <span class="n">shallow</span> <span class="o">=</span> <span class="s2">"SHALLOW "</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">"shallow"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-862"><a href="#Generator-862"><span class="linenos"> 862</span></a> <span class="n">keyword</span> <span class="o">=</span> <span class="s2">"COPY"</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">"copy"</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">SUPPORTS_TABLE_COPY</span> <span class="k">else</span> <span class="s2">"CLONE"</span> -</span><span id="Generator-863"><a href="#Generator-863"><span class="linenos"> 863</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">shallow</span><span class="si">}{</span><span class="n">keyword</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">"</span> -</span><span id="Generator-864"><a href="#Generator-864"><span class="linenos"> 864</span></a> <span class="n">when</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"when"</span><span class="p">)</span> -</span><span id="Generator-865"><a href="#Generator-865"><span class="linenos"> 865</span></a> -</span><span id="Generator-866"><a href="#Generator-866"><span class="linenos"> 866</span></a> <span class="k">if</span> <span class="n">when</span><span class="p">:</span> -</span><span id="Generator-867"><a href="#Generator-867"><span class="linenos"> 867</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-868"><a href="#Generator-868"><span class="linenos"> 868</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-869"><a href="#Generator-869"><span class="linenos"> 869</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">when</span><span class="si">}</span><span class="s2"> (</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">expr</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Generator-859"><a href="#Generator-859"><span class="linenos"> 859</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"CREATE</span><span class="si">{</span><span class="n">modifiers</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">exists_sql</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">properties_sql</span><span class="si">}{</span><span class="n">expression_sql</span><span class="si">}{</span><span class="n">postexpression_props_sql</span><span class="si">}{</span><span class="n">index_sql</span><span class="si">}{</span><span class="n">no_schema_binding</span><span class="si">}{</span><span class="n">clone</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-860"><a href="#Generator-860"><span class="linenos"> 860</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">expression_sql</span><span class="p">)</span> +</span><span id="Generator-861"><a href="#Generator-861"><span class="linenos"> 861</span></a> +</span><span id="Generator-862"><a href="#Generator-862"><span class="linenos"> 862</span></a> <span class="k">def</span> <span class="nf">clone_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Clone</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-863"><a href="#Generator-863"><span class="linenos"> 863</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-864"><a href="#Generator-864"><span class="linenos"> 864</span></a> <span class="n">shallow</span> <span class="o">=</span> <span class="s2">"SHALLOW "</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">"shallow"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-865"><a href="#Generator-865"><span class="linenos"> 865</span></a> <span class="n">keyword</span> <span class="o">=</span> <span class="s2">"COPY"</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">"copy"</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">SUPPORTS_TABLE_COPY</span> <span class="k">else</span> <span class="s2">"CLONE"</span> +</span><span id="Generator-866"><a href="#Generator-866"><span class="linenos"> 866</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">shallow</span><span class="si">}{</span><span class="n">keyword</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">"</span> +</span><span id="Generator-867"><a href="#Generator-867"><span class="linenos"> 867</span></a> +</span><span id="Generator-868"><a href="#Generator-868"><span class="linenos"> 868</span></a> <span class="k">def</span> <span class="nf">describe_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Describe</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-869"><a href="#Generator-869"><span class="linenos"> 869</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"DESCRIBE </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-870"><a href="#Generator-870"><span class="linenos"> 870</span></a> -</span><span id="Generator-871"><a href="#Generator-871"><span class="linenos"> 871</span></a> <span class="k">return</span> <span class="n">this</span> -</span><span id="Generator-872"><a href="#Generator-872"><span class="linenos"> 872</span></a> -</span><span id="Generator-873"><a href="#Generator-873"><span class="linenos"> 873</span></a> <span class="k">def</span> <span class="nf">describe_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Describe</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-874"><a href="#Generator-874"><span class="linenos"> 874</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"DESCRIBE </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-875"><a href="#Generator-875"><span class="linenos"> 875</span></a> -</span><span id="Generator-876"><a href="#Generator-876"><span class="linenos"> 876</span></a> <span class="k">def</span> <span class="nf">prepend_ctes</span><span class="p">(</span><span class="bp">self</span><span 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">sql</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-877"><a href="#Generator-877"><span class="linenos"> 877</span></a> <span class="n">with_</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"with"</span><span class="p">)</span> -</span><span id="Generator-878"><a href="#Generator-878"><span class="linenos"> 878</span></a> <span class="k">if</span> <span class="n">with_</span><span class="p">:</span> -</span><span id="Generator-879"><a href="#Generator-879"><span class="linenos"> 879</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">with_</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="n">sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-880"><a href="#Generator-880"><span class="linenos"> 880</span></a> <span class="k">return</span> <span class="n">sql</span> -</span><span id="Generator-881"><a href="#Generator-881"><span class="linenos"> 881</span></a> -</span><span id="Generator-882"><a href="#Generator-882"><span class="linenos"> 882</span></a> <span class="k">def</span> <span class="nf">with_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">With</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-883"><a href="#Generator-883"><span class="linenos"> 883</span></a> <span class="n">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="kc">True</span><span class="p">)</span> -</span><span id="Generator-884"><a href="#Generator-884"><span class="linenos"> 884</span></a> <span class="n">recursive</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Generator-885"><a href="#Generator-885"><span class="linenos"> 885</span></a> <span class="s2">"RECURSIVE "</span> -</span><span id="Generator-886"><a href="#Generator-886"><span class="linenos"> 886</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">CTE_RECURSIVE_KEYWORD_REQUIRED</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">"recursive"</span><span class="p">)</span> -</span><span id="Generator-887"><a href="#Generator-887"><span class="linenos"> 887</span></a> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-888"><a href="#Generator-888"><span class="linenos"> 888</span></a> <span class="p">)</span> -</span><span id="Generator-889"><a href="#Generator-889"><span class="linenos"> 889</span></a> -</span><span id="Generator-890"><a href="#Generator-890"><span class="linenos"> 890</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"WITH </span><span class="si">{</span><span class="n">recursive</span><span class="si">}{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-891"><a href="#Generator-891"><span class="linenos"> 891</span></a> -</span><span id="Generator-892"><a href="#Generator-892"><span class="linenos"> 892</span></a> <span class="k">def</span> <span class="nf">cte_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">CTE</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-893"><a href="#Generator-893"><span class="linenos"> 893</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-894"><a href="#Generator-894"><span class="linenos"> 894</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">alias</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">wrap</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-871"><a href="#Generator-871"><span class="linenos"> 871</span></a> <span class="k">def</span> <span class="nf">prepend_ctes</span><span class="p">(</span><span class="bp">self</span><span 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">sql</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-872"><a href="#Generator-872"><span class="linenos"> 872</span></a> <span class="n">with_</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"with"</span><span class="p">)</span> +</span><span id="Generator-873"><a href="#Generator-873"><span class="linenos"> 873</span></a> <span class="k">if</span> <span class="n">with_</span><span class="p">:</span> +</span><span id="Generator-874"><a href="#Generator-874"><span class="linenos"> 874</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">with_</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="n">sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-875"><a href="#Generator-875"><span class="linenos"> 875</span></a> <span class="k">return</span> <span class="n">sql</span> +</span><span id="Generator-876"><a href="#Generator-876"><span class="linenos"> 876</span></a> +</span><span id="Generator-877"><a href="#Generator-877"><span class="linenos"> 877</span></a> <span class="k">def</span> <span class="nf">with_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">With</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-878"><a href="#Generator-878"><span class="linenos"> 878</span></a> <span class="n">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="kc">True</span><span class="p">)</span> +</span><span id="Generator-879"><a href="#Generator-879"><span class="linenos"> 879</span></a> <span class="n">recursive</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Generator-880"><a href="#Generator-880"><span class="linenos"> 880</span></a> <span class="s2">"RECURSIVE "</span> +</span><span id="Generator-881"><a href="#Generator-881"><span class="linenos"> 881</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">CTE_RECURSIVE_KEYWORD_REQUIRED</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">"recursive"</span><span class="p">)</span> +</span><span id="Generator-882"><a href="#Generator-882"><span class="linenos"> 882</span></a> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-883"><a href="#Generator-883"><span class="linenos"> 883</span></a> <span class="p">)</span> +</span><span id="Generator-884"><a href="#Generator-884"><span class="linenos"> 884</span></a> +</span><span id="Generator-885"><a href="#Generator-885"><span class="linenos"> 885</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"WITH </span><span class="si">{</span><span class="n">recursive</span><span class="si">}{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-886"><a href="#Generator-886"><span class="linenos"> 886</span></a> +</span><span id="Generator-887"><a href="#Generator-887"><span class="linenos"> 887</span></a> <span class="k">def</span> <span class="nf">cte_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">CTE</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-888"><a href="#Generator-888"><span class="linenos"> 888</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-889"><a href="#Generator-889"><span class="linenos"> 889</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">alias</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">wrap</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-890"><a href="#Generator-890"><span class="linenos"> 890</span></a> +</span><span id="Generator-891"><a href="#Generator-891"><span class="linenos"> 891</span></a> <span class="k">def</span> <span class="nf">tablealias_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TableAlias</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-892"><a href="#Generator-892"><span class="linenos"> 892</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">"this"</span><span class="p">)</span> +</span><span id="Generator-893"><a href="#Generator-893"><span class="linenos"> 893</span></a> <span class="n">columns</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">"columns"</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-894"><a href="#Generator-894"><span class="linenos"> 894</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">columns</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">columns</span> <span class="k">else</span> <span class="s2">""</span> </span><span id="Generator-895"><a href="#Generator-895"><span class="linenos"> 895</span></a> -</span><span id="Generator-896"><a href="#Generator-896"><span class="linenos"> 896</span></a> <span class="k">def</span> <span class="nf">tablealias_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TableAlias</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-897"><a href="#Generator-897"><span class="linenos"> 897</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">"this"</span><span class="p">)</span> -</span><span id="Generator-898"><a href="#Generator-898"><span class="linenos"> 898</span></a> <span class="n">columns</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">"columns"</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-899"><a href="#Generator-899"><span class="linenos"> 899</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">columns</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">columns</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-896"><a href="#Generator-896"><span class="linenos"> 896</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">alias</span> <span class="ow">and</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">UNNEST_COLUMN_ONLY</span><span class="p">:</span> +</span><span id="Generator-897"><a href="#Generator-897"><span class="linenos"> 897</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="s2">"_t"</span> +</span><span id="Generator-898"><a href="#Generator-898"><span class="linenos"> 898</span></a> +</span><span id="Generator-899"><a href="#Generator-899"><span class="linenos"> 899</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">alias</span><span class="si">}{</span><span class="n">columns</span><span class="si">}</span><span class="s2">"</span> </span><span id="Generator-900"><a href="#Generator-900"><span class="linenos"> 900</span></a> -</span><span id="Generator-901"><a href="#Generator-901"><span class="linenos"> 901</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">alias</span> <span class="ow">and</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">UNNEST_COLUMN_ONLY</span><span class="p">:</span> -</span><span id="Generator-902"><a href="#Generator-902"><span class="linenos"> 902</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="s2">"_t"</span> -</span><span id="Generator-903"><a href="#Generator-903"><span class="linenos"> 903</span></a> -</span><span id="Generator-904"><a href="#Generator-904"><span class="linenos"> 904</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">alias</span><span class="si">}{</span><span class="n">columns</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-905"><a href="#Generator-905"><span class="linenos"> 905</span></a> -</span><span id="Generator-906"><a href="#Generator-906"><span class="linenos"> 906</span></a> <span class="k">def</span> <span class="nf">bitstring_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">BitString</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-907"><a href="#Generator-907"><span class="linenos"> 907</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-908"><a href="#Generator-908"><span class="linenos"> 908</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">BIT_START</span><span class="p">:</span> -</span><span id="Generator-909"><a href="#Generator-909"><span class="linenos"> 909</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">dialect</span><span class="o">.</span><span class="n">BIT_START</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">BIT_END</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-910"><a href="#Generator-910"><span class="linenos"> 910</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="nb">int</span><span class="p">(</span><span class="n">this</span><span class="p">,</span><span class="w"> </span><span class="mi">2</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-911"><a href="#Generator-911"><span class="linenos"> 911</span></a> -</span><span id="Generator-912"><a href="#Generator-912"><span class="linenos"> 912</span></a> <span class="k">def</span> <span class="nf">hexstring_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">HexString</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-913"><a href="#Generator-913"><span class="linenos"> 913</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-914"><a href="#Generator-914"><span class="linenos"> 914</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">HEX_START</span><span class="p">:</span> -</span><span id="Generator-915"><a href="#Generator-915"><span class="linenos"> 915</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">dialect</span><span class="o">.</span><span class="n">HEX_START</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">HEX_END</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-916"><a href="#Generator-916"><span class="linenos"> 916</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="nb">int</span><span class="p">(</span><span class="n">this</span><span class="p">,</span><span class="w"> </span><span class="mi">16</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-917"><a href="#Generator-917"><span class="linenos"> 917</span></a> -</span><span id="Generator-918"><a href="#Generator-918"><span class="linenos"> 918</span></a> <span class="k">def</span> <span class="nf">bytestring_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ByteString</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-919"><a href="#Generator-919"><span class="linenos"> 919</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-920"><a href="#Generator-920"><span class="linenos"> 920</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">BYTE_START</span><span class="p">:</span> -</span><span id="Generator-921"><a href="#Generator-921"><span class="linenos"> 921</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">dialect</span><span class="o">.</span><span class="n">BYTE_START</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">BYTE_END</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-922"><a href="#Generator-922"><span class="linenos"> 922</span></a> <span class="k">return</span> <span class="n">this</span> -</span><span id="Generator-923"><a href="#Generator-923"><span class="linenos"> 923</span></a> -</span><span id="Generator-924"><a href="#Generator-924"><span class="linenos"> 924</span></a> <span class="k">def</span> <span class="nf">rawstring_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RawString</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-925"><a href="#Generator-925"><span class="linenos"> 925</span></a> <span class="n">string</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">escape_str</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">"</span><span class="se">\\</span><span class="s2">"</span><span class="p">,</span> <span class="s2">"</span><span class="se">\\\\</span><span class="s2">"</span><span class="p">))</span> -</span><span id="Generator-926"><a href="#Generator-926"><span class="linenos"> 926</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">dialect</span><span class="o">.</span><span class="n">QUOTE_START</span><span class="si">}{</span><span class="n">string</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">QUOTE_END</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-927"><a href="#Generator-927"><span class="linenos"> 927</span></a> -</span><span id="Generator-928"><a href="#Generator-928"><span class="linenos"> 928</span></a> <span class="k">def</span> <span class="nf">datatypeparam_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataTypeParam</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-929"><a href="#Generator-929"><span class="linenos"> 929</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-930"><a href="#Generator-930"><span class="linenos"> 930</span></a> <span class="n">specifier</span> <span class="o">=</span> <span class="bp">self</span><span 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-931"><a href="#Generator-931"><span class="linenos"> 931</span></a> <span class="n">specifier</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">specifier</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">specifier</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">DATA_TYPE_SPECIFIERS_ALLOWED</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-932"><a href="#Generator-932"><span class="linenos"> 932</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">specifier</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-933"><a href="#Generator-933"><span class="linenos"> 933</span></a> -</span><span id="Generator-934"><a href="#Generator-934"><span class="linenos"> 934</span></a> <span class="k">def</span> <span class="nf">datatype_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-935"><a href="#Generator-935"><span class="linenos"> 935</span></a> <span class="n">type_value</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> -</span><span id="Generator-936"><a href="#Generator-936"><span class="linenos"> 936</span></a> -</span><span id="Generator-937"><a href="#Generator-937"><span class="linenos"> 937</span></a> <span class="k">if</span> <span class="n">type_value</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">USERDEFINED</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">"kind"</span><span class="p">):</span> -</span><span id="Generator-938"><a href="#Generator-938"><span class="linenos"> 938</span></a> <span class="n">type_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">"kind"</span><span class="p">)</span> -</span><span id="Generator-939"><a href="#Generator-939"><span class="linenos"> 939</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator-940"><a href="#Generator-940"><span class="linenos"> 940</span></a> <span class="n">type_sql</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Generator-941"><a href="#Generator-941"><span class="linenos"> 941</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">TYPE_MAPPING</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">type_value</span><span class="p">,</span> <span class="n">type_value</span><span class="o">.</span><span class="n">value</span><span class="p">)</span> -</span><span id="Generator-942"><a href="#Generator-942"><span class="linenos"> 942</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">type_value</span><span class="p">,</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="p">)</span> -</span><span id="Generator-943"><a href="#Generator-943"><span class="linenos"> 943</span></a> <span class="k">else</span> <span class="n">type_value</span> -</span><span id="Generator-944"><a href="#Generator-944"><span class="linenos"> 944</span></a> <span class="p">)</span> -</span><span id="Generator-945"><a href="#Generator-945"><span class="linenos"> 945</span></a> -</span><span id="Generator-946"><a href="#Generator-946"><span class="linenos"> 946</span></a> <span class="n">nested</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator-947"><a href="#Generator-947"><span class="linenos"> 947</span></a> <span class="n">interior</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-948"><a href="#Generator-948"><span class="linenos"> 948</span></a> <span class="n">values</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator-949"><a href="#Generator-949"><span class="linenos"> 949</span></a> -</span><span id="Generator-950"><a href="#Generator-950"><span class="linenos"> 950</span></a> <span class="k">if</span> <span class="n">interior</span><span class="p">:</span> -</span><span id="Generator-951"><a href="#Generator-951"><span class="linenos"> 951</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">"nested"</span><span class="p">):</span> -</span><span id="Generator-952"><a href="#Generator-952"><span class="linenos"> 952</span></a> <span class="n">nested</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">STRUCT_DELIMITER</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="si">}{</span><span class="n">interior</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">STRUCT_DELIMITER</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-953"><a href="#Generator-953"><span class="linenos"> 953</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">"values"</span><span class="p">)</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Generator-954"><a href="#Generator-954"><span class="linenos"> 954</span></a> <span class="n">delimiters</span> <span class="o">=</span> <span class="p">(</span><span class="s2">"["</span><span class="p">,</span> <span class="s2">"]"</span><span class="p">)</span> <span class="k">if</span> <span class="n">type_value</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">ARRAY</span> <span class="k">else</span> <span class="p">(</span><span class="s2">"("</span><span class="p">,</span> <span class="s2">")"</span><span class="p">)</span> -</span><span id="Generator-955"><a href="#Generator-955"><span class="linenos"> 955</span></a> <span class="n">values</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">"values"</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-956"><a href="#Generator-956"><span class="linenos"> 956</span></a> <span class="n">values</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">delimiters</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="si">}{</span><span class="n">values</span><span class="si">}{</span><span class="n">delimiters</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-957"><a href="#Generator-957"><span class="linenos"> 957</span></a> <span class="k">elif</span> <span class="n">type_value</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">INTERVAL</span><span class="p">:</span> -</span><span id="Generator-958"><a href="#Generator-958"><span class="linenos"> 958</span></a> <span class="n">nested</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">interior</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-959"><a href="#Generator-959"><span class="linenos"> 959</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator-960"><a href="#Generator-960"><span class="linenos"> 960</span></a> <span class="n">nested</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">interior</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="Generator-961"><a href="#Generator-961"><span class="linenos"> 961</span></a> -</span><span id="Generator-962"><a href="#Generator-962"><span class="linenos"> 962</span></a> <span class="n">type_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">type_sql</span><span class="si">}{</span><span class="n">nested</span><span class="si">}{</span><span class="n">values</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-963"><a href="#Generator-963"><span class="linenos"> 963</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">TZ_TO_WITH_TIME_ZONE</span> <span class="ow">and</span> <span class="n">type_value</span> <span class="ow">in</span> <span class="p">(</span> -</span><span id="Generator-964"><a href="#Generator-964"><span class="linenos"> 964</span></a> <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">TIMETZ</span><span class="p">,</span> -</span><span id="Generator-965"><a href="#Generator-965"><span class="linenos"> 965</span></a> <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">TIMESTAMPTZ</span><span class="p">,</span> -</span><span id="Generator-966"><a href="#Generator-966"><span class="linenos"> 966</span></a> <span class="p">):</span> -</span><span id="Generator-967"><a href="#Generator-967"><span class="linenos"> 967</span></a> <span class="n">type_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">type_sql</span><span class="si">}</span><span class="s2"> WITH TIME ZONE"</span> -</span><span id="Generator-968"><a href="#Generator-968"><span class="linenos"> 968</span></a> -</span><span id="Generator-969"><a href="#Generator-969"><span class="linenos"> 969</span></a> <span class="k">return</span> <span class="n">type_sql</span> -</span><span id="Generator-970"><a href="#Generator-970"><span class="linenos"> 970</span></a> -</span><span id="Generator-971"><a href="#Generator-971"><span class="linenos"> 971</span></a> <span class="k">def</span> <span class="nf">directory_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Directory</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-972"><a href="#Generator-972"><span class="linenos"> 972</span></a> <span class="n">local</span> <span class="o">=</span> <span class="s2">"LOCAL "</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">"local"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-973"><a href="#Generator-973"><span class="linenos"> 973</span></a> <span class="n">row_format</span> <span class="o">=</span> <span class="bp">self</span><span 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"</span><span class="p">)</span> -</span><span id="Generator-974"><a href="#Generator-974"><span class="linenos"> 974</span></a> <span class="n">row_format</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">row_format</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">row_format</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-975"><a href="#Generator-975"><span class="linenos"> 975</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">local</span><span class="si">}</span><span class="s2">DIRECTORY </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">row_format</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-976"><a href="#Generator-976"><span class="linenos"> 976</span></a> -</span><span id="Generator-977"><a href="#Generator-977"><span class="linenos"> 977</span></a> <span class="k">def</span> <span class="nf">delete_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Delete</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-978"><a href="#Generator-978"><span class="linenos"> 978</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-979"><a href="#Generator-979"><span class="linenos"> 979</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" FROM </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-980"><a href="#Generator-980"><span class="linenos"> 980</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-981"><a href="#Generator-981"><span class="linenos"> 981</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-982"><a href="#Generator-982"><span class="linenos"> 982</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-983"><a href="#Generator-983"><span class="linenos"> 983</span></a> <span class="n">returning</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"returning"</span><span class="p">)</span> -</span><span id="Generator-984"><a href="#Generator-984"><span class="linenos"> 984</span></a> <span class="n">limit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"limit"</span><span class="p">)</span> -</span><span id="Generator-985"><a href="#Generator-985"><span class="linenos"> 985</span></a> <span class="n">tables</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">"tables"</span><span class="p">)</span> -</span><span id="Generator-986"><a href="#Generator-986"><span class="linenos"> 986</span></a> <span class="n">tables</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">tables</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">tables</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-987"><a href="#Generator-987"><span class="linenos"> 987</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">RETURNING_END</span><span class="p">:</span> -</span><span id="Generator-988"><a href="#Generator-988"><span class="linenos"> 988</span></a> <span class="n">expression_sql</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="n">using</span><span class="si">}{</span><span class="n">where</span><span class="si">}{</span><span class="n">returning</span><span class="si">}{</span><span class="n">limit</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-989"><a href="#Generator-989"><span class="linenos"> 989</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator-990"><a href="#Generator-990"><span class="linenos"> 990</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">returning</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="n">using</span><span class="si">}{</span><span class="n">where</span><span class="si">}{</span><span class="n">limit</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-991"><a href="#Generator-991"><span class="linenos"> 991</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="sa">f</span><span class="s2">"DELETE</span><span class="si">{</span><span class="n">tables</span><span class="si">}{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="Generator-992"><a href="#Generator-992"><span class="linenos"> 992</span></a> -</span><span id="Generator-993"><a href="#Generator-993"><span class="linenos"> 993</span></a> <span class="k">def</span> <span class="nf">drop_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Drop</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-994"><a href="#Generator-994"><span class="linenos"> 994</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-995"><a href="#Generator-995"><span class="linenos"> 995</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-996"><a href="#Generator-996"><span class="linenos"> 996</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-997"><a href="#Generator-997"><span class="linenos"> 997</span></a> <span class="n">temporary</span> <span class="o">=</span> <span class="s2">" TEMPORARY"</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">"temporary"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-998"><a href="#Generator-998"><span class="linenos"> 998</span></a> <span class="n">materialized</span> <span class="o">=</span> <span class="s2">" MATERIALIZED"</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">"materialized"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-999"><a href="#Generator-999"><span class="linenos"> 999</span></a> <span class="n">cascade</span> <span class="o">=</span> <span class="s2">" CASCADE"</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">"cascade"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1000"><a href="#Generator-1000"><span class="linenos">1000</span></a> <span class="n">constraints</span> <span class="o">=</span> <span class="s2">" CONSTRAINTS"</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">"constraints"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1001"><a href="#Generator-1001"><span class="linenos">1001</span></a> <span class="n">purge</span> <span class="o">=</span> <span class="s2">" PURGE"</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">"purge"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1002"><a href="#Generator-1002"><span class="linenos">1002</span></a> <span class="k">return</span> <span class="p">(</span> -</span><span id="Generator-1003"><a href="#Generator-1003"><span class="linenos">1003</span></a> <span class="sa">f</span><span class="s2">"DROP</span><span class="si">{</span><span class="n">temporary</span><span class="si">}{</span><span class="n">materialized</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">exists_sql</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="n">cascade</span><span class="si">}{</span><span class="n">constraints</span><span class="si">}{</span><span class="n">purge</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1004"><a href="#Generator-1004"><span class="linenos">1004</span></a> <span class="p">)</span> -</span><span id="Generator-1005"><a href="#Generator-1005"><span class="linenos">1005</span></a> -</span><span id="Generator-1006"><a href="#Generator-1006"><span class="linenos">1006</span></a> <span class="k">def</span> <span class="nf">except_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Except</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1007"><a href="#Generator-1007"><span class="linenos">1007</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><span id="Generator-1008"><a href="#Generator-1008"><span class="linenos">1008</span></a> <span class="n">expression</span><span class="p">,</span> -</span><span id="Generator-1009"><a href="#Generator-1009"><span class="linenos">1009</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">set_operation</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">except_op</span><span class="p">(</span><span class="n">expression</span><span class="p">)),</span> -</span><span id="Generator-1010"><a href="#Generator-1010"><span class="linenos">1010</span></a> <span class="p">)</span> -</span><span id="Generator-1011"><a href="#Generator-1011"><span class="linenos">1011</span></a> -</span><span id="Generator-1012"><a href="#Generator-1012"><span class="linenos">1012</span></a> <span class="k">def</span> <span class="nf">except_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Except</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1013"><a href="#Generator-1013"><span class="linenos">1013</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"EXCEPT</span><span class="si">{</span><span class="s1">''</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">'distinct'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">' ALL'</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1014"><a href="#Generator-1014"><span class="linenos">1014</span></a> -</span><span id="Generator-1015"><a href="#Generator-1015"><span class="linenos">1015</span></a> <span class="k">def</span> <span class="nf">fetch_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1016"><a href="#Generator-1016"><span class="linenos">1016</span></a> <span class="n">direction</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">"direction"</span><span class="p">)</span> -</span><span id="Generator-1017"><a href="#Generator-1017"><span class="linenos">1017</span></a> <span class="n">direction</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">direction</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">direction</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1018"><a href="#Generator-1018"><span class="linenos">1018</span></a> <span class="n">count</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">"count"</span><span class="p">)</span> -</span><span id="Generator-1019"><a href="#Generator-1019"><span class="linenos">1019</span></a> <span class="n">count</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">count</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">count</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1020"><a href="#Generator-1020"><span class="linenos">1020</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">"percent"</span><span class="p">):</span> -</span><span id="Generator-1021"><a href="#Generator-1021"><span class="linenos">1021</span></a> <span class="n">count</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">count</span><span class="si">}</span><span class="s2"> PERCENT"</span> -</span><span id="Generator-1022"><a href="#Generator-1022"><span class="linenos">1022</span></a> <span class="n">with_ties_or_only</span> <span class="o">=</span> <span class="s2">"WITH TIES"</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">"with_ties"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">"ONLY"</span> -</span><span id="Generator-1023"><a href="#Generator-1023"><span class="linenos">1023</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="s1">'FETCH'</span><span class="p">)</span><span class="si">}{</span><span class="n">direction</span><span class="si">}{</span><span class="n">count</span><span class="si">}</span><span class="s2"> ROWS </span><span class="si">{</span><span class="n">with_ties_or_only</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1024"><a href="#Generator-1024"><span class="linenos">1024</span></a> -</span><span id="Generator-1025"><a href="#Generator-1025"><span class="linenos">1025</span></a> <span class="k">def</span> <span class="nf">filter_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Filter</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1026"><a href="#Generator-1026"><span class="linenos">1026</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">AGGREGATE_FILTER_SUPPORTED</span><span class="p">:</span> -</span><span id="Generator-1027"><a href="#Generator-1027"><span class="linenos">1027</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-1028"><a href="#Generator-1028"><span class="linenos">1028</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">"expression"</span><span class="p">)</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> -</span><span id="Generator-1029"><a href="#Generator-1029"><span class="linenos">1029</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"> FILTER(</span><span class="si">{</span><span class="n">where</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="Generator-1030"><a href="#Generator-1030"><span class="linenos">1030</span></a> -</span><span id="Generator-1031"><a href="#Generator-1031"><span class="linenos">1031</span></a> <span class="n">agg</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> -</span><span id="Generator-1032"><a href="#Generator-1032"><span class="linenos">1032</span></a> <span class="n">agg_arg</span> <span class="o">=</span> <span class="n">agg</span><span class="o">.</span><span class="n">this</span> -</span><span id="Generator-1033"><a href="#Generator-1033"><span class="linenos">1033</span></a> <span class="n">cond</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">this</span> -</span><span id="Generator-1034"><a href="#Generator-1034"><span class="linenos">1034</span></a> <span class="n">agg_arg</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">If</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">cond</span><span class="o">.</span><span class="n">copy</span><span class="p">(),</span> <span class="n">true</span><span class="o">=</span><span class="n">agg_arg</span><span class="o">.</span><span class="n">copy</span><span class="p">()))</span> -</span><span id="Generator-1035"><a href="#Generator-1035"><span class="linenos">1035</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">agg</span><span class="p">)</span> +</span><span id="Generator-901"><a href="#Generator-901"><span class="linenos"> 901</span></a> <span class="k">def</span> <span class="nf">bitstring_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">BitString</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-902"><a href="#Generator-902"><span class="linenos"> 902</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-903"><a href="#Generator-903"><span class="linenos"> 903</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">BIT_START</span><span class="p">:</span> +</span><span id="Generator-904"><a href="#Generator-904"><span class="linenos"> 904</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">dialect</span><span class="o">.</span><span class="n">BIT_START</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">BIT_END</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-905"><a href="#Generator-905"><span class="linenos"> 905</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="nb">int</span><span class="p">(</span><span class="n">this</span><span class="p">,</span><span class="w"> </span><span class="mi">2</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-906"><a href="#Generator-906"><span class="linenos"> 906</span></a> +</span><span id="Generator-907"><a href="#Generator-907"><span class="linenos"> 907</span></a> <span class="k">def</span> <span class="nf">hexstring_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">HexString</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-908"><a href="#Generator-908"><span class="linenos"> 908</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-909"><a href="#Generator-909"><span class="linenos"> 909</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">HEX_START</span><span class="p">:</span> +</span><span id="Generator-910"><a href="#Generator-910"><span class="linenos"> 910</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">dialect</span><span class="o">.</span><span class="n">HEX_START</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">HEX_END</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-911"><a href="#Generator-911"><span class="linenos"> 911</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="nb">int</span><span class="p">(</span><span class="n">this</span><span class="p">,</span><span class="w"> </span><span class="mi">16</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-912"><a href="#Generator-912"><span class="linenos"> 912</span></a> +</span><span id="Generator-913"><a href="#Generator-913"><span class="linenos"> 913</span></a> <span class="k">def</span> <span class="nf">bytestring_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ByteString</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-914"><a href="#Generator-914"><span class="linenos"> 914</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-915"><a href="#Generator-915"><span class="linenos"> 915</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">BYTE_START</span><span class="p">:</span> +</span><span id="Generator-916"><a href="#Generator-916"><span class="linenos"> 916</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">dialect</span><span class="o">.</span><span class="n">BYTE_START</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">BYTE_END</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-917"><a href="#Generator-917"><span class="linenos"> 917</span></a> <span class="k">return</span> <span class="n">this</span> +</span><span id="Generator-918"><a href="#Generator-918"><span class="linenos"> 918</span></a> +</span><span id="Generator-919"><a href="#Generator-919"><span class="linenos"> 919</span></a> <span class="k">def</span> <span class="nf">rawstring_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RawString</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-920"><a href="#Generator-920"><span class="linenos"> 920</span></a> <span class="n">string</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">escape_str</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">"</span><span class="se">\\</span><span class="s2">"</span><span class="p">,</span> <span class="s2">"</span><span class="se">\\\\</span><span class="s2">"</span><span class="p">))</span> +</span><span id="Generator-921"><a href="#Generator-921"><span class="linenos"> 921</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">dialect</span><span class="o">.</span><span class="n">QUOTE_START</span><span class="si">}{</span><span class="n">string</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">QUOTE_END</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-922"><a href="#Generator-922"><span class="linenos"> 922</span></a> +</span><span id="Generator-923"><a href="#Generator-923"><span class="linenos"> 923</span></a> <span class="k">def</span> <span class="nf">datatypeparam_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataTypeParam</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-924"><a href="#Generator-924"><span class="linenos"> 924</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-925"><a href="#Generator-925"><span class="linenos"> 925</span></a> <span class="n">specifier</span> <span class="o">=</span> <span class="bp">self</span><span 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-926"><a href="#Generator-926"><span class="linenos"> 926</span></a> <span class="n">specifier</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">specifier</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">specifier</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">DATA_TYPE_SPECIFIERS_ALLOWED</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-927"><a href="#Generator-927"><span class="linenos"> 927</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">specifier</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-928"><a href="#Generator-928"><span class="linenos"> 928</span></a> +</span><span id="Generator-929"><a href="#Generator-929"><span class="linenos"> 929</span></a> <span class="k">def</span> <span class="nf">datatype_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-930"><a href="#Generator-930"><span class="linenos"> 930</span></a> <span class="n">type_value</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> +</span><span id="Generator-931"><a href="#Generator-931"><span class="linenos"> 931</span></a> +</span><span id="Generator-932"><a href="#Generator-932"><span class="linenos"> 932</span></a> <span class="k">if</span> <span class="n">type_value</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">USERDEFINED</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">"kind"</span><span class="p">):</span> +</span><span id="Generator-933"><a href="#Generator-933"><span class="linenos"> 933</span></a> <span class="n">type_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">"kind"</span><span class="p">)</span> +</span><span id="Generator-934"><a href="#Generator-934"><span class="linenos"> 934</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator-935"><a href="#Generator-935"><span class="linenos"> 935</span></a> <span class="n">type_sql</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Generator-936"><a href="#Generator-936"><span class="linenos"> 936</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">TYPE_MAPPING</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">type_value</span><span class="p">,</span> <span class="n">type_value</span><span class="o">.</span><span class="n">value</span><span class="p">)</span> +</span><span id="Generator-937"><a href="#Generator-937"><span class="linenos"> 937</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">type_value</span><span class="p">,</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="p">)</span> +</span><span id="Generator-938"><a href="#Generator-938"><span class="linenos"> 938</span></a> <span class="k">else</span> <span class="n">type_value</span> +</span><span id="Generator-939"><a href="#Generator-939"><span class="linenos"> 939</span></a> <span class="p">)</span> +</span><span id="Generator-940"><a href="#Generator-940"><span class="linenos"> 940</span></a> +</span><span id="Generator-941"><a href="#Generator-941"><span class="linenos"> 941</span></a> <span class="n">nested</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator-942"><a href="#Generator-942"><span class="linenos"> 942</span></a> <span class="n">interior</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-943"><a href="#Generator-943"><span class="linenos"> 943</span></a> <span class="n">values</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator-944"><a href="#Generator-944"><span class="linenos"> 944</span></a> +</span><span id="Generator-945"><a href="#Generator-945"><span class="linenos"> 945</span></a> <span class="k">if</span> <span class="n">interior</span><span class="p">:</span> +</span><span id="Generator-946"><a href="#Generator-946"><span class="linenos"> 946</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">"nested"</span><span class="p">):</span> +</span><span id="Generator-947"><a href="#Generator-947"><span class="linenos"> 947</span></a> <span class="n">nested</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">STRUCT_DELIMITER</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="si">}{</span><span class="n">interior</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">STRUCT_DELIMITER</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-948"><a href="#Generator-948"><span class="linenos"> 948</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">"values"</span><span class="p">)</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Generator-949"><a href="#Generator-949"><span class="linenos"> 949</span></a> <span class="n">delimiters</span> <span class="o">=</span> <span class="p">(</span><span class="s2">"["</span><span class="p">,</span> <span class="s2">"]"</span><span class="p">)</span> <span class="k">if</span> <span class="n">type_value</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">ARRAY</span> <span class="k">else</span> <span class="p">(</span><span class="s2">"("</span><span class="p">,</span> <span class="s2">")"</span><span class="p">)</span> +</span><span id="Generator-950"><a href="#Generator-950"><span class="linenos"> 950</span></a> <span class="n">values</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">"values"</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-951"><a href="#Generator-951"><span class="linenos"> 951</span></a> <span class="n">values</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">delimiters</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="si">}{</span><span class="n">values</span><span class="si">}{</span><span class="n">delimiters</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-952"><a href="#Generator-952"><span class="linenos"> 952</span></a> <span class="k">elif</span> <span class="n">type_value</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">INTERVAL</span><span class="p">:</span> +</span><span id="Generator-953"><a href="#Generator-953"><span class="linenos"> 953</span></a> <span class="n">nested</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">interior</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-954"><a href="#Generator-954"><span class="linenos"> 954</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator-955"><a href="#Generator-955"><span class="linenos"> 955</span></a> <span class="n">nested</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">interior</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Generator-956"><a href="#Generator-956"><span class="linenos"> 956</span></a> +</span><span id="Generator-957"><a href="#Generator-957"><span class="linenos"> 957</span></a> <span class="n">type_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">type_sql</span><span class="si">}{</span><span class="n">nested</span><span class="si">}{</span><span class="n">values</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-958"><a href="#Generator-958"><span class="linenos"> 958</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">TZ_TO_WITH_TIME_ZONE</span> <span class="ow">and</span> <span class="n">type_value</span> <span class="ow">in</span> <span class="p">(</span> +</span><span id="Generator-959"><a href="#Generator-959"><span class="linenos"> 959</span></a> <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">TIMETZ</span><span class="p">,</span> +</span><span id="Generator-960"><a href="#Generator-960"><span class="linenos"> 960</span></a> <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">TIMESTAMPTZ</span><span class="p">,</span> +</span><span id="Generator-961"><a href="#Generator-961"><span class="linenos"> 961</span></a> <span class="p">):</span> +</span><span id="Generator-962"><a href="#Generator-962"><span class="linenos"> 962</span></a> <span class="n">type_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">type_sql</span><span class="si">}</span><span class="s2"> WITH TIME ZONE"</span> +</span><span id="Generator-963"><a href="#Generator-963"><span class="linenos"> 963</span></a> +</span><span id="Generator-964"><a href="#Generator-964"><span class="linenos"> 964</span></a> <span class="k">return</span> <span class="n">type_sql</span> +</span><span id="Generator-965"><a href="#Generator-965"><span class="linenos"> 965</span></a> +</span><span id="Generator-966"><a href="#Generator-966"><span class="linenos"> 966</span></a> <span class="k">def</span> <span class="nf">directory_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Directory</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-967"><a href="#Generator-967"><span class="linenos"> 967</span></a> <span class="n">local</span> <span class="o">=</span> <span class="s2">"LOCAL "</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">"local"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-968"><a href="#Generator-968"><span class="linenos"> 968</span></a> <span class="n">row_format</span> <span class="o">=</span> <span class="bp">self</span><span 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"</span><span class="p">)</span> +</span><span id="Generator-969"><a href="#Generator-969"><span class="linenos"> 969</span></a> <span class="n">row_format</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">row_format</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">row_format</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-970"><a href="#Generator-970"><span class="linenos"> 970</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">local</span><span class="si">}</span><span class="s2">DIRECTORY </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">row_format</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-971"><a href="#Generator-971"><span class="linenos"> 971</span></a> +</span><span id="Generator-972"><a href="#Generator-972"><span class="linenos"> 972</span></a> <span class="k">def</span> <span class="nf">delete_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Delete</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-973"><a href="#Generator-973"><span class="linenos"> 973</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-974"><a href="#Generator-974"><span class="linenos"> 974</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" FROM </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-975"><a href="#Generator-975"><span class="linenos"> 975</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-976"><a href="#Generator-976"><span class="linenos"> 976</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-977"><a href="#Generator-977"><span class="linenos"> 977</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-978"><a href="#Generator-978"><span class="linenos"> 978</span></a> <span class="n">returning</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"returning"</span><span class="p">)</span> +</span><span id="Generator-979"><a href="#Generator-979"><span class="linenos"> 979</span></a> <span class="n">limit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"limit"</span><span class="p">)</span> +</span><span id="Generator-980"><a href="#Generator-980"><span class="linenos"> 980</span></a> <span class="n">tables</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">"tables"</span><span class="p">)</span> +</span><span id="Generator-981"><a href="#Generator-981"><span class="linenos"> 981</span></a> <span class="n">tables</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">tables</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">tables</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-982"><a href="#Generator-982"><span class="linenos"> 982</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">RETURNING_END</span><span class="p">:</span> +</span><span id="Generator-983"><a href="#Generator-983"><span class="linenos"> 983</span></a> <span class="n">expression_sql</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="n">using</span><span class="si">}{</span><span class="n">where</span><span class="si">}{</span><span class="n">returning</span><span class="si">}{</span><span class="n">limit</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-984"><a href="#Generator-984"><span class="linenos"> 984</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator-985"><a href="#Generator-985"><span class="linenos"> 985</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">returning</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="n">using</span><span class="si">}{</span><span class="n">where</span><span class="si">}{</span><span class="n">limit</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-986"><a href="#Generator-986"><span class="linenos"> 986</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="sa">f</span><span class="s2">"DELETE</span><span class="si">{</span><span class="n">tables</span><span class="si">}{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="Generator-987"><a href="#Generator-987"><span class="linenos"> 987</span></a> +</span><span id="Generator-988"><a href="#Generator-988"><span class="linenos"> 988</span></a> <span class="k">def</span> <span class="nf">drop_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Drop</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-989"><a href="#Generator-989"><span class="linenos"> 989</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-990"><a href="#Generator-990"><span class="linenos"> 990</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-991"><a href="#Generator-991"><span class="linenos"> 991</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-992"><a href="#Generator-992"><span class="linenos"> 992</span></a> <span class="n">temporary</span> <span class="o">=</span> <span class="s2">" TEMPORARY"</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">"temporary"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-993"><a href="#Generator-993"><span class="linenos"> 993</span></a> <span class="n">materialized</span> <span class="o">=</span> <span class="s2">" MATERIALIZED"</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">"materialized"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-994"><a href="#Generator-994"><span class="linenos"> 994</span></a> <span class="n">cascade</span> <span class="o">=</span> <span class="s2">" CASCADE"</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">"cascade"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-995"><a href="#Generator-995"><span class="linenos"> 995</span></a> <span class="n">constraints</span> <span class="o">=</span> <span class="s2">" CONSTRAINTS"</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">"constraints"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-996"><a href="#Generator-996"><span class="linenos"> 996</span></a> <span class="n">purge</span> <span class="o">=</span> <span class="s2">" PURGE"</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">"purge"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-997"><a href="#Generator-997"><span class="linenos"> 997</span></a> <span class="k">return</span> <span class="p">(</span> +</span><span id="Generator-998"><a href="#Generator-998"><span class="linenos"> 998</span></a> <span class="sa">f</span><span class="s2">"DROP</span><span class="si">{</span><span class="n">temporary</span><span class="si">}{</span><span class="n">materialized</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">exists_sql</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="n">cascade</span><span class="si">}{</span><span class="n">constraints</span><span class="si">}{</span><span class="n">purge</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-999"><a href="#Generator-999"><span class="linenos"> 999</span></a> <span class="p">)</span> +</span><span id="Generator-1000"><a href="#Generator-1000"><span class="linenos">1000</span></a> +</span><span id="Generator-1001"><a href="#Generator-1001"><span class="linenos">1001</span></a> <span class="k">def</span> <span class="nf">except_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Except</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1002"><a href="#Generator-1002"><span class="linenos">1002</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><span id="Generator-1003"><a href="#Generator-1003"><span class="linenos">1003</span></a> <span class="n">expression</span><span class="p">,</span> +</span><span id="Generator-1004"><a href="#Generator-1004"><span class="linenos">1004</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">set_operation</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">except_op</span><span class="p">(</span><span class="n">expression</span><span class="p">)),</span> +</span><span id="Generator-1005"><a href="#Generator-1005"><span class="linenos">1005</span></a> <span class="p">)</span> +</span><span id="Generator-1006"><a href="#Generator-1006"><span class="linenos">1006</span></a> +</span><span id="Generator-1007"><a href="#Generator-1007"><span class="linenos">1007</span></a> <span class="k">def</span> <span class="nf">except_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Except</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1008"><a href="#Generator-1008"><span class="linenos">1008</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"EXCEPT</span><span class="si">{</span><span class="s1">''</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">'distinct'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">' ALL'</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1009"><a href="#Generator-1009"><span class="linenos">1009</span></a> +</span><span id="Generator-1010"><a href="#Generator-1010"><span class="linenos">1010</span></a> <span class="k">def</span> <span class="nf">fetch_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1011"><a href="#Generator-1011"><span class="linenos">1011</span></a> <span class="n">direction</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">"direction"</span><span class="p">)</span> +</span><span id="Generator-1012"><a href="#Generator-1012"><span class="linenos">1012</span></a> <span class="n">direction</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">direction</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">direction</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1013"><a href="#Generator-1013"><span class="linenos">1013</span></a> <span class="n">count</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">"count"</span><span class="p">)</span> +</span><span id="Generator-1014"><a href="#Generator-1014"><span class="linenos">1014</span></a> <span class="n">count</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">count</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">count</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1015"><a href="#Generator-1015"><span class="linenos">1015</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">"percent"</span><span class="p">):</span> +</span><span id="Generator-1016"><a href="#Generator-1016"><span class="linenos">1016</span></a> <span class="n">count</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">count</span><span class="si">}</span><span class="s2"> PERCENT"</span> +</span><span id="Generator-1017"><a href="#Generator-1017"><span class="linenos">1017</span></a> <span class="n">with_ties_or_only</span> <span class="o">=</span> <span class="s2">"WITH TIES"</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">"with_ties"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">"ONLY"</span> +</span><span id="Generator-1018"><a href="#Generator-1018"><span class="linenos">1018</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="s1">'FETCH'</span><span class="p">)</span><span class="si">}{</span><span class="n">direction</span><span class="si">}{</span><span class="n">count</span><span class="si">}</span><span class="s2"> ROWS </span><span class="si">{</span><span class="n">with_ties_or_only</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1019"><a href="#Generator-1019"><span class="linenos">1019</span></a> +</span><span id="Generator-1020"><a href="#Generator-1020"><span class="linenos">1020</span></a> <span class="k">def</span> <span class="nf">filter_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Filter</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1021"><a href="#Generator-1021"><span class="linenos">1021</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">AGGREGATE_FILTER_SUPPORTED</span><span class="p">:</span> +</span><span id="Generator-1022"><a href="#Generator-1022"><span class="linenos">1022</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-1023"><a href="#Generator-1023"><span class="linenos">1023</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">"expression"</span><span class="p">)</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> +</span><span id="Generator-1024"><a href="#Generator-1024"><span class="linenos">1024</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"> FILTER(</span><span class="si">{</span><span class="n">where</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Generator-1025"><a href="#Generator-1025"><span class="linenos">1025</span></a> +</span><span id="Generator-1026"><a href="#Generator-1026"><span class="linenos">1026</span></a> <span class="n">agg</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> +</span><span id="Generator-1027"><a href="#Generator-1027"><span class="linenos">1027</span></a> <span class="n">agg_arg</span> <span class="o">=</span> <span class="n">agg</span><span class="o">.</span><span class="n">this</span> +</span><span id="Generator-1028"><a href="#Generator-1028"><span class="linenos">1028</span></a> <span class="n">cond</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">this</span> +</span><span id="Generator-1029"><a href="#Generator-1029"><span class="linenos">1029</span></a> <span class="n">agg_arg</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">If</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">cond</span><span class="o">.</span><span class="n">copy</span><span class="p">(),</span> <span class="n">true</span><span class="o">=</span><span class="n">agg_arg</span><span class="o">.</span><span class="n">copy</span><span class="p">()))</span> +</span><span id="Generator-1030"><a href="#Generator-1030"><span class="linenos">1030</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">agg</span><span class="p">)</span> +</span><span id="Generator-1031"><a href="#Generator-1031"><span class="linenos">1031</span></a> +</span><span id="Generator-1032"><a href="#Generator-1032"><span class="linenos">1032</span></a> <span class="k">def</span> <span class="nf">hint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Hint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1033"><a href="#Generator-1033"><span class="linenos">1033</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">QUERY_HINTS</span><span class="p">:</span> +</span><span id="Generator-1034"><a href="#Generator-1034"><span class="linenos">1034</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Hints are not supported"</span><span class="p">)</span> +</span><span id="Generator-1035"><a href="#Generator-1035"><span class="linenos">1035</span></a> <span class="k">return</span> <span class="s2">""</span> </span><span id="Generator-1036"><a href="#Generator-1036"><span class="linenos">1036</span></a> -</span><span id="Generator-1037"><a href="#Generator-1037"><span class="linenos">1037</span></a> <span class="k">def</span> <span class="nf">hint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Hint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1038"><a href="#Generator-1038"><span class="linenos">1038</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">QUERY_HINTS</span><span class="p">:</span> -</span><span id="Generator-1039"><a href="#Generator-1039"><span class="linenos">1039</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Hints are not supported"</span><span class="p">)</span> -</span><span id="Generator-1040"><a href="#Generator-1040"><span class="linenos">1040</span></a> <span class="k">return</span> <span class="s2">""</span> -</span><span id="Generator-1041"><a href="#Generator-1041"><span class="linenos">1041</span></a> -</span><span id="Generator-1042"><a href="#Generator-1042"><span class="linenos">1042</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">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">QUERY_HINT_SEP</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-1043"><a href="#Generator-1043"><span class="linenos">1043</span></a> -</span><span id="Generator-1044"><a href="#Generator-1044"><span class="linenos">1044</span></a> <span class="k">def</span> <span class="nf">index_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Index</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1045"><a href="#Generator-1045"><span class="linenos">1045</span></a> <span class="n">unique</span> <span class="o">=</span> <span class="s2">"UNIQUE "</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">"unique"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1046"><a href="#Generator-1046"><span class="linenos">1046</span></a> <span class="n">primary</span> <span class="o">=</span> <span class="s2">"PRIMARY "</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">"primary"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1047"><a href="#Generator-1047"><span class="linenos">1047</span></a> <span class="n">amp</span> <span class="o">=</span> <span class="s2">"AMP "</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">"amp"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1048"><a href="#Generator-1048"><span class="linenos">1048</span></a> <span class="n">name</span> <span class="o">=</span> <span class="bp">self</span><span 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-1049"><a href="#Generator-1049"><span class="linenos">1049</span></a> <span class="n">name</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">name</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">name</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1050"><a href="#Generator-1050"><span class="linenos">1050</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">"table"</span><span class="p">)</span> -</span><span id="Generator-1051"><a href="#Generator-1051"><span class="linenos">1051</span></a> <span class="n">table</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">INDEX_ON</span><span class="si">}</span><span class="s2"> </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="n">table</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1052"><a href="#Generator-1052"><span class="linenos">1052</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-1053"><a href="#Generator-1053"><span class="linenos">1053</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-1054"><a href="#Generator-1054"><span class="linenos">1054</span></a> <span class="n">index</span> <span class="o">=</span> <span class="s2">"INDEX "</span> <span class="k">if</span> <span class="ow">not</span> <span class="n">table</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1055"><a href="#Generator-1055"><span class="linenos">1055</span></a> <span class="n">columns</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">"columns"</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-1056"><a href="#Generator-1056"><span class="linenos">1056</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">columns</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">columns</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1057"><a href="#Generator-1057"><span class="linenos">1057</span></a> <span class="n">partition_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">"partition_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-1058"><a href="#Generator-1058"><span class="linenos">1058</span></a> <span class="n">partition_by</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" PARTITION BY </span><span class="si">{</span><span class="n">partition_by</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">partition_by</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1059"><a href="#Generator-1059"><span class="linenos">1059</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-1060"><a href="#Generator-1060"><span class="linenos">1060</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">unique</span><span class="si">}{</span><span class="n">primary</span><span class="si">}{</span><span class="n">amp</span><span class="si">}{</span><span class="n">index</span><span class="si">}{</span><span class="n">name</span><span class="si">}{</span><span class="n">table</span><span class="si">}{</span><span class="n">using</span><span class="si">}{</span><span class="n">columns</span><span class="si">}{</span><span class="n">partition_by</span><span class="si">}{</span><span class="n">where</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1061"><a href="#Generator-1061"><span class="linenos">1061</span></a> -</span><span id="Generator-1062"><a href="#Generator-1062"><span class="linenos">1062</span></a> <span class="k">def</span> <span class="nf">identifier_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1063"><a href="#Generator-1063"><span class="linenos">1063</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">name</span> -</span><span id="Generator-1064"><a href="#Generator-1064"><span class="linenos">1064</span></a> <span class="n">lower</span> <span class="o">=</span> <span class="n">text</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> -</span><span id="Generator-1065"><a href="#Generator-1065"><span class="linenos">1065</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">lower</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">normalize</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">quoted</span> <span class="k">else</span> <span class="n">text</span> -</span><span id="Generator-1066"><a href="#Generator-1066"><span class="linenos">1066</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">text</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">IDENTIFIER_END</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_escaped_identifier_end</span><span class="p">)</span> -</span><span id="Generator-1067"><a href="#Generator-1067"><span class="linenos">1067</span></a> <span class="k">if</span> <span class="p">(</span> -</span><span id="Generator-1068"><a href="#Generator-1068"><span class="linenos">1068</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">quoted</span> -</span><span id="Generator-1069"><a href="#Generator-1069"><span class="linenos">1069</span></a> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">can_identify</span><span class="p">(</span><span class="n">text</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">identify</span><span class="p">)</span> -</span><span id="Generator-1070"><a href="#Generator-1070"><span class="linenos">1070</span></a> <span class="ow">or</span> <span class="n">lower</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">RESERVED_KEYWORDS</span> -</span><span id="Generator-1071"><a href="#Generator-1071"><span class="linenos">1071</span></a> <span class="ow">or</span> <span class="p">(</span><span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">IDENTIFIERS_CAN_START_WITH_DIGIT</span> <span class="ow">and</span> <span class="n">text</span><span class="p">[:</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">isdigit</span><span class="p">())</span> -</span><span id="Generator-1072"><a href="#Generator-1072"><span class="linenos">1072</span></a> <span class="p">):</span> -</span><span id="Generator-1073"><a href="#Generator-1073"><span class="linenos">1073</span></a> <span class="n">text</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">dialect</span><span class="o">.</span><span class="n">IDENTIFIER_START</span><span class="si">}{</span><span class="n">text</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">IDENTIFIER_END</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1074"><a href="#Generator-1074"><span class="linenos">1074</span></a> <span class="k">return</span> <span class="n">text</span> -</span><span id="Generator-1075"><a href="#Generator-1075"><span class="linenos">1075</span></a> -</span><span id="Generator-1076"><a href="#Generator-1076"><span class="linenos">1076</span></a> <span class="k">def</span> <span class="nf">inputoutputformat_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">InputOutputFormat</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1077"><a href="#Generator-1077"><span class="linenos">1077</span></a> <span class="n">input_format</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"input_format"</span><span class="p">)</span> -</span><span id="Generator-1078"><a href="#Generator-1078"><span class="linenos">1078</span></a> <span class="n">input_format</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"INPUTFORMAT </span><span class="si">{</span><span class="n">input_format</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">input_format</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1079"><a href="#Generator-1079"><span class="linenos">1079</span></a> <span class="n">output_format</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"output_format"</span><span class="p">)</span> -</span><span id="Generator-1080"><a href="#Generator-1080"><span class="linenos">1080</span></a> <span class="n">output_format</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"OUTPUTFORMAT </span><span class="si">{</span><span class="n">output_format</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">output_format</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1081"><a href="#Generator-1081"><span class="linenos">1081</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="o">.</span><span class="n">join</span><span class="p">((</span><span class="n">input_format</span><span class="p">,</span> <span class="n">output_format</span><span class="p">))</span> -</span><span id="Generator-1082"><a href="#Generator-1082"><span class="linenos">1082</span></a> -</span><span id="Generator-1083"><a href="#Generator-1083"><span class="linenos">1083</span></a> <span class="k">def</span> <span class="nf">national_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">National</span><span class="p">,</span> <span class="n">prefix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"N"</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1084"><a href="#Generator-1084"><span class="linenos">1084</span></a> <span class="n">string</span> <span class="o">=</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">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="p">))</span> -</span><span id="Generator-1085"><a href="#Generator-1085"><span class="linenos">1085</span></a> <span class="k">return</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">string</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1086"><a href="#Generator-1086"><span class="linenos">1086</span></a> -</span><span id="Generator-1087"><a href="#Generator-1087"><span class="linenos">1087</span></a> <span class="k">def</span> <span class="nf">partition_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Partition</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1088"><a href="#Generator-1088"><span class="linenos">1088</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PARTITION(</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-1089"><a href="#Generator-1089"><span class="linenos">1089</span></a> -</span><span id="Generator-1090"><a href="#Generator-1090"><span class="linenos">1090</span></a> <span class="k">def</span> <span class="nf">properties_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1091"><a href="#Generator-1091"><span class="linenos">1091</span></a> <span class="n">root_properties</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="Generator-1092"><a href="#Generator-1092"><span class="linenos">1092</span></a> <span class="n">with_properties</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="Generator-1093"><a href="#Generator-1093"><span class="linenos">1093</span></a> -</span><span id="Generator-1094"><a href="#Generator-1094"><span class="linenos">1094</span></a> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> -</span><span id="Generator-1095"><a href="#Generator-1095"><span class="linenos">1095</span></a> <span class="n">p_loc</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">PROPERTIES_LOCATION</span><span class="p">[</span><span class="n">p</span><span class="o">.</span><span class="vm">__class__</span><span class="p">]</span> -</span><span id="Generator-1096"><a href="#Generator-1096"><span class="linenos">1096</span></a> <span class="k">if</span> <span class="n">p_loc</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">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">:</span> -</span><span id="Generator-1097"><a href="#Generator-1097"><span class="linenos">1097</span></a> <span class="n">with_properties</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> -</span><span id="Generator-1098"><a href="#Generator-1098"><span class="linenos">1098</span></a> <span class="k">elif</span> <span class="n">p_loc</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">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">:</span> -</span><span id="Generator-1099"><a href="#Generator-1099"><span class="linenos">1099</span></a> <span class="n">root_properties</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> -</span><span id="Generator-1100"><a href="#Generator-1100"><span class="linenos">1100</span></a> -</span><span id="Generator-1101"><a href="#Generator-1101"><span class="linenos">1101</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">root_properties</span><span class="p">(</span> -</span><span id="Generator-1102"><a href="#Generator-1102"><span class="linenos">1102</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">root_properties</span><span class="p">)</span> -</span><span id="Generator-1103"><a href="#Generator-1103"><span class="linenos">1103</span></a> <span class="p">)</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">with_properties</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">with_properties</span><span class="p">))</span> +</span><span id="Generator-1037"><a href="#Generator-1037"><span class="linenos">1037</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">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">QUERY_HINT_SEP</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-1038"><a href="#Generator-1038"><span class="linenos">1038</span></a> +</span><span id="Generator-1039"><a href="#Generator-1039"><span class="linenos">1039</span></a> <span class="k">def</span> <span class="nf">index_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Index</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1040"><a href="#Generator-1040"><span class="linenos">1040</span></a> <span class="n">unique</span> <span class="o">=</span> <span class="s2">"UNIQUE "</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">"unique"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1041"><a href="#Generator-1041"><span class="linenos">1041</span></a> <span class="n">primary</span> <span class="o">=</span> <span class="s2">"PRIMARY "</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">"primary"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1042"><a href="#Generator-1042"><span class="linenos">1042</span></a> <span class="n">amp</span> <span class="o">=</span> <span class="s2">"AMP "</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">"amp"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1043"><a href="#Generator-1043"><span class="linenos">1043</span></a> <span class="n">name</span> <span class="o">=</span> <span class="bp">self</span><span 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-1044"><a href="#Generator-1044"><span class="linenos">1044</span></a> <span class="n">name</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">name</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">name</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1045"><a href="#Generator-1045"><span class="linenos">1045</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">"table"</span><span class="p">)</span> +</span><span id="Generator-1046"><a href="#Generator-1046"><span class="linenos">1046</span></a> <span class="n">table</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">INDEX_ON</span><span class="si">}</span><span class="s2"> </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="n">table</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1047"><a href="#Generator-1047"><span class="linenos">1047</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-1048"><a href="#Generator-1048"><span class="linenos">1048</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-1049"><a href="#Generator-1049"><span class="linenos">1049</span></a> <span class="n">index</span> <span class="o">=</span> <span class="s2">"INDEX "</span> <span class="k">if</span> <span class="ow">not</span> <span class="n">table</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1050"><a href="#Generator-1050"><span class="linenos">1050</span></a> <span class="n">columns</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">"columns"</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-1051"><a href="#Generator-1051"><span class="linenos">1051</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">columns</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">columns</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1052"><a href="#Generator-1052"><span class="linenos">1052</span></a> <span class="n">partition_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">"partition_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-1053"><a href="#Generator-1053"><span class="linenos">1053</span></a> <span class="n">partition_by</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" PARTITION BY </span><span class="si">{</span><span class="n">partition_by</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">partition_by</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1054"><a href="#Generator-1054"><span class="linenos">1054</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-1055"><a href="#Generator-1055"><span class="linenos">1055</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">unique</span><span class="si">}{</span><span class="n">primary</span><span class="si">}{</span><span class="n">amp</span><span class="si">}{</span><span class="n">index</span><span class="si">}{</span><span class="n">name</span><span class="si">}{</span><span class="n">table</span><span class="si">}{</span><span class="n">using</span><span class="si">}{</span><span class="n">columns</span><span class="si">}{</span><span class="n">partition_by</span><span class="si">}{</span><span class="n">where</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1056"><a href="#Generator-1056"><span class="linenos">1056</span></a> +</span><span id="Generator-1057"><a href="#Generator-1057"><span class="linenos">1057</span></a> <span class="k">def</span> <span class="nf">identifier_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1058"><a href="#Generator-1058"><span class="linenos">1058</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">name</span> +</span><span id="Generator-1059"><a href="#Generator-1059"><span class="linenos">1059</span></a> <span class="n">lower</span> <span class="o">=</span> <span class="n">text</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> +</span><span id="Generator-1060"><a href="#Generator-1060"><span class="linenos">1060</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">lower</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">normalize</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">quoted</span> <span class="k">else</span> <span class="n">text</span> +</span><span id="Generator-1061"><a href="#Generator-1061"><span class="linenos">1061</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">text</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">IDENTIFIER_END</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_escaped_identifier_end</span><span class="p">)</span> +</span><span id="Generator-1062"><a href="#Generator-1062"><span class="linenos">1062</span></a> <span class="k">if</span> <span class="p">(</span> +</span><span id="Generator-1063"><a href="#Generator-1063"><span class="linenos">1063</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">quoted</span> +</span><span id="Generator-1064"><a href="#Generator-1064"><span class="linenos">1064</span></a> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">can_identify</span><span class="p">(</span><span class="n">text</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">identify</span><span class="p">)</span> +</span><span id="Generator-1065"><a href="#Generator-1065"><span class="linenos">1065</span></a> <span class="ow">or</span> <span class="n">lower</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">RESERVED_KEYWORDS</span> +</span><span id="Generator-1066"><a href="#Generator-1066"><span class="linenos">1066</span></a> <span class="ow">or</span> <span class="p">(</span><span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">IDENTIFIERS_CAN_START_WITH_DIGIT</span> <span class="ow">and</span> <span class="n">text</span><span class="p">[:</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">isdigit</span><span class="p">())</span> +</span><span id="Generator-1067"><a href="#Generator-1067"><span class="linenos">1067</span></a> <span class="p">):</span> +</span><span id="Generator-1068"><a href="#Generator-1068"><span class="linenos">1068</span></a> <span class="n">text</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">dialect</span><span class="o">.</span><span class="n">IDENTIFIER_START</span><span class="si">}{</span><span class="n">text</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">IDENTIFIER_END</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1069"><a href="#Generator-1069"><span class="linenos">1069</span></a> <span class="k">return</span> <span class="n">text</span> +</span><span id="Generator-1070"><a href="#Generator-1070"><span class="linenos">1070</span></a> +</span><span id="Generator-1071"><a href="#Generator-1071"><span class="linenos">1071</span></a> <span class="k">def</span> <span class="nf">inputoutputformat_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">InputOutputFormat</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1072"><a href="#Generator-1072"><span class="linenos">1072</span></a> <span class="n">input_format</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"input_format"</span><span class="p">)</span> +</span><span id="Generator-1073"><a href="#Generator-1073"><span class="linenos">1073</span></a> <span class="n">input_format</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"INPUTFORMAT </span><span class="si">{</span><span class="n">input_format</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">input_format</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1074"><a href="#Generator-1074"><span class="linenos">1074</span></a> <span class="n">output_format</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"output_format"</span><span class="p">)</span> +</span><span id="Generator-1075"><a href="#Generator-1075"><span class="linenos">1075</span></a> <span class="n">output_format</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"OUTPUTFORMAT </span><span class="si">{</span><span class="n">output_format</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">output_format</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1076"><a href="#Generator-1076"><span class="linenos">1076</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="o">.</span><span class="n">join</span><span class="p">((</span><span class="n">input_format</span><span class="p">,</span> <span class="n">output_format</span><span class="p">))</span> +</span><span id="Generator-1077"><a href="#Generator-1077"><span class="linenos">1077</span></a> +</span><span id="Generator-1078"><a href="#Generator-1078"><span class="linenos">1078</span></a> <span class="k">def</span> <span class="nf">national_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">National</span><span class="p">,</span> <span class="n">prefix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"N"</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1079"><a href="#Generator-1079"><span class="linenos">1079</span></a> <span class="n">string</span> <span class="o">=</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">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="p">))</span> +</span><span id="Generator-1080"><a href="#Generator-1080"><span class="linenos">1080</span></a> <span class="k">return</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">string</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1081"><a href="#Generator-1081"><span class="linenos">1081</span></a> +</span><span id="Generator-1082"><a href="#Generator-1082"><span class="linenos">1082</span></a> <span class="k">def</span> <span class="nf">partition_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Partition</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1083"><a href="#Generator-1083"><span class="linenos">1083</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PARTITION(</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-1084"><a href="#Generator-1084"><span class="linenos">1084</span></a> +</span><span id="Generator-1085"><a href="#Generator-1085"><span class="linenos">1085</span></a> <span class="k">def</span> <span class="nf">properties_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1086"><a href="#Generator-1086"><span class="linenos">1086</span></a> <span class="n">root_properties</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="Generator-1087"><a href="#Generator-1087"><span class="linenos">1087</span></a> <span class="n">with_properties</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="Generator-1088"><a href="#Generator-1088"><span class="linenos">1088</span></a> +</span><span id="Generator-1089"><a href="#Generator-1089"><span class="linenos">1089</span></a> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> +</span><span id="Generator-1090"><a href="#Generator-1090"><span class="linenos">1090</span></a> <span class="n">p_loc</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">PROPERTIES_LOCATION</span><span class="p">[</span><span class="n">p</span><span class="o">.</span><span class="vm">__class__</span><span class="p">]</span> +</span><span id="Generator-1091"><a href="#Generator-1091"><span class="linenos">1091</span></a> <span class="k">if</span> <span class="n">p_loc</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">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">:</span> +</span><span id="Generator-1092"><a href="#Generator-1092"><span class="linenos">1092</span></a> <span class="n">with_properties</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> +</span><span id="Generator-1093"><a href="#Generator-1093"><span class="linenos">1093</span></a> <span class="k">elif</span> <span class="n">p_loc</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">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">:</span> +</span><span id="Generator-1094"><a href="#Generator-1094"><span class="linenos">1094</span></a> <span class="n">root_properties</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> +</span><span id="Generator-1095"><a href="#Generator-1095"><span class="linenos">1095</span></a> +</span><span id="Generator-1096"><a href="#Generator-1096"><span class="linenos">1096</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">root_properties</span><span class="p">(</span> +</span><span id="Generator-1097"><a href="#Generator-1097"><span class="linenos">1097</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">root_properties</span><span class="p">)</span> +</span><span id="Generator-1098"><a href="#Generator-1098"><span class="linenos">1098</span></a> <span class="p">)</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">with_properties</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">with_properties</span><span class="p">))</span> +</span><span id="Generator-1099"><a href="#Generator-1099"><span class="linenos">1099</span></a> +</span><span id="Generator-1100"><a href="#Generator-1100"><span class="linenos">1100</span></a> <span class="k">def</span> <span class="nf">root_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1101"><a href="#Generator-1101"><span class="linenos">1101</span></a> <span class="k">if</span> <span class="n">properties</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> +</span><span id="Generator-1102"><a href="#Generator-1102"><span class="linenos">1102</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</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">properties</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="kc">False</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-1103"><a href="#Generator-1103"><span class="linenos">1103</span></a> <span class="k">return</span> <span class="s2">""</span> </span><span id="Generator-1104"><a href="#Generator-1104"><span class="linenos">1104</span></a> -</span><span id="Generator-1105"><a href="#Generator-1105"><span class="linenos">1105</span></a> <span class="k">def</span> <span class="nf">root_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1106"><a href="#Generator-1106"><span class="linenos">1106</span></a> <span class="k">if</span> <span class="n">properties</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> -</span><span id="Generator-1107"><a href="#Generator-1107"><span class="linenos">1107</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</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">properties</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="kc">False</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-1108"><a href="#Generator-1108"><span class="linenos">1108</span></a> <span class="k">return</span> <span class="s2">""</span> -</span><span id="Generator-1109"><a href="#Generator-1109"><span class="linenos">1109</span></a> -</span><span id="Generator-1110"><a href="#Generator-1110"><span class="linenos">1110</span></a> <span class="k">def</span> <span class="nf">properties</span><span class="p">(</span> -</span><span id="Generator-1111"><a href="#Generator-1111"><span class="linenos">1111</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Generator-1112"><a href="#Generator-1112"><span class="linenos">1112</span></a> <span class="n">properties</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-1113"><a href="#Generator-1113"><span class="linenos">1113</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-1114"><a href="#Generator-1114"><span class="linenos">1114</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-1115"><a href="#Generator-1115"><span class="linenos">1115</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-1116"><a href="#Generator-1116"><span class="linenos">1116</span></a> <span class="n">wrapped</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-1117"><a href="#Generator-1117"><span class="linenos">1117</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1118"><a href="#Generator-1118"><span class="linenos">1118</span></a> <span class="k">if</span> <span class="n">properties</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> -</span><span id="Generator-1119"><a href="#Generator-1119"><span class="linenos">1119</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">properties</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="n">sep</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> -</span><span id="Generator-1120"><a href="#Generator-1120"><span class="linenos">1120</span></a> <span class="k">if</span> <span class="n">expressions</span><span class="p">:</span> -</span><span id="Generator-1121"><a href="#Generator-1121"><span class="linenos">1121</span></a> <span class="n">expressions</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">expressions</span><span class="p">)</span> <span class="k">if</span> <span class="n">wrapped</span> <span class="k">else</span> <span class="n">expressions</span> -</span><span id="Generator-1122"><a href="#Generator-1122"><span class="linenos">1122</span></a> <span class="k">return</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="s1">' '</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">prefix</span><span class="o">.</span><span class="n">strip</span><span class="p">()</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</span><span class="si">}{</span><span class="n">suffix</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1123"><a href="#Generator-1123"><span class="linenos">1123</span></a> <span class="k">return</span> <span class="s2">""</span> -</span><span id="Generator-1124"><a href="#Generator-1124"><span class="linenos">1124</span></a> -</span><span id="Generator-1125"><a href="#Generator-1125"><span class="linenos">1125</span></a> <span class="k">def</span> <span class="nf">with_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1126"><a href="#Generator-1126"><span class="linenos">1126</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span><span class="n">properties</span><span class="p">,</span> <span class="n">prefix</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">"WITH"</span><span class="p">))</span> -</span><span id="Generator-1127"><a href="#Generator-1127"><span class="linenos">1127</span></a> -</span><span id="Generator-1128"><a href="#Generator-1128"><span class="linenos">1128</span></a> <span class="k">def</span> <span class="nf">locate_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">DefaultDict</span><span class="p">:</span> -</span><span id="Generator-1129"><a href="#Generator-1129"><span class="linenos">1129</span></a> <span class="n">properties_locs</span> <span class="o">=</span> <span class="n">defaultdict</span><span class="p">(</span><span class="nb">list</span><span class="p">)</span> -</span><span id="Generator-1130"><a href="#Generator-1130"><span class="linenos">1130</span></a> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">properties</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> -</span><span id="Generator-1131"><a href="#Generator-1131"><span class="linenos">1131</span></a> <span class="n">p_loc</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">PROPERTIES_LOCATION</span><span class="p">[</span><span class="n">p</span><span class="o">.</span><span class="vm">__class__</span><span class="p">]</span> -</span><span id="Generator-1132"><a href="#Generator-1132"><span class="linenos">1132</span></a> <span class="k">if</span> <span class="n">p_loc</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">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span><span class="p">:</span> -</span><span id="Generator-1133"><a href="#Generator-1133"><span class="linenos">1133</span></a> <span class="n">properties_locs</span><span class="p">[</span><span class="n">p_loc</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> -</span><span id="Generator-1134"><a href="#Generator-1134"><span class="linenos">1134</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator-1135"><a href="#Generator-1135"><span class="linenos">1135</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">p</span><span class="o">.</span><span class="n">key</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="Generator-1136"><a href="#Generator-1136"><span class="linenos">1136</span></a> -</span><span id="Generator-1137"><a href="#Generator-1137"><span class="linenos">1137</span></a> <span class="k">return</span> <span class="n">properties_locs</span> +</span><span id="Generator-1105"><a href="#Generator-1105"><span class="linenos">1105</span></a> <span class="k">def</span> <span class="nf">properties</span><span class="p">(</span> +</span><span id="Generator-1106"><a href="#Generator-1106"><span class="linenos">1106</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Generator-1107"><a href="#Generator-1107"><span class="linenos">1107</span></a> <span class="n">properties</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-1108"><a href="#Generator-1108"><span class="linenos">1108</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-1109"><a href="#Generator-1109"><span class="linenos">1109</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-1110"><a href="#Generator-1110"><span class="linenos">1110</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-1111"><a href="#Generator-1111"><span class="linenos">1111</span></a> <span class="n">wrapped</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-1112"><a href="#Generator-1112"><span class="linenos">1112</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1113"><a href="#Generator-1113"><span class="linenos">1113</span></a> <span class="k">if</span> <span class="n">properties</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> +</span><span id="Generator-1114"><a href="#Generator-1114"><span class="linenos">1114</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">properties</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="n">sep</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</span><span id="Generator-1115"><a href="#Generator-1115"><span class="linenos">1115</span></a> <span class="k">if</span> <span class="n">expressions</span><span class="p">:</span> +</span><span id="Generator-1116"><a href="#Generator-1116"><span class="linenos">1116</span></a> <span class="n">expressions</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">expressions</span><span class="p">)</span> <span class="k">if</span> <span class="n">wrapped</span> <span class="k">else</span> <span class="n">expressions</span> +</span><span id="Generator-1117"><a href="#Generator-1117"><span class="linenos">1117</span></a> <span class="k">return</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="s1">' '</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">prefix</span><span class="o">.</span><span class="n">strip</span><span class="p">()</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</span><span class="si">}{</span><span class="n">suffix</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1118"><a href="#Generator-1118"><span class="linenos">1118</span></a> <span class="k">return</span> <span class="s2">""</span> +</span><span id="Generator-1119"><a href="#Generator-1119"><span class="linenos">1119</span></a> +</span><span id="Generator-1120"><a href="#Generator-1120"><span class="linenos">1120</span></a> <span class="k">def</span> <span class="nf">with_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1121"><a href="#Generator-1121"><span class="linenos">1121</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span><span class="n">properties</span><span class="p">,</span> <span class="n">prefix</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">"WITH"</span><span class="p">))</span> +</span><span id="Generator-1122"><a href="#Generator-1122"><span class="linenos">1122</span></a> +</span><span id="Generator-1123"><a href="#Generator-1123"><span class="linenos">1123</span></a> <span class="k">def</span> <span class="nf">locate_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">DefaultDict</span><span class="p">:</span> +</span><span id="Generator-1124"><a href="#Generator-1124"><span class="linenos">1124</span></a> <span class="n">properties_locs</span> <span class="o">=</span> <span class="n">defaultdict</span><span class="p">(</span><span class="nb">list</span><span class="p">)</span> +</span><span id="Generator-1125"><a href="#Generator-1125"><span class="linenos">1125</span></a> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">properties</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> +</span><span id="Generator-1126"><a href="#Generator-1126"><span class="linenos">1126</span></a> <span class="n">p_loc</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">PROPERTIES_LOCATION</span><span class="p">[</span><span class="n">p</span><span class="o">.</span><span class="vm">__class__</span><span class="p">]</span> +</span><span id="Generator-1127"><a href="#Generator-1127"><span class="linenos">1127</span></a> <span class="k">if</span> <span class="n">p_loc</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">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span><span class="p">:</span> +</span><span id="Generator-1128"><a href="#Generator-1128"><span class="linenos">1128</span></a> <span class="n">properties_locs</span><span class="p">[</span><span class="n">p_loc</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> +</span><span id="Generator-1129"><a href="#Generator-1129"><span class="linenos">1129</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator-1130"><a href="#Generator-1130"><span class="linenos">1130</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">p</span><span class="o">.</span><span class="n">key</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="Generator-1131"><a href="#Generator-1131"><span class="linenos">1131</span></a> +</span><span id="Generator-1132"><a href="#Generator-1132"><span class="linenos">1132</span></a> <span class="k">return</span> <span class="n">properties_locs</span> +</span><span id="Generator-1133"><a href="#Generator-1133"><span class="linenos">1133</span></a> +</span><span id="Generator-1134"><a href="#Generator-1134"><span class="linenos">1134</span></a> <span class="k">def</span> <span class="nf">property_name</span><span class="p">(</span><span class="bp">self</span><span 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="n">string_key</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-1135"><a href="#Generator-1135"><span class="linenos">1135</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">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Dot</span><span class="p">):</span> +</span><span id="Generator-1136"><a href="#Generator-1136"><span class="linenos">1136</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">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-1137"><a href="#Generator-1137"><span class="linenos">1137</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">name</span><span class="si">}</span><span class="s2">'"</span> <span class="k">if</span> <span class="n">string_key</span> <span class="k">else</span> <span class="n">expression</span><span class="o">.</span><span class="n">name</span> </span><span id="Generator-1138"><a href="#Generator-1138"><span class="linenos">1138</span></a> -</span><span id="Generator-1139"><a href="#Generator-1139"><span class="linenos">1139</span></a> <span class="k">def</span> <span class="nf">property_name</span><span class="p">(</span><span class="bp">self</span><span 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="n">string_key</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-1140"><a href="#Generator-1140"><span class="linenos">1140</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">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Dot</span><span class="p">):</span> -</span><span id="Generator-1141"><a href="#Generator-1141"><span class="linenos">1141</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">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-1142"><a href="#Generator-1142"><span class="linenos">1142</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">name</span><span class="si">}</span><span class="s2">'"</span> <span class="k">if</span> <span class="n">string_key</span> <span class="k">else</span> <span class="n">expression</span><span class="o">.</span><span class="n">name</span> +</span><span id="Generator-1139"><a href="#Generator-1139"><span class="linenos">1139</span></a> <span class="k">def</span> <span class="nf">property_sql</span><span class="p">(</span><span class="bp">self</span><span 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-1140"><a href="#Generator-1140"><span class="linenos">1140</span></a> <span class="n">property_cls</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="vm">__class__</span> +</span><span id="Generator-1141"><a href="#Generator-1141"><span class="linenos">1141</span></a> <span class="k">if</span> <span class="n">property_cls</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Property</span><span class="p">:</span> +</span><span id="Generator-1142"><a href="#Generator-1142"><span class="linenos">1142</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">property_name</span><span class="p">(</span><span class="n">expression</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-1143"><a href="#Generator-1143"><span class="linenos">1143</span></a> -</span><span id="Generator-1144"><a href="#Generator-1144"><span class="linenos">1144</span></a> <span class="k">def</span> <span class="nf">property_sql</span><span class="p">(</span><span class="bp">self</span><span 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-1145"><a href="#Generator-1145"><span class="linenos">1145</span></a> <span class="n">property_cls</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="vm">__class__</span> -</span><span id="Generator-1146"><a href="#Generator-1146"><span class="linenos">1146</span></a> <span class="k">if</span> <span class="n">property_cls</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Property</span><span class="p">:</span> -</span><span id="Generator-1147"><a href="#Generator-1147"><span class="linenos">1147</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">property_name</span><span class="p">(</span><span class="n">expression</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-1148"><a href="#Generator-1148"><span class="linenos">1148</span></a> -</span><span id="Generator-1149"><a href="#Generator-1149"><span class="linenos">1149</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">property_cls</span><span class="p">)</span> -</span><span id="Generator-1150"><a href="#Generator-1150"><span class="linenos">1150</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-1151"><a href="#Generator-1151"><span class="linenos">1151</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="n">key</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="Generator-1152"><a href="#Generator-1152"><span class="linenos">1152</span></a> -</span><span id="Generator-1153"><a href="#Generator-1153"><span class="linenos">1153</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-1144"><a href="#Generator-1144"><span class="linenos">1144</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">property_cls</span><span class="p">)</span> +</span><span id="Generator-1145"><a href="#Generator-1145"><span class="linenos">1145</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-1146"><a href="#Generator-1146"><span class="linenos">1146</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="n">key</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="Generator-1147"><a href="#Generator-1147"><span class="linenos">1147</span></a> +</span><span id="Generator-1148"><a href="#Generator-1148"><span class="linenos">1148</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-1149"><a href="#Generator-1149"><span class="linenos">1149</span></a> +</span><span id="Generator-1150"><a href="#Generator-1150"><span class="linenos">1150</span></a> <span class="k">def</span> <span class="nf">likeproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">LikeProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1151"><a href="#Generator-1151"><span class="linenos">1151</span></a> <span class="n">options</span> <span class="o">=</span> <span class="s2">" "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">e</span><span class="o">.</span><span class="n">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">e</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 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">expressions</span><span class="p">)</span> +</span><span id="Generator-1152"><a href="#Generator-1152"><span class="linenos">1152</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-1153"><a href="#Generator-1153"><span class="linenos">1153</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"LIKE </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">options</span><span class="si">}</span><span class="s2">"</span> </span><span id="Generator-1154"><a href="#Generator-1154"><span class="linenos">1154</span></a> -</span><span id="Generator-1155"><a href="#Generator-1155"><span class="linenos">1155</span></a> <span class="k">def</span> <span class="nf">likeproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">LikeProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1156"><a href="#Generator-1156"><span class="linenos">1156</span></a> <span class="n">options</span> <span class="o">=</span> <span class="s2">" "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">e</span><span class="o">.</span><span class="n">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">e</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 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">expressions</span><span class="p">)</span> -</span><span id="Generator-1157"><a href="#Generator-1157"><span class="linenos">1157</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-1158"><a href="#Generator-1158"><span class="linenos">1158</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"LIKE </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">options</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1155"><a href="#Generator-1155"><span class="linenos">1155</span></a> <span class="k">def</span> <span class="nf">fallbackproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">FallbackProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1156"><a href="#Generator-1156"><span class="linenos">1156</span></a> <span class="n">no</span> <span class="o">=</span> <span class="s2">"NO "</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">"no"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1157"><a href="#Generator-1157"><span class="linenos">1157</span></a> <span class="n">protection</span> <span class="o">=</span> <span class="s2">" PROTECTION"</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">"protection"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1158"><a href="#Generator-1158"><span class="linenos">1158</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">no</span><span class="si">}</span><span class="s2">FALLBACK</span><span class="si">{</span><span class="n">protection</span><span class="si">}</span><span class="s2">"</span> </span><span id="Generator-1159"><a href="#Generator-1159"><span class="linenos">1159</span></a> -</span><span id="Generator-1160"><a href="#Generator-1160"><span class="linenos">1160</span></a> <span class="k">def</span> <span class="nf">fallbackproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">FallbackProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1160"><a href="#Generator-1160"><span class="linenos">1160</span></a> <span class="k">def</span> <span class="nf">journalproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">JournalProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> </span><span id="Generator-1161"><a href="#Generator-1161"><span class="linenos">1161</span></a> <span class="n">no</span> <span class="o">=</span> <span class="s2">"NO "</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">"no"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1162"><a href="#Generator-1162"><span class="linenos">1162</span></a> <span class="n">protection</span> <span class="o">=</span> <span class="s2">" PROTECTION"</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">"protection"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1163"><a href="#Generator-1163"><span class="linenos">1163</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">no</span><span class="si">}</span><span class="s2">FALLBACK</span><span class="si">{</span><span class="n">protection</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1164"><a href="#Generator-1164"><span class="linenos">1164</span></a> -</span><span id="Generator-1165"><a href="#Generator-1165"><span class="linenos">1165</span></a> <span class="k">def</span> <span class="nf">journalproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">JournalProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1166"><a href="#Generator-1166"><span class="linenos">1166</span></a> <span class="n">no</span> <span class="o">=</span> <span class="s2">"NO "</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">"no"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1167"><a href="#Generator-1167"><span class="linenos">1167</span></a> <span class="n">local</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">"local"</span><span class="p">)</span> -</span><span id="Generator-1168"><a href="#Generator-1168"><span class="linenos">1168</span></a> <span class="n">local</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">local</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">local</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1169"><a href="#Generator-1169"><span class="linenos">1169</span></a> <span class="n">dual</span> <span class="o">=</span> <span class="s2">"DUAL "</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">"dual"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1170"><a href="#Generator-1170"><span class="linenos">1170</span></a> <span class="n">before</span> <span class="o">=</span> <span class="s2">"BEFORE "</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">"before"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1171"><a href="#Generator-1171"><span class="linenos">1171</span></a> <span class="n">after</span> <span class="o">=</span> <span class="s2">"AFTER "</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">"after"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1172"><a href="#Generator-1172"><span class="linenos">1172</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">no</span><span class="si">}{</span><span class="n">local</span><span class="si">}{</span><span class="n">dual</span><span class="si">}{</span><span class="n">before</span><span class="si">}{</span><span class="n">after</span><span class="si">}</span><span class="s2">JOURNAL"</span> +</span><span id="Generator-1162"><a href="#Generator-1162"><span class="linenos">1162</span></a> <span class="n">local</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">"local"</span><span class="p">)</span> +</span><span id="Generator-1163"><a href="#Generator-1163"><span class="linenos">1163</span></a> <span class="n">local</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">local</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">local</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1164"><a href="#Generator-1164"><span class="linenos">1164</span></a> <span class="n">dual</span> <span class="o">=</span> <span class="s2">"DUAL "</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">"dual"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1165"><a href="#Generator-1165"><span class="linenos">1165</span></a> <span class="n">before</span> <span class="o">=</span> <span class="s2">"BEFORE "</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">"before"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1166"><a href="#Generator-1166"><span class="linenos">1166</span></a> <span class="n">after</span> <span class="o">=</span> <span class="s2">"AFTER "</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">"after"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1167"><a href="#Generator-1167"><span class="linenos">1167</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">no</span><span class="si">}{</span><span class="n">local</span><span class="si">}{</span><span class="n">dual</span><span class="si">}{</span><span class="n">before</span><span class="si">}{</span><span class="n">after</span><span class="si">}</span><span class="s2">JOURNAL"</span> +</span><span id="Generator-1168"><a href="#Generator-1168"><span class="linenos">1168</span></a> +</span><span id="Generator-1169"><a href="#Generator-1169"><span class="linenos">1169</span></a> <span class="k">def</span> <span class="nf">freespaceproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">FreespaceProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1170"><a href="#Generator-1170"><span class="linenos">1170</span></a> <span class="n">freespace</span> <span class="o">=</span> <span class="bp">self</span><span 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-1171"><a href="#Generator-1171"><span class="linenos">1171</span></a> <span class="n">percent</span> <span class="o">=</span> <span class="s2">" PERCENT"</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">"percent"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1172"><a href="#Generator-1172"><span class="linenos">1172</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"FREESPACE=</span><span class="si">{</span><span class="n">freespace</span><span class="si">}{</span><span class="n">percent</span><span class="si">}</span><span class="s2">"</span> </span><span id="Generator-1173"><a href="#Generator-1173"><span class="linenos">1173</span></a> -</span><span id="Generator-1174"><a href="#Generator-1174"><span class="linenos">1174</span></a> <span class="k">def</span> <span class="nf">freespaceproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">FreespaceProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1175"><a href="#Generator-1175"><span class="linenos">1175</span></a> <span class="n">freespace</span> <span class="o">=</span> <span class="bp">self</span><span 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-1176"><a href="#Generator-1176"><span class="linenos">1176</span></a> <span class="n">percent</span> <span class="o">=</span> <span class="s2">" PERCENT"</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">"percent"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1177"><a href="#Generator-1177"><span class="linenos">1177</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"FREESPACE=</span><span class="si">{</span><span class="n">freespace</span><span class="si">}{</span><span class="n">percent</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1178"><a href="#Generator-1178"><span class="linenos">1178</span></a> -</span><span id="Generator-1179"><a href="#Generator-1179"><span class="linenos">1179</span></a> <span class="k">def</span> <span class="nf">checksumproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ChecksumProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1180"><a href="#Generator-1180"><span class="linenos">1180</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">"default"</span><span class="p">):</span> -</span><span id="Generator-1181"><a href="#Generator-1181"><span class="linenos">1181</span></a> <span class="nb">property</span> <span class="o">=</span> <span class="s2">"DEFAULT"</span> -</span><span id="Generator-1182"><a href="#Generator-1182"><span class="linenos">1182</span></a> <span class="k">elif</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">"on"</span><span class="p">):</span> -</span><span id="Generator-1183"><a href="#Generator-1183"><span class="linenos">1183</span></a> <span class="nb">property</span> <span class="o">=</span> <span class="s2">"ON"</span> -</span><span id="Generator-1184"><a href="#Generator-1184"><span class="linenos">1184</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator-1185"><a href="#Generator-1185"><span class="linenos">1185</span></a> <span class="nb">property</span> <span class="o">=</span> <span class="s2">"OFF"</span> -</span><span id="Generator-1186"><a href="#Generator-1186"><span class="linenos">1186</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CHECKSUM=</span><span class="si">{</span><span class="nb">property</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1187"><a href="#Generator-1187"><span class="linenos">1187</span></a> -</span><span id="Generator-1188"><a href="#Generator-1188"><span class="linenos">1188</span></a> <span class="k">def</span> <span class="nf">mergeblockratioproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">MergeBlockRatioProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1189"><a href="#Generator-1189"><span class="linenos">1189</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">"no"</span><span class="p">):</span> -</span><span id="Generator-1190"><a href="#Generator-1190"><span class="linenos">1190</span></a> <span class="k">return</span> <span class="s2">"NO MERGEBLOCKRATIO"</span> -</span><span id="Generator-1191"><a href="#Generator-1191"><span class="linenos">1191</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">"default"</span><span class="p">):</span> -</span><span id="Generator-1192"><a href="#Generator-1192"><span class="linenos">1192</span></a> <span class="k">return</span> <span class="s2">"DEFAULT MERGEBLOCKRATIO"</span> -</span><span id="Generator-1193"><a href="#Generator-1193"><span class="linenos">1193</span></a> -</span><span id="Generator-1194"><a href="#Generator-1194"><span class="linenos">1194</span></a> <span class="n">percent</span> <span class="o">=</span> <span class="s2">" PERCENT"</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">"percent"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1195"><a href="#Generator-1195"><span class="linenos">1195</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"MERGEBLOCKRATIO=</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">percent</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1196"><a href="#Generator-1196"><span class="linenos">1196</span></a> -</span><span id="Generator-1197"><a href="#Generator-1197"><span class="linenos">1197</span></a> <span class="k">def</span> <span class="nf">datablocksizeproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataBlocksizeProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1198"><a href="#Generator-1198"><span class="linenos">1198</span></a> <span class="n">default</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">"default"</span><span class="p">)</span> -</span><span id="Generator-1199"><a href="#Generator-1199"><span class="linenos">1199</span></a> <span class="n">minimum</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">"minimum"</span><span class="p">)</span> -</span><span id="Generator-1200"><a href="#Generator-1200"><span class="linenos">1200</span></a> <span class="n">maximum</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">"maximum"</span><span class="p">)</span> -</span><span id="Generator-1201"><a href="#Generator-1201"><span class="linenos">1201</span></a> <span class="k">if</span> <span class="n">default</span> <span class="ow">or</span> <span class="n">minimum</span> <span class="ow">or</span> <span class="n">maximum</span><span class="p">:</span> -</span><span id="Generator-1202"><a href="#Generator-1202"><span class="linenos">1202</span></a> <span class="k">if</span> <span class="n">default</span><span class="p">:</span> -</span><span id="Generator-1203"><a href="#Generator-1203"><span class="linenos">1203</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"DEFAULT"</span> -</span><span id="Generator-1204"><a href="#Generator-1204"><span class="linenos">1204</span></a> <span class="k">elif</span> <span class="n">minimum</span><span class="p">:</span> -</span><span id="Generator-1205"><a href="#Generator-1205"><span class="linenos">1205</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"MINIMUM"</span> -</span><span id="Generator-1206"><a href="#Generator-1206"><span class="linenos">1206</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator-1207"><a href="#Generator-1207"><span class="linenos">1207</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"MAXIMUM"</span> -</span><span id="Generator-1208"><a href="#Generator-1208"><span class="linenos">1208</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">prop</span><span class="si">}</span><span class="s2"> DATABLOCKSIZE"</span> -</span><span id="Generator-1209"><a href="#Generator-1209"><span class="linenos">1209</span></a> <span class="n">units</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">"units"</span><span class="p">)</span> -</span><span id="Generator-1210"><a href="#Generator-1210"><span class="linenos">1210</span></a> <span class="n">units</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">units</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">units</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1211"><a href="#Generator-1211"><span class="linenos">1211</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"DATABLOCKSIZE=</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">'size'</span><span class="p">)</span><span class="si">}{</span><span class="n">units</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1212"><a href="#Generator-1212"><span class="linenos">1212</span></a> -</span><span id="Generator-1213"><a href="#Generator-1213"><span class="linenos">1213</span></a> <span class="k">def</span> <span class="nf">blockcompressionproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">BlockCompressionProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1214"><a href="#Generator-1214"><span class="linenos">1214</span></a> <span class="n">autotemp</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">"autotemp"</span><span class="p">)</span> -</span><span id="Generator-1215"><a href="#Generator-1215"><span class="linenos">1215</span></a> <span class="n">always</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">"always"</span><span class="p">)</span> -</span><span id="Generator-1216"><a href="#Generator-1216"><span class="linenos">1216</span></a> <span class="n">default</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">"default"</span><span class="p">)</span> -</span><span id="Generator-1217"><a href="#Generator-1217"><span class="linenos">1217</span></a> <span class="n">manual</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">"manual"</span><span class="p">)</span> -</span><span id="Generator-1218"><a href="#Generator-1218"><span class="linenos">1218</span></a> <span class="n">never</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">"never"</span><span class="p">)</span> -</span><span id="Generator-1219"><a href="#Generator-1219"><span class="linenos">1219</span></a> -</span><span id="Generator-1220"><a href="#Generator-1220"><span class="linenos">1220</span></a> <span class="k">if</span> <span class="n">autotemp</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Generator-1221"><a href="#Generator-1221"><span class="linenos">1221</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"AUTOTEMP(</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">autotemp</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="Generator-1222"><a href="#Generator-1222"><span class="linenos">1222</span></a> <span class="k">elif</span> <span class="n">always</span><span class="p">:</span> -</span><span id="Generator-1223"><a href="#Generator-1223"><span class="linenos">1223</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"ALWAYS"</span> -</span><span id="Generator-1224"><a href="#Generator-1224"><span class="linenos">1224</span></a> <span class="k">elif</span> <span class="n">default</span><span class="p">:</span> -</span><span id="Generator-1225"><a href="#Generator-1225"><span class="linenos">1225</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"DEFAULT"</span> -</span><span id="Generator-1226"><a href="#Generator-1226"><span class="linenos">1226</span></a> <span class="k">elif</span> <span class="n">manual</span><span class="p">:</span> -</span><span id="Generator-1227"><a href="#Generator-1227"><span class="linenos">1227</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"MANUAL"</span> -</span><span id="Generator-1228"><a href="#Generator-1228"><span class="linenos">1228</span></a> <span class="k">elif</span> <span class="n">never</span><span class="p">:</span> -</span><span id="Generator-1229"><a href="#Generator-1229"><span class="linenos">1229</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"NEVER"</span> -</span><span id="Generator-1230"><a href="#Generator-1230"><span class="linenos">1230</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"BLOCKCOMPRESSION=</span><span class="si">{</span><span class="n">prop</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1231"><a href="#Generator-1231"><span class="linenos">1231</span></a> -</span><span id="Generator-1232"><a href="#Generator-1232"><span class="linenos">1232</span></a> <span class="k">def</span> <span class="nf">isolatedloadingproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">IsolatedLoadingProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1233"><a href="#Generator-1233"><span class="linenos">1233</span></a> <span class="n">no</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">"no"</span><span class="p">)</span> -</span><span id="Generator-1234"><a href="#Generator-1234"><span class="linenos">1234</span></a> <span class="n">no</span> <span class="o">=</span> <span class="s2">" NO"</span> <span class="k">if</span> <span class="n">no</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1235"><a href="#Generator-1235"><span class="linenos">1235</span></a> <span class="n">concurrent</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">"concurrent"</span><span class="p">)</span> -</span><span id="Generator-1236"><a href="#Generator-1236"><span class="linenos">1236</span></a> <span class="n">concurrent</span> <span class="o">=</span> <span class="s2">" CONCURRENT"</span> <span class="k">if</span> <span class="n">concurrent</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1237"><a href="#Generator-1237"><span class="linenos">1237</span></a> -</span><span id="Generator-1238"><a href="#Generator-1238"><span class="linenos">1238</span></a> <span class="n">for_</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator-1239"><a href="#Generator-1239"><span class="linenos">1239</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">"for_all"</span><span class="p">):</span> -</span><span id="Generator-1240"><a href="#Generator-1240"><span class="linenos">1240</span></a> <span class="n">for_</span> <span class="o">=</span> <span class="s2">" FOR ALL"</span> -</span><span id="Generator-1241"><a href="#Generator-1241"><span class="linenos">1241</span></a> <span class="k">elif</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">"for_insert"</span><span class="p">):</span> -</span><span id="Generator-1242"><a href="#Generator-1242"><span class="linenos">1242</span></a> <span class="n">for_</span> <span class="o">=</span> <span class="s2">" FOR INSERT"</span> -</span><span id="Generator-1243"><a href="#Generator-1243"><span class="linenos">1243</span></a> <span class="k">elif</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">"for_none"</span><span class="p">):</span> -</span><span id="Generator-1244"><a href="#Generator-1244"><span class="linenos">1244</span></a> <span class="n">for_</span> <span class="o">=</span> <span class="s2">" FOR NONE"</span> -</span><span id="Generator-1245"><a href="#Generator-1245"><span class="linenos">1245</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"WITH</span><span class="si">{</span><span class="n">no</span><span class="si">}{</span><span class="n">concurrent</span><span class="si">}</span><span class="s2"> ISOLATED LOADING</span><span class="si">{</span><span class="n">for_</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1246"><a href="#Generator-1246"><span class="linenos">1246</span></a> -</span><span id="Generator-1247"><a href="#Generator-1247"><span class="linenos">1247</span></a> <span class="k">def</span> <span class="nf">partitionboundspec_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionBoundSpec</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1248"><a href="#Generator-1248"><span class="linenos">1248</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">this</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span> -</span><span id="Generator-1249"><a href="#Generator-1249"><span class="linenos">1249</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"IN (</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">'this'</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-1250"><a href="#Generator-1250"><span class="linenos">1250</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">:</span> -</span><span id="Generator-1251"><a href="#Generator-1251"><span class="linenos">1251</span></a> <span class="n">modulus</span> <span class="o">=</span> <span class="bp">self</span><span 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-1252"><a href="#Generator-1252"><span class="linenos">1252</span></a> <span class="n">remainder</span> <span class="o">=</span> <span class="bp">self</span><span 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-1253"><a href="#Generator-1253"><span class="linenos">1253</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"WITH (MODULUS </span><span class="si">{</span><span class="n">modulus</span><span class="si">}</span><span class="s2">, REMAINDER </span><span class="si">{</span><span class="n">remainder</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="Generator-1254"><a href="#Generator-1254"><span class="linenos">1254</span></a> -</span><span id="Generator-1255"><a href="#Generator-1255"><span class="linenos">1255</span></a> <span class="n">from_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">"from_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-1256"><a href="#Generator-1256"><span class="linenos">1256</span></a> <span class="n">to_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">"to_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-1257"><a href="#Generator-1257"><span class="linenos">1257</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"FROM (</span><span class="si">{</span><span class="n">from_expressions</span><span class="si">}</span><span class="s2">) TO (</span><span class="si">{</span><span class="n">to_expressions</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="Generator-1258"><a href="#Generator-1258"><span class="linenos">1258</span></a> -</span><span id="Generator-1259"><a href="#Generator-1259"><span class="linenos">1259</span></a> <span class="k">def</span> <span class="nf">partitionedofproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionedOfProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1260"><a href="#Generator-1260"><span class="linenos">1260</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-1261"><a href="#Generator-1261"><span class="linenos">1261</span></a> -</span><span id="Generator-1262"><a href="#Generator-1262"><span class="linenos">1262</span></a> <span class="n">for_values_or_default</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span> -</span><span id="Generator-1263"><a href="#Generator-1263"><span class="linenos">1263</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">for_values_or_default</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionBoundSpec</span><span class="p">):</span> -</span><span id="Generator-1264"><a href="#Generator-1264"><span class="linenos">1264</span></a> <span class="n">for_values_or_default</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" FOR 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">for_values_or_default</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1265"><a href="#Generator-1265"><span class="linenos">1265</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator-1266"><a href="#Generator-1266"><span class="linenos">1266</span></a> <span class="n">for_values_or_default</span> <span class="o">=</span> <span class="s2">" DEFAULT"</span> -</span><span id="Generator-1267"><a href="#Generator-1267"><span class="linenos">1267</span></a> -</span><span id="Generator-1268"><a href="#Generator-1268"><span class="linenos">1268</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PARTITION OF </span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">for_values_or_default</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1269"><a href="#Generator-1269"><span class="linenos">1269</span></a> -</span><span id="Generator-1270"><a href="#Generator-1270"><span class="linenos">1270</span></a> <span class="k">def</span> <span class="nf">lockingproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">LockingProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1271"><a href="#Generator-1271"><span class="linenos">1271</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="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">)</span> -</span><span id="Generator-1272"><a href="#Generator-1272"><span class="linenos">1272</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="bp">self</span><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="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-1273"><a href="#Generator-1273"><span class="linenos">1273</span></a> <span class="n">for_or_in</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">"for_or_in"</span><span class="p">)</span> -</span><span id="Generator-1274"><a href="#Generator-1274"><span class="linenos">1274</span></a> <span class="n">for_or_in</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">for_or_in</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">for_or_in</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1275"><a href="#Generator-1275"><span class="linenos">1275</span></a> <span class="n">lock_type</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">"lock_type"</span><span class="p">)</span> -</span><span id="Generator-1276"><a href="#Generator-1276"><span class="linenos">1276</span></a> <span class="n">override</span> <span class="o">=</span> <span class="s2">" OVERRIDE"</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">"override"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1277"><a href="#Generator-1277"><span class="linenos">1277</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"LOCKING </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">for_or_in</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">lock_type</span><span class="si">}{</span><span class="n">override</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1278"><a href="#Generator-1278"><span class="linenos">1278</span></a> -</span><span id="Generator-1279"><a href="#Generator-1279"><span class="linenos">1279</span></a> <span class="k">def</span> <span class="nf">withdataproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">WithDataProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1280"><a href="#Generator-1280"><span class="linenos">1280</span></a> <span class="n">data_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"WITH </span><span class="si">{</span><span class="s1">'NO '</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">'no'</span><span class="p">)</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">DATA"</span> -</span><span id="Generator-1281"><a href="#Generator-1281"><span class="linenos">1281</span></a> <span class="n">statistics</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">"statistics"</span><span class="p">)</span> -</span><span id="Generator-1282"><a href="#Generator-1282"><span class="linenos">1282</span></a> <span class="n">statistics_sql</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator-1283"><a href="#Generator-1283"><span class="linenos">1283</span></a> <span class="k">if</span> <span class="n">statistics</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Generator-1284"><a href="#Generator-1284"><span class="linenos">1284</span></a> <span class="n">statistics_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AND </span><span class="si">{</span><span class="s1">'NO '</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="ow">not</span><span class="w"> </span><span class="n">statistics</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">STATISTICS"</span> -</span><span id="Generator-1285"><a href="#Generator-1285"><span class="linenos">1285</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">data_sql</span><span class="si">}{</span><span class="n">statistics_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1286"><a href="#Generator-1286"><span class="linenos">1286</span></a> -</span><span id="Generator-1287"><a href="#Generator-1287"><span class="linenos">1287</span></a> <span class="k">def</span> <span class="nf">withsystemversioningproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">WithSystemVersioningProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1288"><a href="#Generator-1288"><span class="linenos">1288</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="s2">"WITH(SYSTEM_VERSIONING=ON"</span> -</span><span id="Generator-1289"><a href="#Generator-1289"><span class="linenos">1289</span></a> -</span><span id="Generator-1290"><a href="#Generator-1290"><span class="linenos">1290</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">:</span> -</span><span id="Generator-1291"><a href="#Generator-1291"><span class="linenos">1291</span></a> <span class="n">history_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">"this"</span><span class="p">)</span> -</span><span id="Generator-1292"><a href="#Generator-1292"><span class="linenos">1292</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="s2">(HISTORY_TABLE=</span><span class="si">{</span><span class="n">history_table</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1293"><a href="#Generator-1293"><span class="linenos">1293</span></a> -</span><span id="Generator-1294"><a href="#Generator-1294"><span class="linenos">1294</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span><span class="p">:</span> -</span><span id="Generator-1295"><a href="#Generator-1295"><span class="linenos">1295</span></a> <span class="n">data_consistency_check</span> <span class="o">=</span> <span class="bp">self</span><span 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-1296"><a href="#Generator-1296"><span class="linenos">1296</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="s2">, DATA_CONSISTENCY_CHECK=</span><span class="si">{</span><span class="n">data_consistency_check</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1297"><a href="#Generator-1297"><span class="linenos">1297</span></a> -</span><span id="Generator-1298"><a href="#Generator-1298"><span class="linenos">1298</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="s2">)"</span> +</span><span id="Generator-1174"><a href="#Generator-1174"><span class="linenos">1174</span></a> <span class="k">def</span> <span class="nf">checksumproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ChecksumProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1175"><a href="#Generator-1175"><span class="linenos">1175</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">"default"</span><span class="p">):</span> +</span><span id="Generator-1176"><a href="#Generator-1176"><span class="linenos">1176</span></a> <span class="nb">property</span> <span class="o">=</span> <span class="s2">"DEFAULT"</span> +</span><span id="Generator-1177"><a href="#Generator-1177"><span class="linenos">1177</span></a> <span class="k">elif</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">"on"</span><span class="p">):</span> +</span><span id="Generator-1178"><a href="#Generator-1178"><span class="linenos">1178</span></a> <span class="nb">property</span> <span class="o">=</span> <span class="s2">"ON"</span> +</span><span id="Generator-1179"><a href="#Generator-1179"><span class="linenos">1179</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator-1180"><a href="#Generator-1180"><span class="linenos">1180</span></a> <span class="nb">property</span> <span class="o">=</span> <span class="s2">"OFF"</span> +</span><span id="Generator-1181"><a href="#Generator-1181"><span class="linenos">1181</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CHECKSUM=</span><span class="si">{</span><span class="nb">property</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1182"><a href="#Generator-1182"><span class="linenos">1182</span></a> +</span><span id="Generator-1183"><a href="#Generator-1183"><span class="linenos">1183</span></a> <span class="k">def</span> <span class="nf">mergeblockratioproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">MergeBlockRatioProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1184"><a href="#Generator-1184"><span class="linenos">1184</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">"no"</span><span class="p">):</span> +</span><span id="Generator-1185"><a href="#Generator-1185"><span class="linenos">1185</span></a> <span class="k">return</span> <span class="s2">"NO MERGEBLOCKRATIO"</span> +</span><span id="Generator-1186"><a href="#Generator-1186"><span class="linenos">1186</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">"default"</span><span class="p">):</span> +</span><span id="Generator-1187"><a href="#Generator-1187"><span class="linenos">1187</span></a> <span class="k">return</span> <span class="s2">"DEFAULT MERGEBLOCKRATIO"</span> +</span><span id="Generator-1188"><a href="#Generator-1188"><span class="linenos">1188</span></a> +</span><span id="Generator-1189"><a href="#Generator-1189"><span class="linenos">1189</span></a> <span class="n">percent</span> <span class="o">=</span> <span class="s2">" PERCENT"</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">"percent"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1190"><a href="#Generator-1190"><span class="linenos">1190</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"MERGEBLOCKRATIO=</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">percent</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1191"><a href="#Generator-1191"><span class="linenos">1191</span></a> +</span><span id="Generator-1192"><a href="#Generator-1192"><span class="linenos">1192</span></a> <span class="k">def</span> <span class="nf">datablocksizeproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataBlocksizeProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1193"><a href="#Generator-1193"><span class="linenos">1193</span></a> <span class="n">default</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">"default"</span><span class="p">)</span> +</span><span id="Generator-1194"><a href="#Generator-1194"><span class="linenos">1194</span></a> <span class="n">minimum</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">"minimum"</span><span class="p">)</span> +</span><span id="Generator-1195"><a href="#Generator-1195"><span class="linenos">1195</span></a> <span class="n">maximum</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">"maximum"</span><span class="p">)</span> +</span><span id="Generator-1196"><a href="#Generator-1196"><span class="linenos">1196</span></a> <span class="k">if</span> <span class="n">default</span> <span class="ow">or</span> <span class="n">minimum</span> <span class="ow">or</span> <span class="n">maximum</span><span class="p">:</span> +</span><span id="Generator-1197"><a href="#Generator-1197"><span class="linenos">1197</span></a> <span class="k">if</span> <span class="n">default</span><span class="p">:</span> +</span><span id="Generator-1198"><a href="#Generator-1198"><span class="linenos">1198</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"DEFAULT"</span> +</span><span id="Generator-1199"><a href="#Generator-1199"><span class="linenos">1199</span></a> <span class="k">elif</span> <span class="n">minimum</span><span class="p">:</span> +</span><span id="Generator-1200"><a href="#Generator-1200"><span class="linenos">1200</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"MINIMUM"</span> +</span><span id="Generator-1201"><a href="#Generator-1201"><span class="linenos">1201</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator-1202"><a href="#Generator-1202"><span class="linenos">1202</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"MAXIMUM"</span> +</span><span id="Generator-1203"><a href="#Generator-1203"><span class="linenos">1203</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">prop</span><span class="si">}</span><span class="s2"> DATABLOCKSIZE"</span> +</span><span id="Generator-1204"><a href="#Generator-1204"><span class="linenos">1204</span></a> <span class="n">units</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">"units"</span><span class="p">)</span> +</span><span id="Generator-1205"><a href="#Generator-1205"><span class="linenos">1205</span></a> <span class="n">units</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">units</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">units</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1206"><a href="#Generator-1206"><span class="linenos">1206</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"DATABLOCKSIZE=</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">'size'</span><span class="p">)</span><span class="si">}{</span><span class="n">units</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1207"><a href="#Generator-1207"><span class="linenos">1207</span></a> +</span><span id="Generator-1208"><a href="#Generator-1208"><span class="linenos">1208</span></a> <span class="k">def</span> <span class="nf">blockcompressionproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">BlockCompressionProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1209"><a href="#Generator-1209"><span class="linenos">1209</span></a> <span class="n">autotemp</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">"autotemp"</span><span class="p">)</span> +</span><span id="Generator-1210"><a href="#Generator-1210"><span class="linenos">1210</span></a> <span class="n">always</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">"always"</span><span class="p">)</span> +</span><span id="Generator-1211"><a href="#Generator-1211"><span class="linenos">1211</span></a> <span class="n">default</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">"default"</span><span class="p">)</span> +</span><span id="Generator-1212"><a href="#Generator-1212"><span class="linenos">1212</span></a> <span class="n">manual</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">"manual"</span><span class="p">)</span> +</span><span id="Generator-1213"><a href="#Generator-1213"><span class="linenos">1213</span></a> <span class="n">never</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">"never"</span><span class="p">)</span> +</span><span id="Generator-1214"><a href="#Generator-1214"><span class="linenos">1214</span></a> +</span><span id="Generator-1215"><a href="#Generator-1215"><span class="linenos">1215</span></a> <span class="k">if</span> <span class="n">autotemp</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Generator-1216"><a href="#Generator-1216"><span class="linenos">1216</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"AUTOTEMP(</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">autotemp</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Generator-1217"><a href="#Generator-1217"><span class="linenos">1217</span></a> <span class="k">elif</span> <span class="n">always</span><span class="p">:</span> +</span><span id="Generator-1218"><a href="#Generator-1218"><span class="linenos">1218</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"ALWAYS"</span> +</span><span id="Generator-1219"><a href="#Generator-1219"><span class="linenos">1219</span></a> <span class="k">elif</span> <span class="n">default</span><span class="p">:</span> +</span><span id="Generator-1220"><a href="#Generator-1220"><span class="linenos">1220</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"DEFAULT"</span> +</span><span id="Generator-1221"><a href="#Generator-1221"><span class="linenos">1221</span></a> <span class="k">elif</span> <span class="n">manual</span><span class="p">:</span> +</span><span id="Generator-1222"><a href="#Generator-1222"><span class="linenos">1222</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"MANUAL"</span> +</span><span id="Generator-1223"><a href="#Generator-1223"><span class="linenos">1223</span></a> <span class="k">elif</span> <span class="n">never</span><span class="p">:</span> +</span><span id="Generator-1224"><a href="#Generator-1224"><span class="linenos">1224</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"NEVER"</span> +</span><span id="Generator-1225"><a href="#Generator-1225"><span class="linenos">1225</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"BLOCKCOMPRESSION=</span><span class="si">{</span><span class="n">prop</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1226"><a href="#Generator-1226"><span class="linenos">1226</span></a> +</span><span id="Generator-1227"><a href="#Generator-1227"><span class="linenos">1227</span></a> <span class="k">def</span> <span class="nf">isolatedloadingproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">IsolatedLoadingProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1228"><a href="#Generator-1228"><span class="linenos">1228</span></a> <span class="n">no</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">"no"</span><span class="p">)</span> +</span><span id="Generator-1229"><a href="#Generator-1229"><span class="linenos">1229</span></a> <span class="n">no</span> <span class="o">=</span> <span class="s2">" NO"</span> <span class="k">if</span> <span class="n">no</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1230"><a href="#Generator-1230"><span class="linenos">1230</span></a> <span class="n">concurrent</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">"concurrent"</span><span class="p">)</span> +</span><span id="Generator-1231"><a href="#Generator-1231"><span class="linenos">1231</span></a> <span class="n">concurrent</span> <span class="o">=</span> <span class="s2">" CONCURRENT"</span> <span class="k">if</span> <span class="n">concurrent</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1232"><a href="#Generator-1232"><span class="linenos">1232</span></a> +</span><span id="Generator-1233"><a href="#Generator-1233"><span class="linenos">1233</span></a> <span class="n">for_</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator-1234"><a href="#Generator-1234"><span class="linenos">1234</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">"for_all"</span><span class="p">):</span> +</span><span id="Generator-1235"><a href="#Generator-1235"><span class="linenos">1235</span></a> <span class="n">for_</span> <span class="o">=</span> <span class="s2">" FOR ALL"</span> +</span><span id="Generator-1236"><a href="#Generator-1236"><span class="linenos">1236</span></a> <span class="k">elif</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">"for_insert"</span><span class="p">):</span> +</span><span id="Generator-1237"><a href="#Generator-1237"><span class="linenos">1237</span></a> <span class="n">for_</span> <span class="o">=</span> <span class="s2">" FOR INSERT"</span> +</span><span id="Generator-1238"><a href="#Generator-1238"><span class="linenos">1238</span></a> <span class="k">elif</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">"for_none"</span><span class="p">):</span> +</span><span id="Generator-1239"><a href="#Generator-1239"><span class="linenos">1239</span></a> <span class="n">for_</span> <span class="o">=</span> <span class="s2">" FOR NONE"</span> +</span><span id="Generator-1240"><a href="#Generator-1240"><span class="linenos">1240</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"WITH</span><span class="si">{</span><span class="n">no</span><span class="si">}{</span><span class="n">concurrent</span><span class="si">}</span><span class="s2"> ISOLATED LOADING</span><span class="si">{</span><span class="n">for_</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1241"><a href="#Generator-1241"><span class="linenos">1241</span></a> +</span><span id="Generator-1242"><a href="#Generator-1242"><span class="linenos">1242</span></a> <span class="k">def</span> <span class="nf">partitionboundspec_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionBoundSpec</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1243"><a href="#Generator-1243"><span class="linenos">1243</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">this</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span> +</span><span id="Generator-1244"><a href="#Generator-1244"><span class="linenos">1244</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"IN (</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">'this'</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-1245"><a href="#Generator-1245"><span class="linenos">1245</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">:</span> +</span><span id="Generator-1246"><a href="#Generator-1246"><span class="linenos">1246</span></a> <span class="n">modulus</span> <span class="o">=</span> <span class="bp">self</span><span 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-1247"><a href="#Generator-1247"><span class="linenos">1247</span></a> <span class="n">remainder</span> <span class="o">=</span> <span class="bp">self</span><span 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-1248"><a href="#Generator-1248"><span class="linenos">1248</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"WITH (MODULUS </span><span class="si">{</span><span class="n">modulus</span><span class="si">}</span><span class="s2">, REMAINDER </span><span class="si">{</span><span class="n">remainder</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Generator-1249"><a href="#Generator-1249"><span class="linenos">1249</span></a> +</span><span id="Generator-1250"><a href="#Generator-1250"><span class="linenos">1250</span></a> <span class="n">from_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">"from_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-1251"><a href="#Generator-1251"><span class="linenos">1251</span></a> <span class="n">to_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">"to_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-1252"><a href="#Generator-1252"><span class="linenos">1252</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"FROM (</span><span class="si">{</span><span class="n">from_expressions</span><span class="si">}</span><span class="s2">) TO (</span><span class="si">{</span><span class="n">to_expressions</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Generator-1253"><a href="#Generator-1253"><span class="linenos">1253</span></a> +</span><span id="Generator-1254"><a href="#Generator-1254"><span class="linenos">1254</span></a> <span class="k">def</span> <span class="nf">partitionedofproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionedOfProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1255"><a href="#Generator-1255"><span class="linenos">1255</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-1256"><a href="#Generator-1256"><span class="linenos">1256</span></a> +</span><span id="Generator-1257"><a href="#Generator-1257"><span class="linenos">1257</span></a> <span class="n">for_values_or_default</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span> +</span><span id="Generator-1258"><a href="#Generator-1258"><span class="linenos">1258</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">for_values_or_default</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionBoundSpec</span><span class="p">):</span> +</span><span id="Generator-1259"><a href="#Generator-1259"><span class="linenos">1259</span></a> <span class="n">for_values_or_default</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" FOR 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">for_values_or_default</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1260"><a href="#Generator-1260"><span class="linenos">1260</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator-1261"><a href="#Generator-1261"><span class="linenos">1261</span></a> <span class="n">for_values_or_default</span> <span class="o">=</span> <span class="s2">" DEFAULT"</span> +</span><span id="Generator-1262"><a href="#Generator-1262"><span class="linenos">1262</span></a> +</span><span id="Generator-1263"><a href="#Generator-1263"><span class="linenos">1263</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PARTITION OF </span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">for_values_or_default</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1264"><a href="#Generator-1264"><span class="linenos">1264</span></a> +</span><span id="Generator-1265"><a href="#Generator-1265"><span class="linenos">1265</span></a> <span class="k">def</span> <span class="nf">lockingproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">LockingProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1266"><a href="#Generator-1266"><span class="linenos">1266</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="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">)</span> +</span><span id="Generator-1267"><a href="#Generator-1267"><span class="linenos">1267</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="bp">self</span><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="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-1268"><a href="#Generator-1268"><span class="linenos">1268</span></a> <span class="n">for_or_in</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">"for_or_in"</span><span class="p">)</span> +</span><span id="Generator-1269"><a href="#Generator-1269"><span class="linenos">1269</span></a> <span class="n">for_or_in</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">for_or_in</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">for_or_in</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1270"><a href="#Generator-1270"><span class="linenos">1270</span></a> <span class="n">lock_type</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">"lock_type"</span><span class="p">)</span> +</span><span id="Generator-1271"><a href="#Generator-1271"><span class="linenos">1271</span></a> <span class="n">override</span> <span class="o">=</span> <span class="s2">" OVERRIDE"</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">"override"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1272"><a href="#Generator-1272"><span class="linenos">1272</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"LOCKING </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">for_or_in</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">lock_type</span><span class="si">}{</span><span class="n">override</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1273"><a href="#Generator-1273"><span class="linenos">1273</span></a> +</span><span id="Generator-1274"><a href="#Generator-1274"><span class="linenos">1274</span></a> <span class="k">def</span> <span class="nf">withdataproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">WithDataProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1275"><a href="#Generator-1275"><span class="linenos">1275</span></a> <span class="n">data_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"WITH </span><span class="si">{</span><span class="s1">'NO '</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">'no'</span><span class="p">)</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">DATA"</span> +</span><span id="Generator-1276"><a href="#Generator-1276"><span class="linenos">1276</span></a> <span class="n">statistics</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">"statistics"</span><span class="p">)</span> +</span><span id="Generator-1277"><a href="#Generator-1277"><span class="linenos">1277</span></a> <span class="n">statistics_sql</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator-1278"><a href="#Generator-1278"><span class="linenos">1278</span></a> <span class="k">if</span> <span class="n">statistics</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Generator-1279"><a href="#Generator-1279"><span class="linenos">1279</span></a> <span class="n">statistics_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AND </span><span class="si">{</span><span class="s1">'NO '</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="ow">not</span><span class="w"> </span><span class="n">statistics</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">STATISTICS"</span> +</span><span id="Generator-1280"><a href="#Generator-1280"><span class="linenos">1280</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">data_sql</span><span class="si">}{</span><span class="n">statistics_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1281"><a href="#Generator-1281"><span class="linenos">1281</span></a> +</span><span id="Generator-1282"><a href="#Generator-1282"><span class="linenos">1282</span></a> <span class="k">def</span> <span class="nf">withsystemversioningproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">WithSystemVersioningProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1283"><a href="#Generator-1283"><span class="linenos">1283</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="s2">"WITH(SYSTEM_VERSIONING=ON"</span> +</span><span id="Generator-1284"><a href="#Generator-1284"><span class="linenos">1284</span></a> +</span><span id="Generator-1285"><a href="#Generator-1285"><span class="linenos">1285</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">:</span> +</span><span id="Generator-1286"><a href="#Generator-1286"><span class="linenos">1286</span></a> <span class="n">history_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">"this"</span><span class="p">)</span> +</span><span id="Generator-1287"><a href="#Generator-1287"><span class="linenos">1287</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="s2">(HISTORY_TABLE=</span><span class="si">{</span><span class="n">history_table</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1288"><a href="#Generator-1288"><span class="linenos">1288</span></a> +</span><span id="Generator-1289"><a href="#Generator-1289"><span class="linenos">1289</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span><span class="p">:</span> +</span><span id="Generator-1290"><a href="#Generator-1290"><span class="linenos">1290</span></a> <span class="n">data_consistency_check</span> <span class="o">=</span> <span class="bp">self</span><span 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-1291"><a href="#Generator-1291"><span class="linenos">1291</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="s2">, DATA_CONSISTENCY_CHECK=</span><span class="si">{</span><span class="n">data_consistency_check</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1292"><a href="#Generator-1292"><span class="linenos">1292</span></a> +</span><span id="Generator-1293"><a href="#Generator-1293"><span class="linenos">1293</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="s2">)"</span> +</span><span id="Generator-1294"><a href="#Generator-1294"><span class="linenos">1294</span></a> +</span><span id="Generator-1295"><a href="#Generator-1295"><span class="linenos">1295</span></a> <span class="k">return</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="s2">)"</span> +</span><span id="Generator-1296"><a href="#Generator-1296"><span class="linenos">1296</span></a> +</span><span id="Generator-1297"><a href="#Generator-1297"><span class="linenos">1297</span></a> <span class="k">def</span> <span class="nf">insert_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">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 class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1298"><a href="#Generator-1298"><span class="linenos">1298</span></a> <span class="n">overwrite</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">"overwrite"</span><span class="p">)</span> </span><span id="Generator-1299"><a href="#Generator-1299"><span class="linenos">1299</span></a> -</span><span id="Generator-1300"><a href="#Generator-1300"><span class="linenos">1300</span></a> <span class="k">return</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="s2">)"</span> -</span><span id="Generator-1301"><a href="#Generator-1301"><span class="linenos">1301</span></a> -</span><span id="Generator-1302"><a href="#Generator-1302"><span class="linenos">1302</span></a> <span class="k">def</span> <span class="nf">insert_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">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 class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1303"><a href="#Generator-1303"><span class="linenos">1303</span></a> <span class="n">overwrite</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">"overwrite"</span><span class="p">)</span> +</span><span id="Generator-1300"><a href="#Generator-1300"><span class="linenos">1300</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">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Directory</span><span class="p">):</span> +</span><span id="Generator-1301"><a href="#Generator-1301"><span class="linenos">1301</span></a> <span class="n">this</span> <span class="o">=</span> <span class="s2">" OVERWRITE"</span> <span class="k">if</span> <span class="n">overwrite</span> <span class="k">else</span> <span class="s2">" INTO"</span> +</span><span id="Generator-1302"><a href="#Generator-1302"><span class="linenos">1302</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator-1303"><a href="#Generator-1303"><span class="linenos">1303</span></a> <span class="n">this</span> <span class="o">=</span> <span class="s2">" OVERWRITE TABLE"</span> <span class="k">if</span> <span class="n">overwrite</span> <span class="k">else</span> <span class="s2">" INTO"</span> </span><span id="Generator-1304"><a href="#Generator-1304"><span class="linenos">1304</span></a> -</span><span id="Generator-1305"><a href="#Generator-1305"><span class="linenos">1305</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">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Directory</span><span class="p">):</span> -</span><span id="Generator-1306"><a href="#Generator-1306"><span class="linenos">1306</span></a> <span class="n">this</span> <span class="o">=</span> <span class="s2">" OVERWRITE"</span> <span class="k">if</span> <span class="n">overwrite</span> <span class="k">else</span> <span class="s2">" INTO"</span> -</span><span id="Generator-1307"><a href="#Generator-1307"><span class="linenos">1307</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator-1308"><a href="#Generator-1308"><span class="linenos">1308</span></a> <span class="n">this</span> <span class="o">=</span> <span class="s2">" OVERWRITE TABLE"</span> <span class="k">if</span> <span class="n">overwrite</span> <span class="k">else</span> <span class="s2">" INTO"</span> -</span><span id="Generator-1309"><a href="#Generator-1309"><span class="linenos">1309</span></a> -</span><span id="Generator-1310"><a href="#Generator-1310"><span class="linenos">1310</span></a> <span class="n">alternative</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">"alternative"</span><span class="p">)</span> -</span><span id="Generator-1311"><a href="#Generator-1311"><span class="linenos">1311</span></a> <span class="n">alternative</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" OR </span><span class="si">{</span><span class="n">alternative</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alternative</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1312"><a href="#Generator-1312"><span class="linenos">1312</span></a> <span class="n">ignore</span> <span class="o">=</span> <span class="s2">" IGNORE"</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">"ignore"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1313"><a href="#Generator-1313"><span class="linenos">1313</span></a> -</span><span id="Generator-1314"><a href="#Generator-1314"><span class="linenos">1314</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="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-1315"><a href="#Generator-1315"><span class="linenos">1315</span></a> -</span><span id="Generator-1316"><a href="#Generator-1316"><span class="linenos">1316</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-1317"><a href="#Generator-1317"><span class="linenos">1317</span></a> <span class="n">partition_sql</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Generator-1318"><a href="#Generator-1318"><span class="linenos">1318</span></a> <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">'partition'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</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">"partition"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1319"><a href="#Generator-1319"><span class="linenos">1319</span></a> <span class="p">)</span> -</span><span id="Generator-1320"><a href="#Generator-1320"><span class="linenos">1320</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-1321"><a href="#Generator-1321"><span class="linenos">1321</span></a> <span class="n">where</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="si">}</span><span class="s2">REPLACE WHERE </span><span class="si">{</span><span class="n">where</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">where</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1322"><a href="#Generator-1322"><span class="linenos">1322</span></a> <span class="n">expression_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">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-1323"><a href="#Generator-1323"><span class="linenos">1323</span></a> <span class="n">conflict</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"conflict"</span><span class="p">)</span> -</span><span id="Generator-1324"><a href="#Generator-1324"><span class="linenos">1324</span></a> <span class="n">by_name</span> <span class="o">=</span> <span class="s2">" BY NAME"</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">"by_name"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1325"><a href="#Generator-1325"><span class="linenos">1325</span></a> <span class="n">returning</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"returning"</span><span class="p">)</span> +</span><span id="Generator-1305"><a href="#Generator-1305"><span class="linenos">1305</span></a> <span class="n">alternative</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">"alternative"</span><span class="p">)</span> +</span><span id="Generator-1306"><a href="#Generator-1306"><span class="linenos">1306</span></a> <span class="n">alternative</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" OR </span><span class="si">{</span><span class="n">alternative</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alternative</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1307"><a href="#Generator-1307"><span class="linenos">1307</span></a> <span class="n">ignore</span> <span class="o">=</span> <span class="s2">" IGNORE"</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">"ignore"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1308"><a href="#Generator-1308"><span class="linenos">1308</span></a> +</span><span id="Generator-1309"><a href="#Generator-1309"><span class="linenos">1309</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="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-1310"><a href="#Generator-1310"><span class="linenos">1310</span></a> +</span><span id="Generator-1311"><a href="#Generator-1311"><span class="linenos">1311</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-1312"><a href="#Generator-1312"><span class="linenos">1312</span></a> <span class="n">partition_sql</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Generator-1313"><a href="#Generator-1313"><span class="linenos">1313</span></a> <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">'partition'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</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">"partition"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1314"><a href="#Generator-1314"><span class="linenos">1314</span></a> <span class="p">)</span> +</span><span id="Generator-1315"><a href="#Generator-1315"><span class="linenos">1315</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-1316"><a href="#Generator-1316"><span class="linenos">1316</span></a> <span class="n">where</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="si">}</span><span class="s2">REPLACE WHERE </span><span class="si">{</span><span class="n">where</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">where</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1317"><a href="#Generator-1317"><span class="linenos">1317</span></a> <span class="n">expression_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">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-1318"><a href="#Generator-1318"><span class="linenos">1318</span></a> <span class="n">conflict</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"conflict"</span><span class="p">)</span> +</span><span id="Generator-1319"><a href="#Generator-1319"><span class="linenos">1319</span></a> <span class="n">by_name</span> <span class="o">=</span> <span class="s2">" BY NAME"</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">"by_name"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1320"><a href="#Generator-1320"><span class="linenos">1320</span></a> <span class="n">returning</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"returning"</span><span class="p">)</span> +</span><span id="Generator-1321"><a href="#Generator-1321"><span class="linenos">1321</span></a> +</span><span id="Generator-1322"><a href="#Generator-1322"><span class="linenos">1322</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">RETURNING_END</span><span class="p">:</span> +</span><span id="Generator-1323"><a href="#Generator-1323"><span class="linenos">1323</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">expression_sql</span><span class="si">}{</span><span class="n">conflict</span><span class="si">}{</span><span class="n">returning</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1324"><a href="#Generator-1324"><span class="linenos">1324</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator-1325"><a href="#Generator-1325"><span class="linenos">1325</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">returning</span><span class="si">}{</span><span class="n">expression_sql</span><span class="si">}{</span><span class="n">conflict</span><span class="si">}</span><span class="s2">"</span> </span><span id="Generator-1326"><a href="#Generator-1326"><span class="linenos">1326</span></a> -</span><span id="Generator-1327"><a href="#Generator-1327"><span class="linenos">1327</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">RETURNING_END</span><span class="p">:</span> -</span><span id="Generator-1328"><a href="#Generator-1328"><span class="linenos">1328</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">expression_sql</span><span class="si">}{</span><span class="n">conflict</span><span class="si">}{</span><span class="n">returning</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1329"><a href="#Generator-1329"><span class="linenos">1329</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator-1330"><a href="#Generator-1330"><span class="linenos">1330</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">returning</span><span class="si">}{</span><span class="n">expression_sql</span><span class="si">}{</span><span class="n">conflict</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1331"><a href="#Generator-1331"><span class="linenos">1331</span></a> -</span><span id="Generator-1332"><a href="#Generator-1332"><span class="linenos">1332</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"INSERT</span><span class="si">{</span><span class="n">alternative</span><span class="si">}{</span><span class="n">ignore</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="n">by_name</span><span class="si">}{</span><span class="n">exists</span><span class="si">}{</span><span class="n">partition_sql</span><span class="si">}{</span><span class="n">where</span><span class="si">}{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1333"><a href="#Generator-1333"><span class="linenos">1333</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-1334"><a href="#Generator-1334"><span class="linenos">1334</span></a> -</span><span id="Generator-1335"><a href="#Generator-1335"><span class="linenos">1335</span></a> <span class="k">def</span> <span class="nf">intersect_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Intersect</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1336"><a href="#Generator-1336"><span class="linenos">1336</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><span id="Generator-1337"><a href="#Generator-1337"><span class="linenos">1337</span></a> <span class="n">expression</span><span class="p">,</span> -</span><span id="Generator-1338"><a href="#Generator-1338"><span class="linenos">1338</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">set_operation</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">intersect_op</span><span class="p">(</span><span class="n">expression</span><span class="p">)),</span> -</span><span id="Generator-1339"><a href="#Generator-1339"><span class="linenos">1339</span></a> <span class="p">)</span> -</span><span id="Generator-1340"><a href="#Generator-1340"><span class="linenos">1340</span></a> -</span><span id="Generator-1341"><a href="#Generator-1341"><span class="linenos">1341</span></a> <span class="k">def</span> <span class="nf">intersect_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Intersect</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1342"><a href="#Generator-1342"><span class="linenos">1342</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"INTERSECT</span><span class="si">{</span><span class="s1">''</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">'distinct'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">' ALL'</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1343"><a href="#Generator-1343"><span class="linenos">1343</span></a> -</span><span id="Generator-1344"><a href="#Generator-1344"><span class="linenos">1344</span></a> <span class="k">def</span> <span class="nf">introducer_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Introducer</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1345"><a href="#Generator-1345"><span class="linenos">1345</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-1346"><a href="#Generator-1346"><span class="linenos">1346</span></a> -</span><span id="Generator-1347"><a href="#Generator-1347"><span class="linenos">1347</span></a> <span class="k">def</span> <span class="nf">kill_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Kill</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1348"><a href="#Generator-1348"><span class="linenos">1348</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-1349"><a href="#Generator-1349"><span class="linenos">1349</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-1350"><a href="#Generator-1350"><span class="linenos">1350</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-1351"><a href="#Generator-1351"><span class="linenos">1351</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-1352"><a href="#Generator-1352"><span class="linenos">1352</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"KILL</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-1353"><a href="#Generator-1353"><span class="linenos">1353</span></a> -</span><span id="Generator-1354"><a href="#Generator-1354"><span class="linenos">1354</span></a> <span class="k">def</span> <span class="nf">pseudotype_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">PseudoType</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1355"><a href="#Generator-1355"><span class="linenos">1355</span></a> <span class="k">return</span> <span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> -</span><span id="Generator-1356"><a href="#Generator-1356"><span class="linenos">1356</span></a> -</span><span id="Generator-1357"><a href="#Generator-1357"><span class="linenos">1357</span></a> <span class="k">def</span> <span class="nf">objectidentifier_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ObjectIdentifier</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1358"><a href="#Generator-1358"><span class="linenos">1358</span></a> <span class="k">return</span> <span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> -</span><span id="Generator-1359"><a href="#Generator-1359"><span class="linenos">1359</span></a> -</span><span id="Generator-1360"><a href="#Generator-1360"><span class="linenos">1360</span></a> <span class="k">def</span> <span class="nf">onconflict_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">OnConflict</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1361"><a href="#Generator-1361"><span class="linenos">1361</span></a> <span class="n">conflict</span> <span class="o">=</span> <span class="s2">"ON DUPLICATE KEY"</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">"duplicate"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">"ON CONFLICT"</span> -</span><span id="Generator-1362"><a href="#Generator-1362"><span class="linenos">1362</span></a> <span class="n">constraint</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"constraint"</span><span class="p">)</span> -</span><span id="Generator-1363"><a href="#Generator-1363"><span class="linenos">1363</span></a> <span class="k">if</span> <span class="n">constraint</span><span class="p">:</span> -</span><span id="Generator-1364"><a href="#Generator-1364"><span class="linenos">1364</span></a> <span class="n">constraint</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"ON CONSTRAINT </span><span class="si">{</span><span class="n">constraint</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1365"><a href="#Generator-1365"><span class="linenos">1365</span></a> <span class="n">key</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">"key"</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-1366"><a href="#Generator-1366"><span class="linenos">1366</span></a> <span class="n">do</span> <span class="o">=</span> <span class="s2">""</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">"duplicate"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">" DO "</span> -</span><span id="Generator-1367"><a href="#Generator-1367"><span class="linenos">1367</span></a> <span class="n">nothing</span> <span class="o">=</span> <span class="s2">"NOTHING"</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">"nothing"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1368"><a href="#Generator-1368"><span class="linenos">1368</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-1369"><a href="#Generator-1369"><span class="linenos">1369</span></a> <span class="n">set_keyword</span> <span class="o">=</span> <span class="s2">"SET "</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">DUPLICATE_KEY_UPDATE_WITH_SET</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1370"><a href="#Generator-1370"><span class="linenos">1370</span></a> <span class="k">if</span> <span class="n">expressions</span><span class="p">:</span> -</span><span id="Generator-1371"><a href="#Generator-1371"><span class="linenos">1371</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"UPDATE </span><span class="si">{</span><span class="n">set_keyword</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1372"><a href="#Generator-1372"><span class="linenos">1372</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">conflict</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">constraint</span><span class="si">}{</span><span class="n">key</span><span class="si">}{</span><span class="n">do</span><span class="si">}{</span><span class="n">nothing</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1373"><a href="#Generator-1373"><span class="linenos">1373</span></a> -</span><span id="Generator-1374"><a href="#Generator-1374"><span class="linenos">1374</span></a> <span class="k">def</span> <span class="nf">returning_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Returning</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1375"><a href="#Generator-1375"><span class="linenos">1375</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="s1">'RETURNING'</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">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-1376"><a href="#Generator-1376"><span class="linenos">1376</span></a> -</span><span id="Generator-1377"><a href="#Generator-1377"><span class="linenos">1377</span></a> <span class="k">def</span> <span class="nf">rowformatdelimitedproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RowFormatDelimitedProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1378"><a href="#Generator-1378"><span class="linenos">1378</span></a> <span class="n">fields</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">"fields"</span><span class="p">)</span> -</span><span id="Generator-1379"><a href="#Generator-1379"><span class="linenos">1379</span></a> <span class="n">fields</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" FIELDS TERMINATED BY </span><span class="si">{</span><span class="n">fields</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">fields</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1380"><a href="#Generator-1380"><span class="linenos">1380</span></a> <span class="n">escaped</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">"escaped"</span><span class="p">)</span> -</span><span id="Generator-1381"><a href="#Generator-1381"><span class="linenos">1381</span></a> <span class="n">escaped</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" ESCAPED BY </span><span class="si">{</span><span class="n">escaped</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">escaped</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1382"><a href="#Generator-1382"><span class="linenos">1382</span></a> <span class="n">items</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">"collection_items"</span><span class="p">)</span> -</span><span id="Generator-1383"><a href="#Generator-1383"><span class="linenos">1383</span></a> <span class="n">items</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" COLLECTION ITEMS TERMINATED BY </span><span class="si">{</span><span class="n">items</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">items</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1384"><a href="#Generator-1384"><span class="linenos">1384</span></a> <span class="n">keys</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">"map_keys"</span><span class="p">)</span> -</span><span id="Generator-1385"><a href="#Generator-1385"><span class="linenos">1385</span></a> <span class="n">keys</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" MAP KEYS TERMINATED BY </span><span class="si">{</span><span class="n">keys</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">keys</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1386"><a href="#Generator-1386"><span class="linenos">1386</span></a> <span class="n">lines</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">"lines"</span><span class="p">)</span> -</span><span id="Generator-1387"><a href="#Generator-1387"><span class="linenos">1387</span></a> <span class="n">lines</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" LINES TERMINATED BY </span><span class="si">{</span><span class="n">lines</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">lines</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1388"><a href="#Generator-1388"><span class="linenos">1388</span></a> <span class="n">null</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">"null"</span><span class="p">)</span> -</span><span id="Generator-1389"><a href="#Generator-1389"><span class="linenos">1389</span></a> <span class="n">null</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" NULL DEFINED AS </span><span class="si">{</span><span class="n">null</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">null</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1390"><a href="#Generator-1390"><span class="linenos">1390</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ROW FORMAT DELIMITED</span><span class="si">{</span><span class="n">fields</span><span class="si">}{</span><span class="n">escaped</span><span class="si">}{</span><span class="n">items</span><span class="si">}{</span><span class="n">keys</span><span class="si">}{</span><span class="n">lines</span><span class="si">}{</span><span class="n">null</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1391"><a href="#Generator-1391"><span class="linenos">1391</span></a> -</span><span id="Generator-1392"><a href="#Generator-1392"><span class="linenos">1392</span></a> <span class="k">def</span> <span class="nf">withtablehint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">WithTableHint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1393"><a href="#Generator-1393"><span class="linenos">1393</span></a> <span class="k">return</span> <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">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-1394"><a href="#Generator-1394"><span class="linenos">1394</span></a> -</span><span id="Generator-1395"><a href="#Generator-1395"><span class="linenos">1395</span></a> <span class="k">def</span> <span class="nf">indextablehint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">IndexTableHint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1396"><a href="#Generator-1396"><span class="linenos">1396</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="bp">self</span><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"> INDEX"</span> -</span><span id="Generator-1397"><a href="#Generator-1397"><span class="linenos">1397</span></a> <span class="n">target</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"target"</span><span class="p">)</span> -</span><span id="Generator-1398"><a href="#Generator-1398"><span class="linenos">1398</span></a> <span class="n">target</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" FOR </span><span class="si">{</span><span class="n">target</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">target</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1399"><a href="#Generator-1399"><span class="linenos">1399</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">target</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">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-1400"><a href="#Generator-1400"><span class="linenos">1400</span></a> -</span><span id="Generator-1401"><a href="#Generator-1401"><span class="linenos">1401</span></a> <span class="k">def</span> <span class="nf">table_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</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">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">" AS "</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1402"><a href="#Generator-1402"><span class="linenos">1402</span></a> <span class="n">table</span> <span class="o">=</span> <span class="s2">"."</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> -</span><span id="Generator-1403"><a href="#Generator-1403"><span class="linenos">1403</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">part</span><span class="p">)</span> -</span><span id="Generator-1404"><a href="#Generator-1404"><span class="linenos">1404</span></a> <span class="k">for</span> <span class="n">part</span> <span class="ow">in</span> <span class="p">(</span> -</span><span id="Generator-1405"><a href="#Generator-1405"><span class="linenos">1405</span></a> <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">"catalog"</span><span class="p">),</span> -</span><span id="Generator-1406"><a href="#Generator-1406"><span class="linenos">1406</span></a> <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">"db"</span><span class="p">),</span> -</span><span id="Generator-1407"><a href="#Generator-1407"><span class="linenos">1407</span></a> <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">"this"</span><span class="p">),</span> -</span><span id="Generator-1408"><a href="#Generator-1408"><span class="linenos">1408</span></a> <span class="p">)</span> -</span><span id="Generator-1409"><a href="#Generator-1409"><span class="linenos">1409</span></a> <span class="k">if</span> <span class="n">part</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> -</span><span id="Generator-1410"><a href="#Generator-1410"><span class="linenos">1410</span></a> <span class="p">)</span> -</span><span id="Generator-1411"><a href="#Generator-1411"><span class="linenos">1411</span></a> -</span><span id="Generator-1412"><a href="#Generator-1412"><span class="linenos">1412</span></a> <span class="n">version</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"version"</span><span class="p">)</span> -</span><span id="Generator-1413"><a href="#Generator-1413"><span class="linenos">1413</span></a> <span class="n">version</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">version</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">version</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1414"><a href="#Generator-1414"><span class="linenos">1414</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-1415"><a href="#Generator-1415"><span class="linenos">1415</span></a> <span class="n">alias</span> <span class="o">=</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">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-1416"><a href="#Generator-1416"><span class="linenos">1416</span></a> <span class="n">hints</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">"hints"</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-1417"><a href="#Generator-1417"><span class="linenos">1417</span></a> <span class="n">hints</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">hints</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">hints</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">TABLE_HINTS</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1418"><a href="#Generator-1418"><span class="linenos">1418</span></a> <span class="n">pivots</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">"pivots"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</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-1419"><a href="#Generator-1419"><span class="linenos">1419</span></a> <span class="n">pivots</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">pivots</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">pivots</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1420"><a href="#Generator-1420"><span class="linenos">1420</span></a> <span class="n">joins</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">"joins"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</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><span id="Generator-1421"><a href="#Generator-1421"><span class="linenos">1421</span></a> <span class="n">laterals</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">"laterals"</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-1422"><a href="#Generator-1422"><span class="linenos">1422</span></a> -</span><span id="Generator-1423"><a href="#Generator-1423"><span class="linenos">1423</span></a> <span class="n">file_format</span> <span class="o">=</span> <span class="bp">self</span><span 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-1424"><a href="#Generator-1424"><span class="linenos">1424</span></a> <span class="k">if</span> <span class="n">file_format</span><span class="p">:</span> -</span><span id="Generator-1425"><a href="#Generator-1425"><span class="linenos">1425</span></a> <span class="n">pattern</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"pattern"</span><span class="p">)</span> -</span><span id="Generator-1426"><a href="#Generator-1426"><span class="linenos">1426</span></a> <span class="n">pattern</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">", PATTERN => </span><span class="si">{</span><span class="n">pattern</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">pattern</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1427"><a href="#Generator-1427"><span class="linenos">1427</span></a> <span class="n">file_format</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" (FILE_FORMAT => </span><span class="si">{</span><span class="n">file_format</span><span class="si">}{</span><span class="n">pattern</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="Generator-1428"><a href="#Generator-1428"><span class="linenos">1428</span></a> -</span><span id="Generator-1429"><a href="#Generator-1429"><span class="linenos">1429</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span 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"</span><span class="p">)</span> -</span><span id="Generator-1430"><a href="#Generator-1430"><span class="linenos">1430</span></a> <span class="n">index</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AT </span><span class="si">{</span><span class="n">index</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">index</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1431"><a href="#Generator-1431"><span class="linenos">1431</span></a> -</span><span id="Generator-1432"><a href="#Generator-1432"><span class="linenos">1432</span></a> <span class="n">ordinality</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">"ordinality"</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">""</span> -</span><span id="Generator-1433"><a href="#Generator-1433"><span class="linenos">1433</span></a> <span class="k">if</span> <span class="n">ordinality</span><span class="p">:</span> -</span><span id="Generator-1434"><a href="#Generator-1434"><span class="linenos">1434</span></a> <span class="n">ordinality</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" WITH ORDINALITY</span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1435"><a href="#Generator-1435"><span class="linenos">1435</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator-1436"><a href="#Generator-1436"><span class="linenos">1436</span></a> -</span><span id="Generator-1437"><a href="#Generator-1437"><span class="linenos">1437</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">table</span><span class="si">}{</span><span class="n">version</span><span class="si">}{</span><span class="n">file_format</span><span class="si">}{</span><span class="n">alias</span><span class="si">}{</span><span class="n">index</span><span class="si">}{</span><span class="n">hints</span><span class="si">}{</span><span class="n">pivots</span><span class="si">}{</span><span class="n">joins</span><span class="si">}{</span><span class="n">laterals</span><span class="si">}{</span><span class="n">ordinality</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1438"><a href="#Generator-1438"><span class="linenos">1438</span></a> -</span><span id="Generator-1439"><a href="#Generator-1439"><span class="linenos">1439</span></a> <span class="k">def</span> <span class="nf">tablesample_sql</span><span class="p">(</span> -</span><span id="Generator-1440"><a href="#Generator-1440"><span class="linenos">1440</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TableSample</span><span class="p">,</span> <span class="n">seed_prefix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"SEED"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" AS "</span> -</span><span id="Generator-1441"><a href="#Generator-1441"><span class="linenos">1441</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1442"><a href="#Generator-1442"><span class="linenos">1442</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">ALIAS_POST_TABLESAMPLE</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">alias</span><span class="p">:</span> -</span><span id="Generator-1443"><a href="#Generator-1443"><span class="linenos">1443</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 class="o">.</span><span class="n">copy</span><span class="p">()</span> -</span><span id="Generator-1444"><a href="#Generator-1444"><span class="linenos">1444</span></a> <span class="n">table</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"alias"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> -</span><span id="Generator-1445"><a href="#Generator-1445"><span class="linenos">1445</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-1446"><a href="#Generator-1446"><span class="linenos">1446</span></a> <span class="n">alias</span> <span class="o">=</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="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="w"> </span><span class="s1">'alias'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1447"><a href="#Generator-1447"><span class="linenos">1447</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator-1448"><a href="#Generator-1448"><span class="linenos">1448</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-1449"><a href="#Generator-1449"><span class="linenos">1449</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator-1450"><a href="#Generator-1450"><span class="linenos">1450</span></a> -</span><span id="Generator-1451"><a href="#Generator-1451"><span class="linenos">1451</span></a> <span class="n">method</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"method"</span><span class="p">)</span> -</span><span id="Generator-1452"><a href="#Generator-1452"><span class="linenos">1452</span></a> <span class="n">method</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">method</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">method</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">TABLESAMPLE_WITH_METHOD</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1453"><a href="#Generator-1453"><span class="linenos">1453</span></a> <span class="n">numerator</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"bucket_numerator"</span><span class="p">)</span> -</span><span id="Generator-1454"><a href="#Generator-1454"><span class="linenos">1454</span></a> <span class="n">denominator</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"bucket_denominator"</span><span class="p">)</span> -</span><span id="Generator-1455"><a href="#Generator-1455"><span class="linenos">1455</span></a> <span class="n">field</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"bucket_field"</span><span class="p">)</span> -</span><span id="Generator-1456"><a href="#Generator-1456"><span class="linenos">1456</span></a> <span class="n">field</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" ON </span><span class="si">{</span><span class="n">field</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">field</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1457"><a href="#Generator-1457"><span class="linenos">1457</span></a> <span class="n">bucket</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"BUCKET </span><span class="si">{</span><span class="n">numerator</span><span class="si">}</span><span class="s2"> OUT OF </span><span class="si">{</span><span class="n">denominator</span><span class="si">}{</span><span class="n">field</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">numerator</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1458"><a href="#Generator-1458"><span class="linenos">1458</span></a> <span class="n">percent</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"percent"</span><span class="p">)</span> -</span><span id="Generator-1459"><a href="#Generator-1459"><span class="linenos">1459</span></a> <span class="n">percent</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">percent</span><span class="si">}</span><span class="s2"> PERCENT"</span> <span class="k">if</span> <span class="n">percent</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1460"><a href="#Generator-1460"><span class="linenos">1460</span></a> <span class="n">rows</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"rows"</span><span class="p">)</span> -</span><span id="Generator-1461"><a href="#Generator-1461"><span class="linenos">1461</span></a> <span class="n">rows</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">rows</span><span class="si">}</span><span class="s2"> ROWS"</span> <span class="k">if</span> <span class="n">rows</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1462"><a href="#Generator-1462"><span class="linenos">1462</span></a> -</span><span id="Generator-1463"><a href="#Generator-1463"><span class="linenos">1463</span></a> <span class="n">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">"size"</span><span class="p">)</span> -</span><span id="Generator-1464"><a href="#Generator-1464"><span class="linenos">1464</span></a> <span class="k">if</span> <span class="n">size</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">TABLESAMPLE_SIZE_IS_PERCENT</span><span class="p">:</span> -</span><span id="Generator-1465"><a href="#Generator-1465"><span class="linenos">1465</span></a> <span class="n">size</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">size</span><span class="si">}</span><span class="s2"> PERCENT"</span> -</span><span id="Generator-1466"><a href="#Generator-1466"><span class="linenos">1466</span></a> -</span><span id="Generator-1467"><a href="#Generator-1467"><span class="linenos">1467</span></a> <span class="n">seed</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"seed"</span><span class="p">)</span> -</span><span id="Generator-1468"><a href="#Generator-1468"><span class="linenos">1468</span></a> <span class="n">seed</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">seed_prefix</span><span class="si">}</span><span class="s2"> (</span><span class="si">{</span><span class="n">seed</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">seed</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1469"><a href="#Generator-1469"><span class="linenos">1469</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="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">,</span> <span class="s2">"TABLESAMPLE"</span><span class="p">)</span> -</span><span id="Generator-1470"><a href="#Generator-1470"><span class="linenos">1470</span></a> -</span><span id="Generator-1471"><a href="#Generator-1471"><span class="linenos">1471</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">bucket</span><span class="si">}{</span><span class="n">percent</span><span class="si">}{</span><span class="n">rows</span><span class="si">}{</span><span class="n">size</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1472"><a href="#Generator-1472"><span class="linenos">1472</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">TABLESAMPLE_REQUIRES_PARENS</span><span class="p">:</span> -</span><span id="Generator-1473"><a href="#Generator-1473"><span class="linenos">1473</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">expr</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="Generator-1474"><a href="#Generator-1474"><span class="linenos">1474</span></a> -</span><span id="Generator-1475"><a href="#Generator-1475"><span class="linenos">1475</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="s2"> </span><span class="si">{</span><span class="n">method</span><span class="si">}{</span><span class="n">expr</span><span class="si">}{</span><span class="n">seed</span><span class="si">}{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1476"><a href="#Generator-1476"><span class="linenos">1476</span></a> -</span><span id="Generator-1477"><a href="#Generator-1477"><span class="linenos">1477</span></a> <span class="k">def</span> <span class="nf">pivot_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Pivot</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1478"><a href="#Generator-1478"><span class="linenos">1478</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-1327"><a href="#Generator-1327"><span class="linenos">1327</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"INSERT</span><span class="si">{</span><span class="n">alternative</span><span class="si">}{</span><span class="n">ignore</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="n">by_name</span><span class="si">}{</span><span class="n">exists</span><span class="si">}{</span><span class="n">partition_sql</span><span class="si">}{</span><span class="n">where</span><span class="si">}{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1328"><a href="#Generator-1328"><span class="linenos">1328</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-1329"><a href="#Generator-1329"><span class="linenos">1329</span></a> +</span><span id="Generator-1330"><a href="#Generator-1330"><span class="linenos">1330</span></a> <span class="k">def</span> <span class="nf">intersect_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Intersect</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1331"><a href="#Generator-1331"><span class="linenos">1331</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><span id="Generator-1332"><a href="#Generator-1332"><span class="linenos">1332</span></a> <span class="n">expression</span><span class="p">,</span> +</span><span id="Generator-1333"><a href="#Generator-1333"><span class="linenos">1333</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">set_operation</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">intersect_op</span><span class="p">(</span><span class="n">expression</span><span class="p">)),</span> +</span><span id="Generator-1334"><a href="#Generator-1334"><span class="linenos">1334</span></a> <span class="p">)</span> +</span><span id="Generator-1335"><a href="#Generator-1335"><span class="linenos">1335</span></a> +</span><span id="Generator-1336"><a href="#Generator-1336"><span class="linenos">1336</span></a> <span class="k">def</span> <span class="nf">intersect_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Intersect</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1337"><a href="#Generator-1337"><span class="linenos">1337</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"INTERSECT</span><span class="si">{</span><span class="s1">''</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">'distinct'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">' ALL'</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1338"><a href="#Generator-1338"><span class="linenos">1338</span></a> +</span><span id="Generator-1339"><a href="#Generator-1339"><span class="linenos">1339</span></a> <span class="k">def</span> <span class="nf">introducer_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Introducer</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1340"><a href="#Generator-1340"><span class="linenos">1340</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-1341"><a href="#Generator-1341"><span class="linenos">1341</span></a> +</span><span id="Generator-1342"><a href="#Generator-1342"><span class="linenos">1342</span></a> <span class="k">def</span> <span class="nf">kill_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Kill</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1343"><a href="#Generator-1343"><span class="linenos">1343</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-1344"><a href="#Generator-1344"><span class="linenos">1344</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-1345"><a href="#Generator-1345"><span class="linenos">1345</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-1346"><a href="#Generator-1346"><span class="linenos">1346</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-1347"><a href="#Generator-1347"><span class="linenos">1347</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"KILL</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-1348"><a href="#Generator-1348"><span class="linenos">1348</span></a> +</span><span id="Generator-1349"><a href="#Generator-1349"><span class="linenos">1349</span></a> <span class="k">def</span> <span class="nf">pseudotype_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">PseudoType</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1350"><a href="#Generator-1350"><span class="linenos">1350</span></a> <span class="k">return</span> <span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> +</span><span id="Generator-1351"><a href="#Generator-1351"><span class="linenos">1351</span></a> +</span><span id="Generator-1352"><a href="#Generator-1352"><span class="linenos">1352</span></a> <span class="k">def</span> <span class="nf">objectidentifier_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ObjectIdentifier</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1353"><a href="#Generator-1353"><span class="linenos">1353</span></a> <span class="k">return</span> <span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> +</span><span id="Generator-1354"><a href="#Generator-1354"><span class="linenos">1354</span></a> +</span><span id="Generator-1355"><a href="#Generator-1355"><span class="linenos">1355</span></a> <span class="k">def</span> <span class="nf">onconflict_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">OnConflict</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1356"><a href="#Generator-1356"><span class="linenos">1356</span></a> <span class="n">conflict</span> <span class="o">=</span> <span class="s2">"ON DUPLICATE KEY"</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">"duplicate"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">"ON CONFLICT"</span> +</span><span id="Generator-1357"><a href="#Generator-1357"><span class="linenos">1357</span></a> <span class="n">constraint</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"constraint"</span><span class="p">)</span> +</span><span id="Generator-1358"><a href="#Generator-1358"><span class="linenos">1358</span></a> <span class="k">if</span> <span class="n">constraint</span><span class="p">:</span> +</span><span id="Generator-1359"><a href="#Generator-1359"><span class="linenos">1359</span></a> <span class="n">constraint</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"ON CONSTRAINT </span><span class="si">{</span><span class="n">constraint</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1360"><a href="#Generator-1360"><span class="linenos">1360</span></a> <span class="n">key</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">"key"</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-1361"><a href="#Generator-1361"><span class="linenos">1361</span></a> <span class="n">do</span> <span class="o">=</span> <span class="s2">""</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">"duplicate"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">" DO "</span> +</span><span id="Generator-1362"><a href="#Generator-1362"><span class="linenos">1362</span></a> <span class="n">nothing</span> <span class="o">=</span> <span class="s2">"NOTHING"</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">"nothing"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1363"><a href="#Generator-1363"><span class="linenos">1363</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-1364"><a href="#Generator-1364"><span class="linenos">1364</span></a> <span class="n">set_keyword</span> <span class="o">=</span> <span class="s2">"SET "</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">DUPLICATE_KEY_UPDATE_WITH_SET</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1365"><a href="#Generator-1365"><span class="linenos">1365</span></a> <span class="k">if</span> <span class="n">expressions</span><span class="p">:</span> +</span><span id="Generator-1366"><a href="#Generator-1366"><span class="linenos">1366</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"UPDATE </span><span class="si">{</span><span class="n">set_keyword</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1367"><a href="#Generator-1367"><span class="linenos">1367</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">conflict</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">constraint</span><span class="si">}{</span><span class="n">key</span><span class="si">}{</span><span class="n">do</span><span class="si">}{</span><span class="n">nothing</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1368"><a href="#Generator-1368"><span class="linenos">1368</span></a> +</span><span id="Generator-1369"><a href="#Generator-1369"><span class="linenos">1369</span></a> <span class="k">def</span> <span class="nf">returning_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Returning</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1370"><a href="#Generator-1370"><span class="linenos">1370</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="s1">'RETURNING'</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">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-1371"><a href="#Generator-1371"><span class="linenos">1371</span></a> +</span><span id="Generator-1372"><a href="#Generator-1372"><span class="linenos">1372</span></a> <span class="k">def</span> <span class="nf">rowformatdelimitedproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RowFormatDelimitedProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1373"><a href="#Generator-1373"><span class="linenos">1373</span></a> <span class="n">fields</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">"fields"</span><span class="p">)</span> +</span><span id="Generator-1374"><a href="#Generator-1374"><span class="linenos">1374</span></a> <span class="n">fields</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" FIELDS TERMINATED BY </span><span class="si">{</span><span class="n">fields</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">fields</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1375"><a href="#Generator-1375"><span class="linenos">1375</span></a> <span class="n">escaped</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">"escaped"</span><span class="p">)</span> +</span><span id="Generator-1376"><a href="#Generator-1376"><span class="linenos">1376</span></a> <span class="n">escaped</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" ESCAPED BY </span><span class="si">{</span><span class="n">escaped</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">escaped</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1377"><a href="#Generator-1377"><span class="linenos">1377</span></a> <span class="n">items</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">"collection_items"</span><span class="p">)</span> +</span><span id="Generator-1378"><a href="#Generator-1378"><span class="linenos">1378</span></a> <span class="n">items</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" COLLECTION ITEMS TERMINATED BY </span><span class="si">{</span><span class="n">items</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">items</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1379"><a href="#Generator-1379"><span class="linenos">1379</span></a> <span class="n">keys</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">"map_keys"</span><span class="p">)</span> +</span><span id="Generator-1380"><a href="#Generator-1380"><span class="linenos">1380</span></a> <span class="n">keys</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" MAP KEYS TERMINATED BY </span><span class="si">{</span><span class="n">keys</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">keys</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1381"><a href="#Generator-1381"><span class="linenos">1381</span></a> <span class="n">lines</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">"lines"</span><span class="p">)</span> +</span><span id="Generator-1382"><a href="#Generator-1382"><span class="linenos">1382</span></a> <span class="n">lines</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" LINES TERMINATED BY </span><span class="si">{</span><span class="n">lines</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">lines</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1383"><a href="#Generator-1383"><span class="linenos">1383</span></a> <span class="n">null</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">"null"</span><span class="p">)</span> +</span><span id="Generator-1384"><a href="#Generator-1384"><span class="linenos">1384</span></a> <span class="n">null</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" NULL DEFINED AS </span><span class="si">{</span><span class="n">null</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">null</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1385"><a href="#Generator-1385"><span class="linenos">1385</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ROW FORMAT DELIMITED</span><span class="si">{</span><span class="n">fields</span><span class="si">}{</span><span class="n">escaped</span><span class="si">}{</span><span class="n">items</span><span class="si">}{</span><span class="n">keys</span><span class="si">}{</span><span class="n">lines</span><span class="si">}{</span><span class="n">null</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1386"><a href="#Generator-1386"><span class="linenos">1386</span></a> +</span><span id="Generator-1387"><a href="#Generator-1387"><span class="linenos">1387</span></a> <span class="k">def</span> <span class="nf">withtablehint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">WithTableHint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1388"><a href="#Generator-1388"><span class="linenos">1388</span></a> <span class="k">return</span> <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">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-1389"><a href="#Generator-1389"><span class="linenos">1389</span></a> +</span><span id="Generator-1390"><a href="#Generator-1390"><span class="linenos">1390</span></a> <span class="k">def</span> <span class="nf">indextablehint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">IndexTableHint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1391"><a href="#Generator-1391"><span class="linenos">1391</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="bp">self</span><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"> INDEX"</span> +</span><span id="Generator-1392"><a href="#Generator-1392"><span class="linenos">1392</span></a> <span class="n">target</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"target"</span><span class="p">)</span> +</span><span id="Generator-1393"><a href="#Generator-1393"><span class="linenos">1393</span></a> <span class="n">target</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" FOR </span><span class="si">{</span><span class="n">target</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">target</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1394"><a href="#Generator-1394"><span class="linenos">1394</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">target</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">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-1395"><a href="#Generator-1395"><span class="linenos">1395</span></a> +</span><span id="Generator-1396"><a href="#Generator-1396"><span class="linenos">1396</span></a> <span class="k">def</span> <span class="nf">historicaldata_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">HistoricalData</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1397"><a href="#Generator-1397"><span class="linenos">1397</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-1398"><a href="#Generator-1398"><span class="linenos">1398</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-1399"><a href="#Generator-1399"><span class="linenos">1399</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-1400"><a href="#Generator-1400"><span class="linenos">1400</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="s2"> => </span><span class="si">{</span><span class="n">expr</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Generator-1401"><a href="#Generator-1401"><span class="linenos">1401</span></a> +</span><span id="Generator-1402"><a href="#Generator-1402"><span class="linenos">1402</span></a> <span class="k">def</span> <span class="nf">table_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</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">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">" AS "</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1403"><a href="#Generator-1403"><span class="linenos">1403</span></a> <span class="n">table</span> <span class="o">=</span> <span class="s2">"."</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> +</span><span id="Generator-1404"><a href="#Generator-1404"><span class="linenos">1404</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">part</span><span class="p">)</span> +</span><span id="Generator-1405"><a href="#Generator-1405"><span class="linenos">1405</span></a> <span class="k">for</span> <span class="n">part</span> <span class="ow">in</span> <span class="p">(</span> +</span><span id="Generator-1406"><a href="#Generator-1406"><span class="linenos">1406</span></a> <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">"catalog"</span><span class="p">),</span> +</span><span id="Generator-1407"><a href="#Generator-1407"><span class="linenos">1407</span></a> <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">"db"</span><span class="p">),</span> +</span><span id="Generator-1408"><a href="#Generator-1408"><span class="linenos">1408</span></a> <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">"this"</span><span class="p">),</span> +</span><span id="Generator-1409"><a href="#Generator-1409"><span class="linenos">1409</span></a> <span class="p">)</span> +</span><span id="Generator-1410"><a href="#Generator-1410"><span class="linenos">1410</span></a> <span class="k">if</span> <span class="n">part</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> +</span><span id="Generator-1411"><a href="#Generator-1411"><span class="linenos">1411</span></a> <span class="p">)</span> +</span><span id="Generator-1412"><a href="#Generator-1412"><span class="linenos">1412</span></a> +</span><span id="Generator-1413"><a href="#Generator-1413"><span class="linenos">1413</span></a> <span class="n">version</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"version"</span><span class="p">)</span> +</span><span id="Generator-1414"><a href="#Generator-1414"><span class="linenos">1414</span></a> <span class="n">version</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">version</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">version</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1415"><a href="#Generator-1415"><span class="linenos">1415</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-1416"><a href="#Generator-1416"><span class="linenos">1416</span></a> <span class="n">alias</span> <span class="o">=</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">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-1417"><a href="#Generator-1417"><span class="linenos">1417</span></a> <span class="n">hints</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">"hints"</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-1418"><a href="#Generator-1418"><span class="linenos">1418</span></a> <span class="n">hints</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">hints</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">hints</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">TABLE_HINTS</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1419"><a href="#Generator-1419"><span class="linenos">1419</span></a> <span class="n">pivots</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">"pivots"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</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-1420"><a href="#Generator-1420"><span class="linenos">1420</span></a> <span class="n">pivots</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">pivots</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">pivots</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1421"><a href="#Generator-1421"><span class="linenos">1421</span></a> <span class="n">joins</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">"joins"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</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><span id="Generator-1422"><a href="#Generator-1422"><span class="linenos">1422</span></a> <span class="n">laterals</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">"laterals"</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-1423"><a href="#Generator-1423"><span class="linenos">1423</span></a> +</span><span id="Generator-1424"><a href="#Generator-1424"><span class="linenos">1424</span></a> <span class="n">file_format</span> <span class="o">=</span> <span class="bp">self</span><span 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-1425"><a href="#Generator-1425"><span class="linenos">1425</span></a> <span class="k">if</span> <span class="n">file_format</span><span class="p">:</span> +</span><span id="Generator-1426"><a href="#Generator-1426"><span class="linenos">1426</span></a> <span class="n">pattern</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"pattern"</span><span class="p">)</span> +</span><span id="Generator-1427"><a href="#Generator-1427"><span class="linenos">1427</span></a> <span class="n">pattern</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">", PATTERN => </span><span class="si">{</span><span class="n">pattern</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">pattern</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1428"><a href="#Generator-1428"><span class="linenos">1428</span></a> <span class="n">file_format</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" (FILE_FORMAT => </span><span class="si">{</span><span class="n">file_format</span><span class="si">}{</span><span class="n">pattern</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Generator-1429"><a href="#Generator-1429"><span class="linenos">1429</span></a> +</span><span id="Generator-1430"><a href="#Generator-1430"><span class="linenos">1430</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span 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"</span><span class="p">)</span> +</span><span id="Generator-1431"><a href="#Generator-1431"><span class="linenos">1431</span></a> <span class="n">index</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AT </span><span class="si">{</span><span class="n">index</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">index</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1432"><a href="#Generator-1432"><span class="linenos">1432</span></a> +</span><span id="Generator-1433"><a href="#Generator-1433"><span class="linenos">1433</span></a> <span class="n">ordinality</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">"ordinality"</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">""</span> +</span><span id="Generator-1434"><a href="#Generator-1434"><span class="linenos">1434</span></a> <span class="k">if</span> <span class="n">ordinality</span><span class="p">:</span> +</span><span id="Generator-1435"><a href="#Generator-1435"><span class="linenos">1435</span></a> <span class="n">ordinality</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" WITH ORDINALITY</span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1436"><a href="#Generator-1436"><span class="linenos">1436</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator-1437"><a href="#Generator-1437"><span class="linenos">1437</span></a> +</span><span id="Generator-1438"><a href="#Generator-1438"><span class="linenos">1438</span></a> <span class="n">when</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"when"</span><span class="p">)</span> +</span><span id="Generator-1439"><a href="#Generator-1439"><span class="linenos">1439</span></a> <span class="k">if</span> <span class="n">when</span><span class="p">:</span> +</span><span id="Generator-1440"><a href="#Generator-1440"><span class="linenos">1440</span></a> <span class="n">table</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">table</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">when</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1441"><a href="#Generator-1441"><span class="linenos">1441</span></a> +</span><span id="Generator-1442"><a href="#Generator-1442"><span class="linenos">1442</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">table</span><span class="si">}{</span><span class="n">version</span><span class="si">}{</span><span class="n">file_format</span><span class="si">}{</span><span class="n">alias</span><span class="si">}{</span><span class="n">index</span><span class="si">}{</span><span class="n">hints</span><span class="si">}{</span><span class="n">pivots</span><span class="si">}{</span><span class="n">joins</span><span class="si">}{</span><span class="n">laterals</span><span class="si">}{</span><span class="n">ordinality</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1443"><a href="#Generator-1443"><span class="linenos">1443</span></a> +</span><span id="Generator-1444"><a href="#Generator-1444"><span class="linenos">1444</span></a> <span class="k">def</span> <span class="nf">tablesample_sql</span><span class="p">(</span> +</span><span id="Generator-1445"><a href="#Generator-1445"><span class="linenos">1445</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TableSample</span><span class="p">,</span> <span class="n">seed_prefix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"SEED"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" AS "</span> +</span><span id="Generator-1446"><a href="#Generator-1446"><span class="linenos">1446</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1447"><a href="#Generator-1447"><span class="linenos">1447</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">ALIAS_POST_TABLESAMPLE</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">alias</span><span class="p">:</span> +</span><span id="Generator-1448"><a href="#Generator-1448"><span class="linenos">1448</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 class="o">.</span><span class="n">copy</span><span class="p">()</span> +</span><span id="Generator-1449"><a href="#Generator-1449"><span class="linenos">1449</span></a> <span class="n">table</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"alias"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> +</span><span id="Generator-1450"><a href="#Generator-1450"><span class="linenos">1450</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-1451"><a href="#Generator-1451"><span class="linenos">1451</span></a> <span class="n">alias</span> <span class="o">=</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="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="w"> </span><span class="s1">'alias'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1452"><a href="#Generator-1452"><span class="linenos">1452</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator-1453"><a href="#Generator-1453"><span class="linenos">1453</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-1454"><a href="#Generator-1454"><span class="linenos">1454</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator-1455"><a href="#Generator-1455"><span class="linenos">1455</span></a> +</span><span id="Generator-1456"><a href="#Generator-1456"><span class="linenos">1456</span></a> <span class="n">method</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"method"</span><span class="p">)</span> +</span><span id="Generator-1457"><a href="#Generator-1457"><span class="linenos">1457</span></a> <span class="n">method</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">method</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">method</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">TABLESAMPLE_WITH_METHOD</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1458"><a href="#Generator-1458"><span class="linenos">1458</span></a> <span class="n">numerator</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"bucket_numerator"</span><span class="p">)</span> +</span><span id="Generator-1459"><a href="#Generator-1459"><span class="linenos">1459</span></a> <span class="n">denominator</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"bucket_denominator"</span><span class="p">)</span> +</span><span id="Generator-1460"><a href="#Generator-1460"><span class="linenos">1460</span></a> <span class="n">field</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"bucket_field"</span><span class="p">)</span> +</span><span id="Generator-1461"><a href="#Generator-1461"><span class="linenos">1461</span></a> <span class="n">field</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" ON </span><span class="si">{</span><span class="n">field</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">field</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1462"><a href="#Generator-1462"><span class="linenos">1462</span></a> <span class="n">bucket</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"BUCKET </span><span class="si">{</span><span class="n">numerator</span><span class="si">}</span><span class="s2"> OUT OF </span><span class="si">{</span><span class="n">denominator</span><span class="si">}{</span><span class="n">field</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">numerator</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1463"><a href="#Generator-1463"><span class="linenos">1463</span></a> <span class="n">percent</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"percent"</span><span class="p">)</span> +</span><span id="Generator-1464"><a href="#Generator-1464"><span class="linenos">1464</span></a> <span class="n">percent</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">percent</span><span class="si">}</span><span class="s2"> PERCENT"</span> <span class="k">if</span> <span class="n">percent</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1465"><a href="#Generator-1465"><span class="linenos">1465</span></a> <span class="n">rows</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"rows"</span><span class="p">)</span> +</span><span id="Generator-1466"><a href="#Generator-1466"><span class="linenos">1466</span></a> <span class="n">rows</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">rows</span><span class="si">}</span><span class="s2"> ROWS"</span> <span class="k">if</span> <span class="n">rows</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1467"><a href="#Generator-1467"><span class="linenos">1467</span></a> +</span><span id="Generator-1468"><a href="#Generator-1468"><span class="linenos">1468</span></a> <span class="n">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">"size"</span><span class="p">)</span> +</span><span id="Generator-1469"><a href="#Generator-1469"><span class="linenos">1469</span></a> <span class="k">if</span> <span class="n">size</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">TABLESAMPLE_SIZE_IS_PERCENT</span><span class="p">:</span> +</span><span id="Generator-1470"><a href="#Generator-1470"><span class="linenos">1470</span></a> <span class="n">size</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">size</span><span class="si">}</span><span class="s2"> PERCENT"</span> +</span><span id="Generator-1471"><a href="#Generator-1471"><span class="linenos">1471</span></a> +</span><span id="Generator-1472"><a href="#Generator-1472"><span class="linenos">1472</span></a> <span class="n">seed</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"seed"</span><span class="p">)</span> +</span><span id="Generator-1473"><a href="#Generator-1473"><span class="linenos">1473</span></a> <span class="n">seed</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">seed_prefix</span><span class="si">}</span><span class="s2"> (</span><span class="si">{</span><span class="n">seed</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">seed</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1474"><a href="#Generator-1474"><span class="linenos">1474</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="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">,</span> <span class="s2">"TABLESAMPLE"</span><span class="p">)</span> +</span><span id="Generator-1475"><a href="#Generator-1475"><span class="linenos">1475</span></a> +</span><span id="Generator-1476"><a href="#Generator-1476"><span class="linenos">1476</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">bucket</span><span class="si">}{</span><span class="n">percent</span><span class="si">}{</span><span class="n">rows</span><span class="si">}{</span><span class="n">size</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1477"><a href="#Generator-1477"><span class="linenos">1477</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">TABLESAMPLE_REQUIRES_PARENS</span><span class="p">:</span> +</span><span id="Generator-1478"><a href="#Generator-1478"><span class="linenos">1478</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">expr</span><span class="si">}</span><span class="s2">)"</span> </span><span id="Generator-1479"><a href="#Generator-1479"><span class="linenos">1479</span></a> -</span><span id="Generator-1480"><a href="#Generator-1480"><span class="linenos">1480</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">:</span> -</span><span id="Generator-1481"><a href="#Generator-1481"><span class="linenos">1481</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-1482"><a href="#Generator-1482"><span class="linenos">1482</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-1483"><a href="#Generator-1483"><span class="linenos">1483</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"UNPIVOT </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1480"><a href="#Generator-1480"><span class="linenos">1480</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="s2"> </span><span class="si">{</span><span class="n">method</span><span class="si">}{</span><span class="n">expr</span><span class="si">}{</span><span class="n">seed</span><span class="si">}{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1481"><a href="#Generator-1481"><span class="linenos">1481</span></a> +</span><span id="Generator-1482"><a href="#Generator-1482"><span class="linenos">1482</span></a> <span class="k">def</span> <span class="nf">pivot_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Pivot</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1483"><a href="#Generator-1483"><span class="linenos">1483</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-1484"><a href="#Generator-1484"><span class="linenos">1484</span></a> -</span><span id="Generator-1485"><a href="#Generator-1485"><span class="linenos">1485</span></a> <span class="n">on</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">seg</span><span class="p">(</span><span class="s1">'ON'</span><span class="p">)</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-1486"><a href="#Generator-1486"><span class="linenos">1486</span></a> <span class="n">using</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">"using"</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-1487"><a href="#Generator-1487"><span class="linenos">1487</span></a> <span class="n">using</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">seg</span><span class="p">(</span><span class="s1">'USING'</span><span class="p">)</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="k">if</span> <span class="n">using</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1488"><a href="#Generator-1488"><span class="linenos">1488</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-1489"><a href="#Generator-1489"><span class="linenos">1489</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PIVOT </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="n">using</span><span class="si">}{</span><span class="n">group</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1490"><a href="#Generator-1490"><span class="linenos">1490</span></a> -</span><span id="Generator-1491"><a href="#Generator-1491"><span class="linenos">1491</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-1492"><a href="#Generator-1492"><span class="linenos">1492</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-1493"><a href="#Generator-1493"><span class="linenos">1493</span></a> <span class="n">unpivot</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">"unpivot"</span><span class="p">)</span> -</span><span id="Generator-1494"><a href="#Generator-1494"><span class="linenos">1494</span></a> <span class="n">direction</span> <span class="o">=</span> <span class="s2">"UNPIVOT"</span> <span class="k">if</span> <span class="n">unpivot</span> <span class="k">else</span> <span class="s2">"PIVOT"</span> -</span><span id="Generator-1495"><a href="#Generator-1495"><span class="linenos">1495</span></a> <span class="n">field</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"field"</span><span class="p">)</span> -</span><span id="Generator-1496"><a href="#Generator-1496"><span class="linenos">1496</span></a> <span class="n">include_nulls</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">"include_nulls"</span><span class="p">)</span> -</span><span id="Generator-1497"><a href="#Generator-1497"><span class="linenos">1497</span></a> <span class="k">if</span> <span class="n">include_nulls</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Generator-1498"><a href="#Generator-1498"><span class="linenos">1498</span></a> <span class="n">nulls</span> <span class="o">=</span> <span class="s2">" INCLUDE NULLS "</span> <span class="k">if</span> <span class="n">include_nulls</span> <span class="k">else</span> <span class="s2">" EXCLUDE NULLS "</span> -</span><span id="Generator-1499"><a href="#Generator-1499"><span class="linenos">1499</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator-1500"><a href="#Generator-1500"><span class="linenos">1500</span></a> <span class="n">nulls</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator-1501"><a href="#Generator-1501"><span class="linenos">1501</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">direction</span><span class="si">}{</span><span class="n">nulls</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"> FOR </span><span class="si">{</span><span class="n">field</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1502"><a href="#Generator-1502"><span class="linenos">1502</span></a> -</span><span id="Generator-1503"><a href="#Generator-1503"><span class="linenos">1503</span></a> <span class="k">def</span> <span class="nf">version_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Version</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1504"><a href="#Generator-1504"><span class="linenos">1504</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"FOR </span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1505"><a href="#Generator-1505"><span class="linenos">1505</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">)</span> -</span><span id="Generator-1506"><a href="#Generator-1506"><span class="linenos">1506</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-1507"><a href="#Generator-1507"><span class="linenos">1507</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="s2"> </span><span class="si">{</span><span class="n">expr</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1508"><a href="#Generator-1508"><span class="linenos">1508</span></a> -</span><span id="Generator-1509"><a href="#Generator-1509"><span class="linenos">1509</span></a> <span class="k">def</span> <span class="nf">tuple_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Tuple</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1510"><a href="#Generator-1510"><span class="linenos">1510</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">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-1511"><a href="#Generator-1511"><span class="linenos">1511</span></a> -</span><span id="Generator-1512"><a href="#Generator-1512"><span class="linenos">1512</span></a> <span class="k">def</span> <span class="nf">update_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">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 class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1513"><a href="#Generator-1513"><span class="linenos">1513</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-1514"><a href="#Generator-1514"><span class="linenos">1514</span></a> <span class="n">set_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="kc">True</span><span class="p">)</span> -</span><span id="Generator-1515"><a href="#Generator-1515"><span class="linenos">1515</span></a> <span class="n">from_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">"from"</span><span class="p">)</span> -</span><span id="Generator-1516"><a href="#Generator-1516"><span class="linenos">1516</span></a> <span class="n">where_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">"where"</span><span class="p">)</span> -</span><span id="Generator-1517"><a href="#Generator-1517"><span class="linenos">1517</span></a> <span class="n">returning</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"returning"</span><span class="p">)</span> -</span><span id="Generator-1518"><a href="#Generator-1518"><span class="linenos">1518</span></a> <span class="n">order</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"order"</span><span class="p">)</span> -</span><span id="Generator-1519"><a href="#Generator-1519"><span class="linenos">1519</span></a> <span class="n">limit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"limit"</span><span class="p">)</span> -</span><span id="Generator-1520"><a href="#Generator-1520"><span class="linenos">1520</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">RETURNING_END</span><span class="p">:</span> -</span><span id="Generator-1521"><a href="#Generator-1521"><span class="linenos">1521</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">from_sql</span><span class="si">}{</span><span class="n">where_sql</span><span class="si">}{</span><span class="n">returning</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1522"><a href="#Generator-1522"><span class="linenos">1522</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator-1523"><a href="#Generator-1523"><span class="linenos">1523</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">returning</span><span class="si">}{</span><span class="n">from_sql</span><span class="si">}{</span><span class="n">where_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1524"><a href="#Generator-1524"><span class="linenos">1524</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"UPDATE </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> SET </span><span class="si">{</span><span class="n">set_sql</span><span class="si">}{</span><span class="n">expression_sql</span><span class="si">}{</span><span class="n">order</span><span class="si">}{</span><span class="n">limit</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1525"><a href="#Generator-1525"><span class="linenos">1525</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-1526"><a href="#Generator-1526"><span class="linenos">1526</span></a> -</span><span id="Generator-1527"><a href="#Generator-1527"><span class="linenos">1527</span></a> <span class="k">def</span> <span class="nf">values_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Values</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1528"><a href="#Generator-1528"><span class="linenos">1528</span></a> <span class="c1"># The VALUES clause is still valid in an `INSERT INTO ..` statement, for example</span> -</span><span id="Generator-1529"><a href="#Generator-1529"><span class="linenos">1529</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">VALUES_AS_TABLE</span> <span class="ow">or</span> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">find_ancestor</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">From</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Join</span><span class="p">):</span> -</span><span id="Generator-1530"><a href="#Generator-1530"><span class="linenos">1530</span></a> <span class="n">args</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-1531"><a href="#Generator-1531"><span class="linenos">1531</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-1532"><a href="#Generator-1532"><span class="linenos">1532</span></a> <span class="n">values</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">seg</span><span class="p">(</span><span class="s1">''</span><span class="p">)</span><span class="si">}{</span><span class="n">args</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1533"><a href="#Generator-1533"><span class="linenos">1533</span></a> <span class="n">values</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Generator-1534"><a href="#Generator-1534"><span class="linenos">1534</span></a> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">values</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="Generator-1535"><a href="#Generator-1535"><span class="linenos">1535</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">WRAP_DERIVED_VALUES</span> <span class="ow">and</span> <span class="p">(</span><span class="n">alias</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">From</span><span class="p">))</span> -</span><span id="Generator-1536"><a href="#Generator-1536"><span class="linenos">1536</span></a> <span class="k">else</span> <span class="n">values</span> -</span><span id="Generator-1537"><a href="#Generator-1537"><span class="linenos">1537</span></a> <span class="p">)</span> -</span><span id="Generator-1538"><a href="#Generator-1538"><span class="linenos">1538</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">values</span><span class="si">}</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="n">values</span> -</span><span id="Generator-1539"><a href="#Generator-1539"><span class="linenos">1539</span></a> -</span><span id="Generator-1540"><a href="#Generator-1540"><span class="linenos">1540</span></a> <span class="c1"># Converts `VALUES...` expression into a series of select unions.</span> -</span><span id="Generator-1541"><a href="#Generator-1541"><span class="linenos">1541</span></a> <span class="n">alias_node</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">"alias"</span><span class="p">)</span> -</span><span id="Generator-1542"><a href="#Generator-1542"><span class="linenos">1542</span></a> <span class="n">column_names</span> <span class="o">=</span> <span class="n">alias_node</span> <span class="ow">and</span> <span class="n">alias_node</span><span class="o">.</span><span class="n">columns</span> -</span><span id="Generator-1543"><a href="#Generator-1543"><span class="linenos">1543</span></a> -</span><span id="Generator-1544"><a href="#Generator-1544"><span class="linenos">1544</span></a> <span class="n">selects</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Subqueryable</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="Generator-1545"><a href="#Generator-1545"><span class="linenos">1545</span></a> -</span><span id="Generator-1546"><a href="#Generator-1546"><span class="linenos">1546</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">tup</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">expressions</span><span class="p">):</span> -</span><span id="Generator-1547"><a href="#Generator-1547"><span class="linenos">1547</span></a> <span class="n">row</span> <span class="o">=</span> <span class="n">tup</span><span class="o">.</span><span class="n">expressions</span> +</span><span id="Generator-1485"><a href="#Generator-1485"><span class="linenos">1485</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">:</span> +</span><span id="Generator-1486"><a href="#Generator-1486"><span class="linenos">1486</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-1487"><a href="#Generator-1487"><span class="linenos">1487</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-1488"><a href="#Generator-1488"><span class="linenos">1488</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"UNPIVOT </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1489"><a href="#Generator-1489"><span class="linenos">1489</span></a> +</span><span id="Generator-1490"><a href="#Generator-1490"><span class="linenos">1490</span></a> <span class="n">on</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">seg</span><span class="p">(</span><span class="s1">'ON'</span><span class="p">)</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-1491"><a href="#Generator-1491"><span class="linenos">1491</span></a> <span class="n">using</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">"using"</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-1492"><a href="#Generator-1492"><span class="linenos">1492</span></a> <span class="n">using</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">seg</span><span class="p">(</span><span class="s1">'USING'</span><span class="p">)</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="k">if</span> <span class="n">using</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1493"><a href="#Generator-1493"><span class="linenos">1493</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-1494"><a href="#Generator-1494"><span class="linenos">1494</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PIVOT </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="n">using</span><span class="si">}{</span><span class="n">group</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1495"><a href="#Generator-1495"><span class="linenos">1495</span></a> +</span><span id="Generator-1496"><a href="#Generator-1496"><span class="linenos">1496</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-1497"><a href="#Generator-1497"><span class="linenos">1497</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-1498"><a href="#Generator-1498"><span class="linenos">1498</span></a> <span class="n">unpivot</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">"unpivot"</span><span class="p">)</span> +</span><span id="Generator-1499"><a href="#Generator-1499"><span class="linenos">1499</span></a> <span class="n">direction</span> <span class="o">=</span> <span class="s2">"UNPIVOT"</span> <span class="k">if</span> <span class="n">unpivot</span> <span class="k">else</span> <span class="s2">"PIVOT"</span> +</span><span id="Generator-1500"><a href="#Generator-1500"><span class="linenos">1500</span></a> <span class="n">field</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"field"</span><span class="p">)</span> +</span><span id="Generator-1501"><a href="#Generator-1501"><span class="linenos">1501</span></a> <span class="n">include_nulls</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">"include_nulls"</span><span class="p">)</span> +</span><span id="Generator-1502"><a href="#Generator-1502"><span class="linenos">1502</span></a> <span class="k">if</span> <span class="n">include_nulls</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Generator-1503"><a href="#Generator-1503"><span class="linenos">1503</span></a> <span class="n">nulls</span> <span class="o">=</span> <span class="s2">" INCLUDE NULLS "</span> <span class="k">if</span> <span class="n">include_nulls</span> <span class="k">else</span> <span class="s2">" EXCLUDE NULLS "</span> +</span><span id="Generator-1504"><a href="#Generator-1504"><span class="linenos">1504</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator-1505"><a href="#Generator-1505"><span class="linenos">1505</span></a> <span class="n">nulls</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator-1506"><a href="#Generator-1506"><span class="linenos">1506</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">direction</span><span class="si">}{</span><span class="n">nulls</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"> FOR </span><span class="si">{</span><span class="n">field</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1507"><a href="#Generator-1507"><span class="linenos">1507</span></a> +</span><span id="Generator-1508"><a href="#Generator-1508"><span class="linenos">1508</span></a> <span class="k">def</span> <span class="nf">version_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Version</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1509"><a href="#Generator-1509"><span class="linenos">1509</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"FOR </span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1510"><a href="#Generator-1510"><span class="linenos">1510</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">)</span> +</span><span id="Generator-1511"><a href="#Generator-1511"><span class="linenos">1511</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-1512"><a href="#Generator-1512"><span class="linenos">1512</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="s2"> </span><span class="si">{</span><span class="n">expr</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1513"><a href="#Generator-1513"><span class="linenos">1513</span></a> +</span><span id="Generator-1514"><a href="#Generator-1514"><span class="linenos">1514</span></a> <span class="k">def</span> <span class="nf">tuple_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Tuple</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1515"><a href="#Generator-1515"><span class="linenos">1515</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">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-1516"><a href="#Generator-1516"><span class="linenos">1516</span></a> +</span><span id="Generator-1517"><a href="#Generator-1517"><span class="linenos">1517</span></a> <span class="k">def</span> <span class="nf">update_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">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 class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1518"><a href="#Generator-1518"><span class="linenos">1518</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-1519"><a href="#Generator-1519"><span class="linenos">1519</span></a> <span class="n">set_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="kc">True</span><span class="p">)</span> +</span><span id="Generator-1520"><a href="#Generator-1520"><span class="linenos">1520</span></a> <span class="n">from_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">"from"</span><span class="p">)</span> +</span><span id="Generator-1521"><a href="#Generator-1521"><span class="linenos">1521</span></a> <span class="n">where_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">"where"</span><span class="p">)</span> +</span><span id="Generator-1522"><a href="#Generator-1522"><span class="linenos">1522</span></a> <span class="n">returning</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"returning"</span><span class="p">)</span> +</span><span id="Generator-1523"><a href="#Generator-1523"><span class="linenos">1523</span></a> <span class="n">order</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"order"</span><span class="p">)</span> +</span><span id="Generator-1524"><a href="#Generator-1524"><span class="linenos">1524</span></a> <span class="n">limit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"limit"</span><span class="p">)</span> +</span><span id="Generator-1525"><a href="#Generator-1525"><span class="linenos">1525</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">RETURNING_END</span><span class="p">:</span> +</span><span id="Generator-1526"><a href="#Generator-1526"><span class="linenos">1526</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">from_sql</span><span class="si">}{</span><span class="n">where_sql</span><span class="si">}{</span><span class="n">returning</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1527"><a href="#Generator-1527"><span class="linenos">1527</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator-1528"><a href="#Generator-1528"><span class="linenos">1528</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">returning</span><span class="si">}{</span><span class="n">from_sql</span><span class="si">}{</span><span class="n">where_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1529"><a href="#Generator-1529"><span class="linenos">1529</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"UPDATE </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> SET </span><span class="si">{</span><span class="n">set_sql</span><span class="si">}{</span><span class="n">expression_sql</span><span class="si">}{</span><span class="n">order</span><span class="si">}{</span><span class="n">limit</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1530"><a href="#Generator-1530"><span class="linenos">1530</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-1531"><a href="#Generator-1531"><span class="linenos">1531</span></a> +</span><span id="Generator-1532"><a href="#Generator-1532"><span class="linenos">1532</span></a> <span class="k">def</span> <span class="nf">values_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Values</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1533"><a href="#Generator-1533"><span class="linenos">1533</span></a> <span class="c1"># The VALUES clause is still valid in an `INSERT INTO ..` statement, for example</span> +</span><span id="Generator-1534"><a href="#Generator-1534"><span class="linenos">1534</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">VALUES_AS_TABLE</span> <span class="ow">or</span> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">find_ancestor</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">From</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Join</span><span class="p">):</span> +</span><span id="Generator-1535"><a href="#Generator-1535"><span class="linenos">1535</span></a> <span class="n">args</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-1536"><a href="#Generator-1536"><span class="linenos">1536</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-1537"><a href="#Generator-1537"><span class="linenos">1537</span></a> <span class="n">values</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">seg</span><span class="p">(</span><span class="s1">''</span><span class="p">)</span><span class="si">}{</span><span class="n">args</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1538"><a href="#Generator-1538"><span class="linenos">1538</span></a> <span class="n">values</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Generator-1539"><a href="#Generator-1539"><span class="linenos">1539</span></a> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">values</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Generator-1540"><a href="#Generator-1540"><span class="linenos">1540</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">WRAP_DERIVED_VALUES</span> <span class="ow">and</span> <span class="p">(</span><span class="n">alias</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">From</span><span class="p">))</span> +</span><span id="Generator-1541"><a href="#Generator-1541"><span class="linenos">1541</span></a> <span class="k">else</span> <span class="n">values</span> +</span><span id="Generator-1542"><a href="#Generator-1542"><span class="linenos">1542</span></a> <span class="p">)</span> +</span><span id="Generator-1543"><a href="#Generator-1543"><span class="linenos">1543</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">values</span><span class="si">}</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="n">values</span> +</span><span id="Generator-1544"><a href="#Generator-1544"><span class="linenos">1544</span></a> +</span><span id="Generator-1545"><a href="#Generator-1545"><span class="linenos">1545</span></a> <span class="c1"># Converts `VALUES...` expression into a series of select unions.</span> +</span><span id="Generator-1546"><a href="#Generator-1546"><span class="linenos">1546</span></a> <span class="n">alias_node</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">"alias"</span><span class="p">)</span> +</span><span id="Generator-1547"><a href="#Generator-1547"><span class="linenos">1547</span></a> <span class="n">column_names</span> <span class="o">=</span> <span class="n">alias_node</span> <span class="ow">and</span> <span class="n">alias_node</span><span class="o">.</span><span class="n">columns</span> </span><span id="Generator-1548"><a href="#Generator-1548"><span class="linenos">1548</span></a> -</span><span id="Generator-1549"><a href="#Generator-1549"><span class="linenos">1549</span></a> <span class="k">if</span> <span class="n">i</span> <span class="o">==</span> <span class="mi">0</span> <span class="ow">and</span> <span class="n">column_names</span><span class="p">:</span> -</span><span id="Generator-1550"><a href="#Generator-1550"><span class="linenos">1550</span></a> <span class="n">row</span> <span class="o">=</span> <span class="p">[</span> -</span><span id="Generator-1551"><a href="#Generator-1551"><span class="linenos">1551</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">alias_</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">column_name</span><span class="p">)</span> <span class="k">for</span> <span class="n">value</span><span class="p">,</span> <span class="n">column_name</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">row</span><span class="p">,</span> <span class="n">column_names</span><span class="p">)</span> -</span><span id="Generator-1552"><a href="#Generator-1552"><span class="linenos">1552</span></a> <span class="p">]</span> +</span><span id="Generator-1549"><a href="#Generator-1549"><span class="linenos">1549</span></a> <span class="n">selects</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Subqueryable</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="Generator-1550"><a href="#Generator-1550"><span class="linenos">1550</span></a> +</span><span id="Generator-1551"><a href="#Generator-1551"><span class="linenos">1551</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">tup</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">expressions</span><span class="p">):</span> +</span><span id="Generator-1552"><a href="#Generator-1552"><span class="linenos">1552</span></a> <span class="n">row</span> <span class="o">=</span> <span class="n">tup</span><span class="o">.</span><span class="n">expressions</span> </span><span id="Generator-1553"><a href="#Generator-1553"><span class="linenos">1553</span></a> -</span><span id="Generator-1554"><a href="#Generator-1554"><span class="linenos">1554</span></a> <span class="n">selects</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">row</span><span class="p">))</span> -</span><span id="Generator-1555"><a href="#Generator-1555"><span class="linenos">1555</span></a> -</span><span id="Generator-1556"><a href="#Generator-1556"><span class="linenos">1556</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-1557"><a href="#Generator-1557"><span class="linenos">1557</span></a> <span class="c1"># This may result in poor performance for large-cardinality `VALUES` tables, due to</span> -</span><span id="Generator-1558"><a href="#Generator-1558"><span class="linenos">1558</span></a> <span class="c1"># the deep nesting of the resulting exp.Unions. If this is a problem, either increase</span> -</span><span id="Generator-1559"><a href="#Generator-1559"><span class="linenos">1559</span></a> <span class="c1"># `sys.setrecursionlimit` to avoid RecursionErrors, or don't set `pretty`.</span> -</span><span id="Generator-1560"><a href="#Generator-1560"><span class="linenos">1560</span></a> <span class="n">subqueryable</span> <span class="o">=</span> <span class="n">reduce</span><span class="p">(</span><span class="k">lambda</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">union</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">distinct</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">),</span> <span class="n">selects</span><span class="p">)</span> -</span><span id="Generator-1561"><a href="#Generator-1561"><span class="linenos">1561</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">subquery_sql</span><span class="p">(</span> -</span><span id="Generator-1562"><a href="#Generator-1562"><span class="linenos">1562</span></a> <span class="n">subqueryable</span><span class="o">.</span><span class="n">subquery</span><span class="p">(</span><span class="n">alias_node</span> <span class="ow">and</span> <span class="n">alias_node</span><span class="o">.</span><span class="n">this</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-1563"><a href="#Generator-1563"><span class="linenos">1563</span></a> <span class="p">)</span> -</span><span id="Generator-1564"><a href="#Generator-1564"><span class="linenos">1564</span></a> -</span><span id="Generator-1565"><a href="#Generator-1565"><span class="linenos">1565</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="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">alias_node</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="k">if</span> <span class="n">alias_node</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1566"><a href="#Generator-1566"><span class="linenos">1566</span></a> <span class="n">unions</span> <span class="o">=</span> <span class="s2">" UNION ALL "</span><span class="o">.</span><span class="n">join</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">select</span><span class="p">)</span> <span class="k">for</span> <span class="n">select</span> <span class="ow">in</span> <span class="n">selects</span><span class="p">)</span> -</span><span id="Generator-1567"><a href="#Generator-1567"><span class="linenos">1567</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">unions</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1568"><a href="#Generator-1568"><span class="linenos">1568</span></a> -</span><span id="Generator-1569"><a href="#Generator-1569"><span class="linenos">1569</span></a> <span class="k">def</span> <span class="nf">var_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Var</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1570"><a href="#Generator-1570"><span class="linenos">1570</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">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-1571"><a href="#Generator-1571"><span class="linenos">1571</span></a> -</span><span id="Generator-1572"><a href="#Generator-1572"><span class="linenos">1572</span></a> <span class="k">def</span> <span class="nf">into_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Into</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1573"><a href="#Generator-1573"><span class="linenos">1573</span></a> <span class="n">temporary</span> <span class="o">=</span> <span class="s2">" TEMPORARY"</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">"temporary"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1574"><a href="#Generator-1574"><span class="linenos">1574</span></a> <span class="n">unlogged</span> <span class="o">=</span> <span class="s2">" UNLOGGED"</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">"unlogged"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1575"><a href="#Generator-1575"><span class="linenos">1575</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="s1">'INTO'</span><span class="p">)</span><span class="si">}{</span><span class="n">temporary</span><span class="w"> </span><span class="ow">or</span><span class="w"> </span><span class="n">unlogged</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-1554"><a href="#Generator-1554"><span class="linenos">1554</span></a> <span class="k">if</span> <span class="n">i</span> <span class="o">==</span> <span class="mi">0</span> <span class="ow">and</span> <span class="n">column_names</span><span class="p">:</span> +</span><span id="Generator-1555"><a href="#Generator-1555"><span class="linenos">1555</span></a> <span class="n">row</span> <span class="o">=</span> <span class="p">[</span> +</span><span id="Generator-1556"><a href="#Generator-1556"><span class="linenos">1556</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">alias_</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">column_name</span><span class="p">)</span> <span class="k">for</span> <span class="n">value</span><span class="p">,</span> <span class="n">column_name</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">row</span><span class="p">,</span> <span class="n">column_names</span><span class="p">)</span> +</span><span id="Generator-1557"><a href="#Generator-1557"><span class="linenos">1557</span></a> <span class="p">]</span> +</span><span id="Generator-1558"><a href="#Generator-1558"><span class="linenos">1558</span></a> +</span><span id="Generator-1559"><a href="#Generator-1559"><span class="linenos">1559</span></a> <span class="n">selects</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">row</span><span class="p">))</span> +</span><span id="Generator-1560"><a href="#Generator-1560"><span class="linenos">1560</span></a> +</span><span id="Generator-1561"><a href="#Generator-1561"><span class="linenos">1561</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-1562"><a href="#Generator-1562"><span class="linenos">1562</span></a> <span class="c1"># This may result in poor performance for large-cardinality `VALUES` tables, due to</span> +</span><span id="Generator-1563"><a href="#Generator-1563"><span class="linenos">1563</span></a> <span class="c1"># the deep nesting of the resulting exp.Unions. If this is a problem, either increase</span> +</span><span id="Generator-1564"><a href="#Generator-1564"><span class="linenos">1564</span></a> <span class="c1"># `sys.setrecursionlimit` to avoid RecursionErrors, or don't set `pretty`.</span> +</span><span id="Generator-1565"><a href="#Generator-1565"><span class="linenos">1565</span></a> <span class="n">subqueryable</span> <span class="o">=</span> <span class="n">reduce</span><span class="p">(</span><span class="k">lambda</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">union</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">distinct</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">),</span> <span class="n">selects</span><span class="p">)</span> +</span><span id="Generator-1566"><a href="#Generator-1566"><span class="linenos">1566</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">subquery_sql</span><span class="p">(</span> +</span><span id="Generator-1567"><a href="#Generator-1567"><span class="linenos">1567</span></a> <span class="n">subqueryable</span><span class="o">.</span><span class="n">subquery</span><span class="p">(</span><span class="n">alias_node</span> <span class="ow">and</span> <span class="n">alias_node</span><span class="o">.</span><span class="n">this</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-1568"><a href="#Generator-1568"><span class="linenos">1568</span></a> <span class="p">)</span> +</span><span id="Generator-1569"><a href="#Generator-1569"><span class="linenos">1569</span></a> +</span><span id="Generator-1570"><a href="#Generator-1570"><span class="linenos">1570</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="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">alias_node</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="k">if</span> <span class="n">alias_node</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1571"><a href="#Generator-1571"><span class="linenos">1571</span></a> <span class="n">unions</span> <span class="o">=</span> <span class="s2">" UNION ALL "</span><span class="o">.</span><span class="n">join</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">select</span><span class="p">)</span> <span class="k">for</span> <span class="n">select</span> <span class="ow">in</span> <span class="n">selects</span><span class="p">)</span> +</span><span id="Generator-1572"><a href="#Generator-1572"><span class="linenos">1572</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">unions</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1573"><a href="#Generator-1573"><span class="linenos">1573</span></a> +</span><span id="Generator-1574"><a href="#Generator-1574"><span class="linenos">1574</span></a> <span class="k">def</span> <span class="nf">var_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Var</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1575"><a href="#Generator-1575"><span class="linenos">1575</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">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> </span><span id="Generator-1576"><a href="#Generator-1576"><span class="linenos">1576</span></a> -</span><span id="Generator-1577"><a href="#Generator-1577"><span class="linenos">1577</span></a> <span class="k">def</span> <span class="nf">from_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">From</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1578"><a href="#Generator-1578"><span class="linenos">1578</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="s1">'FROM'</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">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1579"><a href="#Generator-1579"><span class="linenos">1579</span></a> -</span><span id="Generator-1580"><a href="#Generator-1580"><span class="linenos">1580</span></a> <span class="k">def</span> <span class="nf">group_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Group</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1581"><a href="#Generator-1581"><span class="linenos">1581</span></a> <span class="n">group_by</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">op_expressions</span><span class="p">(</span><span class="s2">"GROUP BY"</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> -</span><span id="Generator-1582"><a href="#Generator-1582"><span class="linenos">1582</span></a> -</span><span id="Generator-1583"><a href="#Generator-1583"><span class="linenos">1583</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">"all"</span><span class="p">):</span> -</span><span id="Generator-1584"><a href="#Generator-1584"><span class="linenos">1584</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">group_by</span><span class="si">}</span><span class="s2"> ALL"</span> -</span><span id="Generator-1585"><a href="#Generator-1585"><span class="linenos">1585</span></a> -</span><span id="Generator-1586"><a href="#Generator-1586"><span class="linenos">1586</span></a> <span class="n">grouping_sets</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">"grouping_sets"</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> -</span><span id="Generator-1587"><a href="#Generator-1587"><span class="linenos">1587</span></a> <span class="n">grouping_sets</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Generator-1588"><a href="#Generator-1588"><span class="linenos">1588</span></a> <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="s1">'GROUPING SETS'</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">wrap</span><span class="p">(</span><span class="n">grouping_sets</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">grouping_sets</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1589"><a href="#Generator-1589"><span class="linenos">1589</span></a> <span class="p">)</span> +</span><span id="Generator-1577"><a href="#Generator-1577"><span class="linenos">1577</span></a> <span class="k">def</span> <span class="nf">into_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Into</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1578"><a href="#Generator-1578"><span class="linenos">1578</span></a> <span class="n">temporary</span> <span class="o">=</span> <span class="s2">" TEMPORARY"</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">"temporary"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1579"><a href="#Generator-1579"><span class="linenos">1579</span></a> <span class="n">unlogged</span> <span class="o">=</span> <span class="s2">" UNLOGGED"</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">"unlogged"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1580"><a href="#Generator-1580"><span class="linenos">1580</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="s1">'INTO'</span><span class="p">)</span><span class="si">}{</span><span class="n">temporary</span><span class="w"> </span><span class="ow">or</span><span class="w"> </span><span class="n">unlogged</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-1581"><a href="#Generator-1581"><span class="linenos">1581</span></a> +</span><span id="Generator-1582"><a href="#Generator-1582"><span class="linenos">1582</span></a> <span class="k">def</span> <span class="nf">from_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">From</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1583"><a href="#Generator-1583"><span class="linenos">1583</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="s1">'FROM'</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">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1584"><a href="#Generator-1584"><span class="linenos">1584</span></a> +</span><span id="Generator-1585"><a href="#Generator-1585"><span class="linenos">1585</span></a> <span class="k">def</span> <span class="nf">group_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Group</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1586"><a href="#Generator-1586"><span class="linenos">1586</span></a> <span class="n">group_by</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">op_expressions</span><span class="p">(</span><span class="s2">"GROUP BY"</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> +</span><span id="Generator-1587"><a href="#Generator-1587"><span class="linenos">1587</span></a> +</span><span id="Generator-1588"><a href="#Generator-1588"><span class="linenos">1588</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">"all"</span><span class="p">):</span> +</span><span id="Generator-1589"><a href="#Generator-1589"><span class="linenos">1589</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">group_by</span><span class="si">}</span><span class="s2"> ALL"</span> </span><span id="Generator-1590"><a href="#Generator-1590"><span class="linenos">1590</span></a> -</span><span id="Generator-1591"><a href="#Generator-1591"><span class="linenos">1591</span></a> <span class="n">cube</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">"cube"</span><span class="p">,</span> <span class="p">[])</span> -</span><span id="Generator-1592"><a href="#Generator-1592"><span class="linenos">1592</span></a> <span class="k">if</span> <span class="n">seq_get</span><span class="p">(</span><span class="n">cube</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> <span class="ow">is</span> <span class="kc">True</span><span class="p">:</span> -</span><span id="Generator-1593"><a href="#Generator-1593"><span class="linenos">1593</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">group_by</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">'WITH CUBE'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1594"><a href="#Generator-1594"><span class="linenos">1594</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator-1595"><a href="#Generator-1595"><span class="linenos">1595</span></a> <span class="n">cube_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">"cube"</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> -</span><span id="Generator-1596"><a href="#Generator-1596"><span class="linenos">1596</span></a> <span class="n">cube_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">seg</span><span class="p">(</span><span class="s1">'CUBE'</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">wrap</span><span class="p">(</span><span class="n">cube_sql</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">cube_sql</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1597"><a href="#Generator-1597"><span class="linenos">1597</span></a> -</span><span id="Generator-1598"><a href="#Generator-1598"><span class="linenos">1598</span></a> <span class="n">rollup</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">"rollup"</span><span class="p">,</span> <span class="p">[])</span> -</span><span id="Generator-1599"><a href="#Generator-1599"><span class="linenos">1599</span></a> <span class="k">if</span> <span class="n">seq_get</span><span class="p">(</span><span class="n">rollup</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> <span class="ow">is</span> <span class="kc">True</span><span class="p">:</span> -</span><span id="Generator-1600"><a href="#Generator-1600"><span class="linenos">1600</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">group_by</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">'WITH ROLLUP'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1601"><a href="#Generator-1601"><span class="linenos">1601</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator-1602"><a href="#Generator-1602"><span class="linenos">1602</span></a> <span class="n">rollup_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">"rollup"</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> -</span><span id="Generator-1603"><a href="#Generator-1603"><span class="linenos">1603</span></a> <span class="n">rollup_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">seg</span><span class="p">(</span><span class="s1">'ROLLUP'</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">wrap</span><span class="p">(</span><span class="n">rollup_sql</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">rollup_sql</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1604"><a href="#Generator-1604"><span class="linenos">1604</span></a> -</span><span id="Generator-1605"><a href="#Generator-1605"><span class="linenos">1605</span></a> <span class="n">groupings</span> <span class="o">=</span> <span class="n">csv</span><span class="p">(</span> -</span><span id="Generator-1606"><a href="#Generator-1606"><span class="linenos">1606</span></a> <span class="n">grouping_sets</span><span class="p">,</span> -</span><span id="Generator-1607"><a href="#Generator-1607"><span class="linenos">1607</span></a> <span class="n">cube_sql</span><span class="p">,</span> -</span><span id="Generator-1608"><a href="#Generator-1608"><span class="linenos">1608</span></a> <span class="n">rollup_sql</span><span class="p">,</span> -</span><span id="Generator-1609"><a href="#Generator-1609"><span class="linenos">1609</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s2">"WITH TOTALS"</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">"totals"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span><span class="p">,</span> -</span><span id="Generator-1610"><a href="#Generator-1610"><span class="linenos">1610</span></a> <span class="n">sep</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">GROUPINGS_SEP</span><span class="p">,</span> -</span><span id="Generator-1611"><a href="#Generator-1611"><span class="linenos">1611</span></a> <span class="p">)</span> -</span><span id="Generator-1612"><a href="#Generator-1612"><span class="linenos">1612</span></a> -</span><span id="Generator-1613"><a href="#Generator-1613"><span class="linenos">1613</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">"expressions"</span><span class="p">)</span> <span class="ow">and</span> <span class="n">groupings</span><span class="p">:</span> -</span><span id="Generator-1614"><a href="#Generator-1614"><span class="linenos">1614</span></a> <span class="n">group_by</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">group_by</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">GROUPINGS_SEP</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1615"><a href="#Generator-1615"><span class="linenos">1615</span></a> -</span><span id="Generator-1616"><a href="#Generator-1616"><span class="linenos">1616</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">group_by</span><span class="si">}{</span><span class="n">groupings</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1591"><a href="#Generator-1591"><span class="linenos">1591</span></a> <span class="n">grouping_sets</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">"grouping_sets"</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</span><span id="Generator-1592"><a href="#Generator-1592"><span class="linenos">1592</span></a> <span class="n">grouping_sets</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Generator-1593"><a href="#Generator-1593"><span class="linenos">1593</span></a> <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="s1">'GROUPING SETS'</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">wrap</span><span class="p">(</span><span class="n">grouping_sets</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">grouping_sets</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1594"><a href="#Generator-1594"><span class="linenos">1594</span></a> <span class="p">)</span> +</span><span id="Generator-1595"><a href="#Generator-1595"><span class="linenos">1595</span></a> +</span><span id="Generator-1596"><a href="#Generator-1596"><span class="linenos">1596</span></a> <span class="n">cube</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">"cube"</span><span class="p">,</span> <span class="p">[])</span> +</span><span id="Generator-1597"><a href="#Generator-1597"><span class="linenos">1597</span></a> <span class="k">if</span> <span class="n">seq_get</span><span class="p">(</span><span class="n">cube</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> <span class="ow">is</span> <span class="kc">True</span><span class="p">:</span> +</span><span id="Generator-1598"><a href="#Generator-1598"><span class="linenos">1598</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">group_by</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">'WITH CUBE'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1599"><a href="#Generator-1599"><span class="linenos">1599</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator-1600"><a href="#Generator-1600"><span class="linenos">1600</span></a> <span class="n">cube_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">"cube"</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</span><span id="Generator-1601"><a href="#Generator-1601"><span class="linenos">1601</span></a> <span class="n">cube_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">seg</span><span class="p">(</span><span class="s1">'CUBE'</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">wrap</span><span class="p">(</span><span class="n">cube_sql</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">cube_sql</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1602"><a href="#Generator-1602"><span class="linenos">1602</span></a> +</span><span id="Generator-1603"><a href="#Generator-1603"><span class="linenos">1603</span></a> <span class="n">rollup</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">"rollup"</span><span class="p">,</span> <span class="p">[])</span> +</span><span id="Generator-1604"><a href="#Generator-1604"><span class="linenos">1604</span></a> <span class="k">if</span> <span class="n">seq_get</span><span class="p">(</span><span class="n">rollup</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> <span class="ow">is</span> <span class="kc">True</span><span class="p">:</span> +</span><span id="Generator-1605"><a href="#Generator-1605"><span class="linenos">1605</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">group_by</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">'WITH ROLLUP'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1606"><a href="#Generator-1606"><span class="linenos">1606</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator-1607"><a href="#Generator-1607"><span class="linenos">1607</span></a> <span class="n">rollup_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">"rollup"</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</span><span id="Generator-1608"><a href="#Generator-1608"><span class="linenos">1608</span></a> <span class="n">rollup_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">seg</span><span class="p">(</span><span class="s1">'ROLLUP'</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">wrap</span><span class="p">(</span><span class="n">rollup_sql</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">rollup_sql</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1609"><a href="#Generator-1609"><span class="linenos">1609</span></a> +</span><span id="Generator-1610"><a href="#Generator-1610"><span class="linenos">1610</span></a> <span class="n">groupings</span> <span class="o">=</span> <span class="n">csv</span><span class="p">(</span> +</span><span id="Generator-1611"><a href="#Generator-1611"><span class="linenos">1611</span></a> <span class="n">grouping_sets</span><span class="p">,</span> +</span><span id="Generator-1612"><a href="#Generator-1612"><span class="linenos">1612</span></a> <span class="n">cube_sql</span><span class="p">,</span> +</span><span id="Generator-1613"><a href="#Generator-1613"><span class="linenos">1613</span></a> <span class="n">rollup_sql</span><span class="p">,</span> +</span><span id="Generator-1614"><a href="#Generator-1614"><span class="linenos">1614</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s2">"WITH TOTALS"</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">"totals"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span><span class="p">,</span> +</span><span id="Generator-1615"><a href="#Generator-1615"><span class="linenos">1615</span></a> <span class="n">sep</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">GROUPINGS_SEP</span><span class="p">,</span> +</span><span id="Generator-1616"><a href="#Generator-1616"><span class="linenos">1616</span></a> <span class="p">)</span> </span><span id="Generator-1617"><a href="#Generator-1617"><span class="linenos">1617</span></a> -</span><span id="Generator-1618"><a href="#Generator-1618"><span class="linenos">1618</span></a> <span class="k">def</span> <span class="nf">having_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Having</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1619"><a href="#Generator-1619"><span class="linenos">1619</span></a> <span class="n">this</span> <span class="o">=</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><span id="Generator-1620"><a href="#Generator-1620"><span class="linenos">1620</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="s1">'HAVING'</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="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1621"><a href="#Generator-1621"><span class="linenos">1621</span></a> -</span><span id="Generator-1622"><a href="#Generator-1622"><span class="linenos">1622</span></a> <span class="k">def</span> <span class="nf">connect_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Connect</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1623"><a href="#Generator-1623"><span class="linenos">1623</span></a> <span class="n">start</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"start"</span><span class="p">)</span> -</span><span id="Generator-1624"><a href="#Generator-1624"><span class="linenos">1624</span></a> <span class="n">start</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="sa">f</span><span class="s2">"START WITH </span><span class="si">{</span><span class="n">start</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> <span class="k">if</span> <span class="n">start</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1625"><a href="#Generator-1625"><span class="linenos">1625</span></a> <span class="n">connect</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"connect"</span><span class="p">)</span> -</span><span id="Generator-1626"><a href="#Generator-1626"><span class="linenos">1626</span></a> <span class="n">connect</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="sa">f</span><span class="s2">"CONNECT BY </span><span class="si">{</span><span class="n">connect</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="Generator-1627"><a href="#Generator-1627"><span class="linenos">1627</span></a> <span class="k">return</span> <span class="n">start</span> <span class="o">+</span> <span class="n">connect</span> -</span><span id="Generator-1628"><a href="#Generator-1628"><span class="linenos">1628</span></a> -</span><span id="Generator-1629"><a href="#Generator-1629"><span class="linenos">1629</span></a> <span class="k">def</span> <span class="nf">prior_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Prior</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1630"><a href="#Generator-1630"><span class="linenos">1630</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PRIOR </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-1631"><a href="#Generator-1631"><span class="linenos">1631</span></a> -</span><span id="Generator-1632"><a href="#Generator-1632"><span class="linenos">1632</span></a> <span class="k">def</span> <span class="nf">join_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Join</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1633"><a href="#Generator-1633"><span class="linenos">1633</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">SEMI_ANTI_JOIN_WITH_SIDE</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">kind</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">"SEMI"</span><span class="p">,</span> <span class="s2">"ANTI"</span><span class="p">):</span> -</span><span id="Generator-1634"><a href="#Generator-1634"><span class="linenos">1634</span></a> <span class="n">side</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Generator-1635"><a href="#Generator-1635"><span class="linenos">1635</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator-1636"><a href="#Generator-1636"><span class="linenos">1636</span></a> <span class="n">side</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">side</span> -</span><span id="Generator-1637"><a href="#Generator-1637"><span class="linenos">1637</span></a> -</span><span id="Generator-1638"><a href="#Generator-1638"><span class="linenos">1638</span></a> <span class="n">op_sql</span> <span class="o">=</span> <span class="s2">" "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> -</span><span id="Generator-1639"><a href="#Generator-1639"><span class="linenos">1639</span></a> <span class="n">op</span> -</span><span id="Generator-1640"><a href="#Generator-1640"><span class="linenos">1640</span></a> <span class="k">for</span> <span class="n">op</span> <span class="ow">in</span> <span class="p">(</span> -</span><span id="Generator-1641"><a href="#Generator-1641"><span class="linenos">1641</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">method</span><span class="p">,</span> -</span><span id="Generator-1642"><a href="#Generator-1642"><span class="linenos">1642</span></a> <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">"global"</span><span class="p">)</span> <span class="k">else</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Generator-1643"><a href="#Generator-1643"><span class="linenos">1643</span></a> <span class="n">side</span><span class="p">,</span> -</span><span id="Generator-1644"><a href="#Generator-1644"><span class="linenos">1644</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">kind</span><span class="p">,</span> -</span><span id="Generator-1645"><a href="#Generator-1645"><span class="linenos">1645</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">hint</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">JOIN_HINTS</span> <span class="k">else</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Generator-1646"><a href="#Generator-1646"><span class="linenos">1646</span></a> <span class="p">)</span> -</span><span id="Generator-1647"><a href="#Generator-1647"><span class="linenos">1647</span></a> <span class="k">if</span> <span class="n">op</span> -</span><span id="Generator-1648"><a href="#Generator-1648"><span class="linenos">1648</span></a> <span class="p">)</span> -</span><span id="Generator-1649"><a href="#Generator-1649"><span class="linenos">1649</span></a> <span class="n">on_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">"on"</span><span class="p">)</span> -</span><span id="Generator-1650"><a href="#Generator-1650"><span class="linenos">1650</span></a> <span class="n">using</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">"using"</span><span class="p">)</span> -</span><span id="Generator-1651"><a href="#Generator-1651"><span class="linenos">1651</span></a> -</span><span id="Generator-1652"><a href="#Generator-1652"><span class="linenos">1652</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">on_sql</span> <span class="ow">and</span> <span class="n">using</span><span class="p">:</span> -</span><span id="Generator-1653"><a href="#Generator-1653"><span class="linenos">1653</span></a> <span class="n">on_sql</span> <span class="o">=</span> <span class="n">csv</span><span class="p">(</span><span class="o">*</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">column</span><span class="p">)</span> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">using</span><span class="p">))</span> -</span><span id="Generator-1654"><a href="#Generator-1654"><span class="linenos">1654</span></a> -</span><span id="Generator-1655"><a href="#Generator-1655"><span class="linenos">1655</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-1618"><a href="#Generator-1618"><span class="linenos">1618</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">"expressions"</span><span class="p">)</span> <span class="ow">and</span> <span class="n">groupings</span><span class="p">:</span> +</span><span id="Generator-1619"><a href="#Generator-1619"><span class="linenos">1619</span></a> <span class="n">group_by</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">group_by</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">GROUPINGS_SEP</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1620"><a href="#Generator-1620"><span class="linenos">1620</span></a> +</span><span id="Generator-1621"><a href="#Generator-1621"><span class="linenos">1621</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">group_by</span><span class="si">}{</span><span class="n">groupings</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1622"><a href="#Generator-1622"><span class="linenos">1622</span></a> +</span><span id="Generator-1623"><a href="#Generator-1623"><span class="linenos">1623</span></a> <span class="k">def</span> <span class="nf">having_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Having</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1624"><a href="#Generator-1624"><span class="linenos">1624</span></a> <span class="n">this</span> <span class="o">=</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><span id="Generator-1625"><a href="#Generator-1625"><span class="linenos">1625</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="s1">'HAVING'</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="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1626"><a href="#Generator-1626"><span class="linenos">1626</span></a> +</span><span id="Generator-1627"><a href="#Generator-1627"><span class="linenos">1627</span></a> <span class="k">def</span> <span class="nf">connect_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Connect</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1628"><a href="#Generator-1628"><span class="linenos">1628</span></a> <span class="n">start</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"start"</span><span class="p">)</span> +</span><span id="Generator-1629"><a href="#Generator-1629"><span class="linenos">1629</span></a> <span class="n">start</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="sa">f</span><span class="s2">"START WITH </span><span class="si">{</span><span class="n">start</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> <span class="k">if</span> <span class="n">start</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1630"><a href="#Generator-1630"><span class="linenos">1630</span></a> <span class="n">connect</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"connect"</span><span class="p">)</span> +</span><span id="Generator-1631"><a href="#Generator-1631"><span class="linenos">1631</span></a> <span class="n">connect</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="sa">f</span><span class="s2">"CONNECT BY </span><span class="si">{</span><span class="n">connect</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="Generator-1632"><a href="#Generator-1632"><span class="linenos">1632</span></a> <span class="k">return</span> <span class="n">start</span> <span class="o">+</span> <span class="n">connect</span> +</span><span id="Generator-1633"><a href="#Generator-1633"><span class="linenos">1633</span></a> +</span><span id="Generator-1634"><a href="#Generator-1634"><span class="linenos">1634</span></a> <span class="k">def</span> <span class="nf">prior_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Prior</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1635"><a href="#Generator-1635"><span class="linenos">1635</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PRIOR </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-1636"><a href="#Generator-1636"><span class="linenos">1636</span></a> +</span><span id="Generator-1637"><a href="#Generator-1637"><span class="linenos">1637</span></a> <span class="k">def</span> <span class="nf">join_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Join</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1638"><a href="#Generator-1638"><span class="linenos">1638</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">SEMI_ANTI_JOIN_WITH_SIDE</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">kind</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">"SEMI"</span><span class="p">,</span> <span class="s2">"ANTI"</span><span class="p">):</span> +</span><span id="Generator-1639"><a href="#Generator-1639"><span class="linenos">1639</span></a> <span class="n">side</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Generator-1640"><a href="#Generator-1640"><span class="linenos">1640</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator-1641"><a href="#Generator-1641"><span class="linenos">1641</span></a> <span class="n">side</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">side</span> +</span><span id="Generator-1642"><a href="#Generator-1642"><span class="linenos">1642</span></a> +</span><span id="Generator-1643"><a href="#Generator-1643"><span class="linenos">1643</span></a> <span class="n">op_sql</span> <span class="o">=</span> <span class="s2">" "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> +</span><span id="Generator-1644"><a href="#Generator-1644"><span class="linenos">1644</span></a> <span class="n">op</span> +</span><span id="Generator-1645"><a href="#Generator-1645"><span class="linenos">1645</span></a> <span class="k">for</span> <span class="n">op</span> <span class="ow">in</span> <span class="p">(</span> +</span><span id="Generator-1646"><a href="#Generator-1646"><span class="linenos">1646</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">method</span><span class="p">,</span> +</span><span id="Generator-1647"><a href="#Generator-1647"><span class="linenos">1647</span></a> <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">"global"</span><span class="p">)</span> <span class="k">else</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Generator-1648"><a href="#Generator-1648"><span class="linenos">1648</span></a> <span class="n">side</span><span class="p">,</span> +</span><span id="Generator-1649"><a href="#Generator-1649"><span class="linenos">1649</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">kind</span><span class="p">,</span> +</span><span id="Generator-1650"><a href="#Generator-1650"><span class="linenos">1650</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">hint</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">JOIN_HINTS</span> <span class="k">else</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Generator-1651"><a href="#Generator-1651"><span class="linenos">1651</span></a> <span class="p">)</span> +</span><span id="Generator-1652"><a href="#Generator-1652"><span class="linenos">1652</span></a> <span class="k">if</span> <span class="n">op</span> +</span><span id="Generator-1653"><a href="#Generator-1653"><span class="linenos">1653</span></a> <span class="p">)</span> +</span><span id="Generator-1654"><a href="#Generator-1654"><span class="linenos">1654</span></a> <span class="n">on_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">"on"</span><span class="p">)</span> +</span><span id="Generator-1655"><a href="#Generator-1655"><span class="linenos">1655</span></a> <span class="n">using</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">"using"</span><span class="p">)</span> </span><span id="Generator-1656"><a href="#Generator-1656"><span class="linenos">1656</span></a> -</span><span id="Generator-1657"><a href="#Generator-1657"><span class="linenos">1657</span></a> <span class="k">if</span> <span class="n">on_sql</span><span class="p">:</span> -</span><span id="Generator-1658"><a href="#Generator-1658"><span class="linenos">1658</span></a> <span class="n">on_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="n">on_sql</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><span id="Generator-1659"><a href="#Generator-1659"><span class="linenos">1659</span></a> <span class="n">space</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">" "</span> <span class="o">*</span> <span class="bp">self</span><span class="o">.</span><span class="n">pad</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><span id="Generator-1660"><a href="#Generator-1660"><span class="linenos">1660</span></a> <span class="k">if</span> <span class="n">using</span><span class="p">:</span> -</span><span id="Generator-1661"><a href="#Generator-1661"><span class="linenos">1661</span></a> <span class="n">on_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">space</span><span class="si">}</span><span class="s2">USING (</span><span class="si">{</span><span class="n">on_sql</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="Generator-1662"><a href="#Generator-1662"><span class="linenos">1662</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator-1663"><a href="#Generator-1663"><span class="linenos">1663</span></a> <span class="n">on_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">space</span><span class="si">}</span><span class="s2">ON </span><span class="si">{</span><span class="n">on_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1664"><a href="#Generator-1664"><span class="linenos">1664</span></a> <span class="k">elif</span> <span class="ow">not</span> <span class="n">op_sql</span><span class="p">:</span> -</span><span id="Generator-1665"><a href="#Generator-1665"><span class="linenos">1665</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">", </span><span class="si">{</span><span class="n">this_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1666"><a href="#Generator-1666"><span class="linenos">1666</span></a> -</span><span id="Generator-1667"><a href="#Generator-1667"><span class="linenos">1667</span></a> <span class="n">op_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">op_sql</span><span class="si">}</span><span class="s2"> JOIN"</span> <span class="k">if</span> <span class="n">op_sql</span> <span class="k">else</span> <span class="s2">"JOIN"</span> -</span><span id="Generator-1668"><a href="#Generator-1668"><span class="linenos">1668</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_sql</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">this_sql</span><span class="si">}{</span><span class="n">on_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1669"><a href="#Generator-1669"><span class="linenos">1669</span></a> -</span><span id="Generator-1670"><a href="#Generator-1670"><span class="linenos">1670</span></a> <span class="k">def</span> <span class="nf">lambda_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Lambda</span><span class="p">,</span> <span class="n">arrow_sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"->"</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1671"><a href="#Generator-1671"><span class="linenos">1671</span></a> <span class="n">args</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-1672"><a href="#Generator-1672"><span class="linenos">1672</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="n">args</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">args</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">","</span><span class="p">))</span> <span class="o">></span> <span class="mi">1</span> <span class="k">else</span> <span class="n">args</span> -</span><span id="Generator-1673"><a href="#Generator-1673"><span class="linenos">1673</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">args</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">arrow_sep</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-1657"><a href="#Generator-1657"><span class="linenos">1657</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">on_sql</span> <span class="ow">and</span> <span class="n">using</span><span class="p">:</span> +</span><span id="Generator-1658"><a href="#Generator-1658"><span class="linenos">1658</span></a> <span class="n">on_sql</span> <span class="o">=</span> <span class="n">csv</span><span class="p">(</span><span class="o">*</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">column</span><span class="p">)</span> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">using</span><span class="p">))</span> +</span><span id="Generator-1659"><a href="#Generator-1659"><span class="linenos">1659</span></a> +</span><span id="Generator-1660"><a href="#Generator-1660"><span class="linenos">1660</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-1661"><a href="#Generator-1661"><span class="linenos">1661</span></a> +</span><span id="Generator-1662"><a href="#Generator-1662"><span class="linenos">1662</span></a> <span class="k">if</span> <span class="n">on_sql</span><span class="p">:</span> +</span><span id="Generator-1663"><a href="#Generator-1663"><span class="linenos">1663</span></a> <span class="n">on_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="n">on_sql</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><span id="Generator-1664"><a href="#Generator-1664"><span class="linenos">1664</span></a> <span class="n">space</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">" "</span> <span class="o">*</span> <span class="bp">self</span><span class="o">.</span><span class="n">pad</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><span id="Generator-1665"><a href="#Generator-1665"><span class="linenos">1665</span></a> <span class="k">if</span> <span class="n">using</span><span class="p">:</span> +</span><span id="Generator-1666"><a href="#Generator-1666"><span class="linenos">1666</span></a> <span class="n">on_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">space</span><span class="si">}</span><span class="s2">USING (</span><span class="si">{</span><span class="n">on_sql</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Generator-1667"><a href="#Generator-1667"><span class="linenos">1667</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator-1668"><a href="#Generator-1668"><span class="linenos">1668</span></a> <span class="n">on_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">space</span><span class="si">}</span><span class="s2">ON </span><span class="si">{</span><span class="n">on_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1669"><a href="#Generator-1669"><span class="linenos">1669</span></a> <span class="k">elif</span> <span class="ow">not</span> <span class="n">op_sql</span><span class="p">:</span> +</span><span id="Generator-1670"><a href="#Generator-1670"><span class="linenos">1670</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">", </span><span class="si">{</span><span class="n">this_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1671"><a href="#Generator-1671"><span class="linenos">1671</span></a> +</span><span id="Generator-1672"><a href="#Generator-1672"><span class="linenos">1672</span></a> <span class="n">op_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">op_sql</span><span class="si">}</span><span class="s2"> JOIN"</span> <span class="k">if</span> <span class="n">op_sql</span> <span class="k">else</span> <span class="s2">"JOIN"</span> +</span><span id="Generator-1673"><a href="#Generator-1673"><span class="linenos">1673</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_sql</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">this_sql</span><span class="si">}{</span><span class="n">on_sql</span><span class="si">}</span><span class="s2">"</span> </span><span id="Generator-1674"><a href="#Generator-1674"><span class="linenos">1674</span></a> -</span><span id="Generator-1675"><a href="#Generator-1675"><span class="linenos">1675</span></a> <span class="k">def</span> <span class="nf">lateral_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Lateral</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1676"><a href="#Generator-1676"><span class="linenos">1676</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-1677"><a href="#Generator-1677"><span class="linenos">1677</span></a> -</span><span id="Generator-1678"><a href="#Generator-1678"><span class="linenos">1678</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">"view"</span><span class="p">):</span> -</span><span id="Generator-1679"><a href="#Generator-1679"><span class="linenos">1679</span></a> <span class="n">alias</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">"alias"</span><span class="p">]</span> -</span><span id="Generator-1680"><a href="#Generator-1680"><span class="linenos">1680</span></a> <span class="n">columns</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">alias</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"columns"</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-1681"><a href="#Generator-1681"><span class="linenos">1681</span></a> <span class="n">table</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">alias</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alias</span><span class="o">.</span><span class="n">name</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1682"><a href="#Generator-1682"><span class="linenos">1682</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="n">columns</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">columns</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1683"><a href="#Generator-1683"><span class="linenos">1683</span></a> <span class="n">op_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="sa">f</span><span class="s2">"LATERAL VIEW</span><span class="si">{</span><span class="s1">' OUTER'</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">'outer'</span><span class="p">)</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-1684"><a href="#Generator-1684"><span class="linenos">1684</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">op_sql</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="n">this</span><span class="si">}{</span><span class="n">table</span><span class="si">}{</span><span class="n">columns</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1685"><a href="#Generator-1685"><span class="linenos">1685</span></a> -</span><span id="Generator-1686"><a href="#Generator-1686"><span class="linenos">1686</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-1687"><a href="#Generator-1687"><span class="linenos">1687</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-1688"><a href="#Generator-1688"><span class="linenos">1688</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"LATERAL </span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1689"><a href="#Generator-1689"><span class="linenos">1689</span></a> -</span><span id="Generator-1690"><a href="#Generator-1690"><span class="linenos">1690</span></a> <span class="k">def</span> <span class="nf">limit_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">,</span> <span class="n">top</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-1691"><a href="#Generator-1691"><span class="linenos">1691</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-1692"><a href="#Generator-1692"><span class="linenos">1692</span></a> -</span><span id="Generator-1693"><a href="#Generator-1693"><span class="linenos">1693</span></a> <span class="n">args</span> <span class="o">=</span> <span class="p">[</span> -</span><span id="Generator-1694"><a href="#Generator-1694"><span class="linenos">1694</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_simplify_unless_literal</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">LIMIT_ONLY_LITERALS</span> <span class="k">else</span> <span class="n">e</span> -</span><span id="Generator-1695"><a href="#Generator-1695"><span class="linenos">1695</span></a> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</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">get</span><span class="p">(</span><span class="n">k</span><span class="p">)</span> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">"offset"</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">))</span> -</span><span id="Generator-1696"><a href="#Generator-1696"><span class="linenos">1696</span></a> <span class="k">if</span> <span class="n">e</span> -</span><span id="Generator-1697"><a href="#Generator-1697"><span class="linenos">1697</span></a> <span class="p">]</span> -</span><span id="Generator-1698"><a href="#Generator-1698"><span class="linenos">1698</span></a> -</span><span id="Generator-1699"><a href="#Generator-1699"><span class="linenos">1699</span></a> <span class="n">args_sql</span> <span class="o">=</span> <span class="s2">", "</span><span class="o">.</span><span class="n">join</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">args</span><span class="p">)</span> -</span><span id="Generator-1700"><a href="#Generator-1700"><span class="linenos">1700</span></a> <span class="n">args_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">args_sql</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="nb">any</span><span class="p">(</span><span class="n">top</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">e</span><span class="o">.</span><span class="n">is_number</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">args</span><span class="p">)</span> <span class="k">else</span> <span class="n">args_sql</span> -</span><span id="Generator-1701"><a href="#Generator-1701"><span class="linenos">1701</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="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'TOP'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">top</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">'LIMIT'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">args_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1702"><a href="#Generator-1702"><span class="linenos">1702</span></a> -</span><span id="Generator-1703"><a href="#Generator-1703"><span class="linenos">1703</span></a> <span class="k">def</span> <span class="nf">offset_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Offset</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1704"><a href="#Generator-1704"><span class="linenos">1704</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-1705"><a href="#Generator-1705"><span class="linenos">1705</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span> -</span><span id="Generator-1706"><a href="#Generator-1706"><span class="linenos">1706</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Generator-1707"><a href="#Generator-1707"><span class="linenos">1707</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_simplify_unless_literal</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">LIMIT_ONLY_LITERALS</span> <span class="k">else</span> <span class="n">expression</span> -</span><span id="Generator-1708"><a href="#Generator-1708"><span class="linenos">1708</span></a> <span class="p">)</span> -</span><span id="Generator-1709"><a href="#Generator-1709"><span class="linenos">1709</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="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'OFFSET'</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="si">}</span><span class="s2">"</span> -</span><span id="Generator-1710"><a href="#Generator-1710"><span class="linenos">1710</span></a> -</span><span id="Generator-1711"><a href="#Generator-1711"><span class="linenos">1711</span></a> <span class="k">def</span> <span class="nf">setitem_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SetItem</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1712"><a href="#Generator-1712"><span class="linenos">1712</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-1713"><a href="#Generator-1713"><span class="linenos">1713</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-1714"><a href="#Generator-1714"><span class="linenos">1714</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-1715"><a href="#Generator-1715"><span class="linenos">1715</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-1716"><a href="#Generator-1716"><span class="linenos">1716</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-1717"><a href="#Generator-1717"><span class="linenos">1717</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-1718"><a href="#Generator-1718"><span class="linenos">1718</span></a> <span class="n">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">"global"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1719"><a href="#Generator-1719"><span class="linenos">1719</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">global_</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">expressions</span><span class="si">}{</span><span class="n">collate</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1720"><a href="#Generator-1720"><span class="linenos">1720</span></a> -</span><span id="Generator-1721"><a href="#Generator-1721"><span class="linenos">1721</span></a> <span class="k">def</span> <span class="nf">set_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Set</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1722"><a href="#Generator-1722"><span class="linenos">1722</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Generator-1723"><a href="#Generator-1723"><span class="linenos">1723</span></a> <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 class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1724"><a href="#Generator-1724"><span class="linenos">1724</span></a> <span class="p">)</span> -</span><span id="Generator-1725"><a href="#Generator-1725"><span class="linenos">1725</span></a> <span class="n">tag</span> <span class="o">=</span> <span class="s2">" TAG"</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">"tag"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1726"><a href="#Generator-1726"><span class="linenos">1726</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="s1">'UNSET'</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">'unset'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">'SET'</span><span class="si">}{</span><span class="n">tag</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1727"><a href="#Generator-1727"><span class="linenos">1727</span></a> -</span><span id="Generator-1728"><a href="#Generator-1728"><span class="linenos">1728</span></a> <span class="k">def</span> <span class="nf">pragma_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Pragma</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1729"><a href="#Generator-1729"><span class="linenos">1729</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PRAGMA </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-1730"><a href="#Generator-1730"><span class="linenos">1730</span></a> -</span><span id="Generator-1731"><a href="#Generator-1731"><span class="linenos">1731</span></a> <span class="k">def</span> <span class="nf">lock_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Lock</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1732"><a href="#Generator-1732"><span class="linenos">1732</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">LOCKING_READS_SUPPORTED</span><span class="p">:</span> -</span><span id="Generator-1733"><a href="#Generator-1733"><span class="linenos">1733</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Locking reads using 'FOR UPDATE/SHARE' are not supported"</span><span class="p">)</span> -</span><span id="Generator-1734"><a href="#Generator-1734"><span class="linenos">1734</span></a> <span class="k">return</span> <span class="s2">""</span> +</span><span id="Generator-1675"><a href="#Generator-1675"><span class="linenos">1675</span></a> <span class="k">def</span> <span class="nf">lambda_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Lambda</span><span class="p">,</span> <span class="n">arrow_sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"->"</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1676"><a href="#Generator-1676"><span class="linenos">1676</span></a> <span class="n">args</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-1677"><a href="#Generator-1677"><span class="linenos">1677</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="n">args</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">args</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">","</span><span class="p">))</span> <span class="o">></span> <span class="mi">1</span> <span class="k">else</span> <span class="n">args</span> +</span><span id="Generator-1678"><a href="#Generator-1678"><span class="linenos">1678</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">args</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">arrow_sep</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-1679"><a href="#Generator-1679"><span class="linenos">1679</span></a> +</span><span id="Generator-1680"><a href="#Generator-1680"><span class="linenos">1680</span></a> <span class="k">def</span> <span class="nf">lateral_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Lateral</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1681"><a href="#Generator-1681"><span class="linenos">1681</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-1682"><a href="#Generator-1682"><span class="linenos">1682</span></a> +</span><span id="Generator-1683"><a href="#Generator-1683"><span class="linenos">1683</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">"view"</span><span class="p">):</span> +</span><span id="Generator-1684"><a href="#Generator-1684"><span class="linenos">1684</span></a> <span class="n">alias</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">"alias"</span><span class="p">]</span> +</span><span id="Generator-1685"><a href="#Generator-1685"><span class="linenos">1685</span></a> <span class="n">columns</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">alias</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"columns"</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-1686"><a href="#Generator-1686"><span class="linenos">1686</span></a> <span class="n">table</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">alias</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alias</span><span class="o">.</span><span class="n">name</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1687"><a href="#Generator-1687"><span class="linenos">1687</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="n">columns</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">columns</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1688"><a href="#Generator-1688"><span class="linenos">1688</span></a> <span class="n">op_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="sa">f</span><span class="s2">"LATERAL VIEW</span><span class="si">{</span><span class="s1">' OUTER'</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">'outer'</span><span class="p">)</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-1689"><a href="#Generator-1689"><span class="linenos">1689</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">op_sql</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="n">this</span><span class="si">}{</span><span class="n">table</span><span class="si">}{</span><span class="n">columns</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1690"><a href="#Generator-1690"><span class="linenos">1690</span></a> +</span><span id="Generator-1691"><a href="#Generator-1691"><span class="linenos">1691</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-1692"><a href="#Generator-1692"><span class="linenos">1692</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-1693"><a href="#Generator-1693"><span class="linenos">1693</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"LATERAL </span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1694"><a href="#Generator-1694"><span class="linenos">1694</span></a> +</span><span id="Generator-1695"><a href="#Generator-1695"><span class="linenos">1695</span></a> <span class="k">def</span> <span class="nf">limit_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">,</span> <span class="n">top</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-1696"><a href="#Generator-1696"><span class="linenos">1696</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-1697"><a href="#Generator-1697"><span class="linenos">1697</span></a> +</span><span id="Generator-1698"><a href="#Generator-1698"><span class="linenos">1698</span></a> <span class="n">args</span> <span class="o">=</span> <span class="p">[</span> +</span><span id="Generator-1699"><a href="#Generator-1699"><span class="linenos">1699</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_simplify_unless_literal</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">LIMIT_ONLY_LITERALS</span> <span class="k">else</span> <span class="n">e</span> +</span><span id="Generator-1700"><a href="#Generator-1700"><span class="linenos">1700</span></a> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</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">get</span><span class="p">(</span><span class="n">k</span><span class="p">)</span> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">"offset"</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">))</span> +</span><span id="Generator-1701"><a href="#Generator-1701"><span class="linenos">1701</span></a> <span class="k">if</span> <span class="n">e</span> +</span><span id="Generator-1702"><a href="#Generator-1702"><span class="linenos">1702</span></a> <span class="p">]</span> +</span><span id="Generator-1703"><a href="#Generator-1703"><span class="linenos">1703</span></a> +</span><span id="Generator-1704"><a href="#Generator-1704"><span class="linenos">1704</span></a> <span class="n">args_sql</span> <span class="o">=</span> <span class="s2">", "</span><span class="o">.</span><span class="n">join</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">args</span><span class="p">)</span> +</span><span id="Generator-1705"><a href="#Generator-1705"><span class="linenos">1705</span></a> <span class="n">args_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">args_sql</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="nb">any</span><span class="p">(</span><span class="n">top</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">e</span><span class="o">.</span><span class="n">is_number</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">args</span><span class="p">)</span> <span class="k">else</span> <span class="n">args_sql</span> +</span><span id="Generator-1706"><a href="#Generator-1706"><span class="linenos">1706</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="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'TOP'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">top</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">'LIMIT'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">args_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1707"><a href="#Generator-1707"><span class="linenos">1707</span></a> +</span><span id="Generator-1708"><a href="#Generator-1708"><span class="linenos">1708</span></a> <span class="k">def</span> <span class="nf">offset_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Offset</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1709"><a href="#Generator-1709"><span class="linenos">1709</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-1710"><a href="#Generator-1710"><span class="linenos">1710</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span> +</span><span id="Generator-1711"><a href="#Generator-1711"><span class="linenos">1711</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Generator-1712"><a href="#Generator-1712"><span class="linenos">1712</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_simplify_unless_literal</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">LIMIT_ONLY_LITERALS</span> <span class="k">else</span> <span class="n">expression</span> +</span><span id="Generator-1713"><a href="#Generator-1713"><span class="linenos">1713</span></a> <span class="p">)</span> +</span><span id="Generator-1714"><a href="#Generator-1714"><span class="linenos">1714</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="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'OFFSET'</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="si">}</span><span class="s2">"</span> +</span><span id="Generator-1715"><a href="#Generator-1715"><span class="linenos">1715</span></a> +</span><span id="Generator-1716"><a href="#Generator-1716"><span class="linenos">1716</span></a> <span class="k">def</span> <span class="nf">setitem_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SetItem</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1717"><a href="#Generator-1717"><span class="linenos">1717</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-1718"><a href="#Generator-1718"><span class="linenos">1718</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-1719"><a href="#Generator-1719"><span class="linenos">1719</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-1720"><a href="#Generator-1720"><span class="linenos">1720</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-1721"><a href="#Generator-1721"><span class="linenos">1721</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-1722"><a href="#Generator-1722"><span class="linenos">1722</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-1723"><a href="#Generator-1723"><span class="linenos">1723</span></a> <span class="n">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">"global"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1724"><a href="#Generator-1724"><span class="linenos">1724</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">global_</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">expressions</span><span class="si">}{</span><span class="n">collate</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1725"><a href="#Generator-1725"><span class="linenos">1725</span></a> +</span><span id="Generator-1726"><a href="#Generator-1726"><span class="linenos">1726</span></a> <span class="k">def</span> <span class="nf">set_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Set</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1727"><a href="#Generator-1727"><span class="linenos">1727</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Generator-1728"><a href="#Generator-1728"><span class="linenos">1728</span></a> <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 class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1729"><a href="#Generator-1729"><span class="linenos">1729</span></a> <span class="p">)</span> +</span><span id="Generator-1730"><a href="#Generator-1730"><span class="linenos">1730</span></a> <span class="n">tag</span> <span class="o">=</span> <span class="s2">" TAG"</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">"tag"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1731"><a href="#Generator-1731"><span class="linenos">1731</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="s1">'UNSET'</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">'unset'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">'SET'</span><span class="si">}{</span><span class="n">tag</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1732"><a href="#Generator-1732"><span class="linenos">1732</span></a> +</span><span id="Generator-1733"><a href="#Generator-1733"><span class="linenos">1733</span></a> <span class="k">def</span> <span class="nf">pragma_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Pragma</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1734"><a href="#Generator-1734"><span class="linenos">1734</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PRAGMA </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-1735"><a href="#Generator-1735"><span class="linenos">1735</span></a> -</span><span id="Generator-1736"><a href="#Generator-1736"><span class="linenos">1736</span></a> <span class="n">lock_type</span> <span class="o">=</span> <span class="s2">"FOR UPDATE"</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">"update"</span><span class="p">]</span> <span class="k">else</span> <span class="s2">"FOR SHARE"</span> -</span><span id="Generator-1737"><a href="#Generator-1737"><span class="linenos">1737</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-1738"><a href="#Generator-1738"><span class="linenos">1738</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" OF </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-1739"><a href="#Generator-1739"><span class="linenos">1739</span></a> <span class="n">wait</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">"wait"</span><span class="p">)</span> +</span><span id="Generator-1736"><a href="#Generator-1736"><span class="linenos">1736</span></a> <span class="k">def</span> <span class="nf">lock_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Lock</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1737"><a href="#Generator-1737"><span class="linenos">1737</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">LOCKING_READS_SUPPORTED</span><span class="p">:</span> +</span><span id="Generator-1738"><a href="#Generator-1738"><span class="linenos">1738</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Locking reads using 'FOR UPDATE/SHARE' are not supported"</span><span class="p">)</span> +</span><span id="Generator-1739"><a href="#Generator-1739"><span class="linenos">1739</span></a> <span class="k">return</span> <span class="s2">""</span> </span><span id="Generator-1740"><a href="#Generator-1740"><span class="linenos">1740</span></a> -</span><span id="Generator-1741"><a href="#Generator-1741"><span class="linenos">1741</span></a> <span class="k">if</span> <span class="n">wait</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Generator-1742"><a href="#Generator-1742"><span class="linenos">1742</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">wait</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="p">):</span> -</span><span id="Generator-1743"><a href="#Generator-1743"><span class="linenos">1743</span></a> <span class="n">wait</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" WAIT </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">wait</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1744"><a href="#Generator-1744"><span class="linenos">1744</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator-1745"><a href="#Generator-1745"><span class="linenos">1745</span></a> <span class="n">wait</span> <span class="o">=</span> <span class="s2">" NOWAIT"</span> <span class="k">if</span> <span class="n">wait</span> <span class="k">else</span> <span class="s2">" SKIP LOCKED"</span> -</span><span id="Generator-1746"><a href="#Generator-1746"><span class="linenos">1746</span></a> -</span><span id="Generator-1747"><a href="#Generator-1747"><span class="linenos">1747</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">lock_type</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}{</span><span class="n">wait</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-1748"><a href="#Generator-1748"><span class="linenos">1748</span></a> -</span><span id="Generator-1749"><a href="#Generator-1749"><span class="linenos">1749</span></a> <span class="k">def</span> <span class="nf">literal_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1750"><a href="#Generator-1750"><span class="linenos">1750</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="ow">or</span> <span class="s2">""</span> -</span><span id="Generator-1751"><a href="#Generator-1751"><span class="linenos">1751</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">is_string</span><span class="p">:</span> -</span><span id="Generator-1752"><a href="#Generator-1752"><span class="linenos">1752</span></a> <span class="n">text</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">dialect</span><span class="o">.</span><span class="n">QUOTE_START</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">escape_str</span><span class="p">(</span><span class="n">text</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">QUOTE_END</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1753"><a href="#Generator-1753"><span class="linenos">1753</span></a> <span class="k">return</span> <span class="n">text</span> -</span><span id="Generator-1754"><a href="#Generator-1754"><span class="linenos">1754</span></a> -</span><span id="Generator-1755"><a href="#Generator-1755"><span class="linenos">1755</span></a> <span class="k">def</span> <span class="nf">escape_str</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">text</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-1756"><a href="#Generator-1756"><span class="linenos">1756</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">text</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">QUOTE_END</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_escaped_quote_end</span><span class="p">)</span> -</span><span id="Generator-1757"><a href="#Generator-1757"><span class="linenos">1757</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">INVERSE_ESCAPE_SEQUENCES</span><span class="p">:</span> -</span><span id="Generator-1758"><a href="#Generator-1758"><span class="linenos">1758</span></a> <span class="n">text</span> <span class="o">=</span> <span class="s2">""</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">INVERSE_ESCAPE_SEQUENCES</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">ch</span><span class="p">,</span> <span class="n">ch</span><span class="p">)</span> <span class="k">for</span> <span class="n">ch</span> <span class="ow">in</span> <span class="n">text</span><span class="p">)</span> -</span><span id="Generator-1759"><a href="#Generator-1759"><span class="linenos">1759</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span><span class="p">:</span> -</span><span id="Generator-1760"><a href="#Generator-1760"><span class="linenos">1760</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">text</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">SENTINEL_LINE_BREAK</span><span class="p">)</span> -</span><span id="Generator-1761"><a href="#Generator-1761"><span class="linenos">1761</span></a> <span class="k">return</span> <span class="n">text</span> -</span><span id="Generator-1762"><a href="#Generator-1762"><span class="linenos">1762</span></a> -</span><span id="Generator-1763"><a href="#Generator-1763"><span class="linenos">1763</span></a> <span class="k">def</span> <span class="nf">loaddata_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">LoadData</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1764"><a href="#Generator-1764"><span class="linenos">1764</span></a> <span class="n">local</span> <span class="o">=</span> <span class="s2">" LOCAL"</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">"local"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1765"><a href="#Generator-1765"><span class="linenos">1765</span></a> <span class="n">inpath</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" INPATH </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">'inpath'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1766"><a href="#Generator-1766"><span class="linenos">1766</span></a> <span class="n">overwrite</span> <span class="o">=</span> <span class="s2">" OVERWRITE"</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">"overwrite"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1767"><a href="#Generator-1767"><span class="linenos">1767</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" INTO TABLE </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-1768"><a href="#Generator-1768"><span class="linenos">1768</span></a> <span class="n">partition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"partition"</span><span class="p">)</span> -</span><span id="Generator-1769"><a href="#Generator-1769"><span class="linenos">1769</span></a> <span class="n">partition</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">partition</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">partition</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1770"><a href="#Generator-1770"><span class="linenos">1770</span></a> <span class="n">input_format</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"input_format"</span><span class="p">)</span> -</span><span id="Generator-1771"><a href="#Generator-1771"><span class="linenos">1771</span></a> <span class="n">input_format</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" INPUTFORMAT </span><span class="si">{</span><span class="n">input_format</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">input_format</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1772"><a href="#Generator-1772"><span class="linenos">1772</span></a> <span class="n">serde</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"serde"</span><span class="p">)</span> -</span><span id="Generator-1773"><a href="#Generator-1773"><span class="linenos">1773</span></a> <span class="n">serde</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" SERDE </span><span class="si">{</span><span class="n">serde</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">serde</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1774"><a href="#Generator-1774"><span class="linenos">1774</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"LOAD DATA</span><span class="si">{</span><span class="n">local</span><span class="si">}{</span><span class="n">inpath</span><span class="si">}{</span><span class="n">overwrite</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="n">partition</span><span class="si">}{</span><span class="n">input_format</span><span class="si">}{</span><span class="n">serde</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1775"><a href="#Generator-1775"><span class="linenos">1775</span></a> -</span><span id="Generator-1776"><a href="#Generator-1776"><span class="linenos">1776</span></a> <span class="k">def</span> <span class="nf">null_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">_</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1777"><a href="#Generator-1777"><span class="linenos">1777</span></a> <span class="k">return</span> <span class="s2">"NULL"</span> -</span><span id="Generator-1778"><a href="#Generator-1778"><span class="linenos">1778</span></a> -</span><span id="Generator-1779"><a href="#Generator-1779"><span class="linenos">1779</span></a> <span class="k">def</span> <span class="nf">boolean_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</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 class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1780"><a href="#Generator-1780"><span class="linenos">1780</span></a> <span class="k">return</span> <span class="s2">"TRUE"</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">"FALSE"</span> -</span><span id="Generator-1781"><a href="#Generator-1781"><span class="linenos">1781</span></a> -</span><span id="Generator-1782"><a href="#Generator-1782"><span class="linenos">1782</span></a> <span class="k">def</span> <span class="nf">order_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Order</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-1783"><a href="#Generator-1783"><span class="linenos">1783</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-1784"><a href="#Generator-1784"><span class="linenos">1784</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="n">this</span> -</span><span id="Generator-1785"><a href="#Generator-1785"><span class="linenos">1785</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">op_expressions</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="s2">ORDER BY"</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">this</span> <span class="ow">or</span> <span class="n">flat</span><span class="p">)</span> <span class="c1"># type: ignore</span> +</span><span id="Generator-1741"><a href="#Generator-1741"><span class="linenos">1741</span></a> <span class="n">lock_type</span> <span class="o">=</span> <span class="s2">"FOR UPDATE"</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">"update"</span><span class="p">]</span> <span class="k">else</span> <span class="s2">"FOR SHARE"</span> +</span><span id="Generator-1742"><a href="#Generator-1742"><span class="linenos">1742</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-1743"><a href="#Generator-1743"><span class="linenos">1743</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" OF </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-1744"><a href="#Generator-1744"><span class="linenos">1744</span></a> <span class="n">wait</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">"wait"</span><span class="p">)</span> +</span><span id="Generator-1745"><a href="#Generator-1745"><span class="linenos">1745</span></a> +</span><span id="Generator-1746"><a href="#Generator-1746"><span class="linenos">1746</span></a> <span class="k">if</span> <span class="n">wait</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Generator-1747"><a href="#Generator-1747"><span class="linenos">1747</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">wait</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="p">):</span> +</span><span id="Generator-1748"><a href="#Generator-1748"><span class="linenos">1748</span></a> <span class="n">wait</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" WAIT </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">wait</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1749"><a href="#Generator-1749"><span class="linenos">1749</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator-1750"><a href="#Generator-1750"><span class="linenos">1750</span></a> <span class="n">wait</span> <span class="o">=</span> <span class="s2">" NOWAIT"</span> <span class="k">if</span> <span class="n">wait</span> <span class="k">else</span> <span class="s2">" SKIP LOCKED"</span> +</span><span id="Generator-1751"><a href="#Generator-1751"><span class="linenos">1751</span></a> +</span><span id="Generator-1752"><a href="#Generator-1752"><span class="linenos">1752</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">lock_type</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}{</span><span class="n">wait</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-1753"><a href="#Generator-1753"><span class="linenos">1753</span></a> +</span><span id="Generator-1754"><a href="#Generator-1754"><span class="linenos">1754</span></a> <span class="k">def</span> <span class="nf">literal_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1755"><a href="#Generator-1755"><span class="linenos">1755</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="ow">or</span> <span class="s2">""</span> +</span><span id="Generator-1756"><a href="#Generator-1756"><span class="linenos">1756</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">is_string</span><span class="p">:</span> +</span><span id="Generator-1757"><a href="#Generator-1757"><span class="linenos">1757</span></a> <span class="n">text</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">dialect</span><span class="o">.</span><span class="n">QUOTE_START</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">escape_str</span><span class="p">(</span><span class="n">text</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">QUOTE_END</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1758"><a href="#Generator-1758"><span class="linenos">1758</span></a> <span class="k">return</span> <span class="n">text</span> +</span><span id="Generator-1759"><a href="#Generator-1759"><span class="linenos">1759</span></a> +</span><span id="Generator-1760"><a href="#Generator-1760"><span class="linenos">1760</span></a> <span class="k">def</span> <span class="nf">escape_str</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">text</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-1761"><a href="#Generator-1761"><span class="linenos">1761</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">text</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">QUOTE_END</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_escaped_quote_end</span><span class="p">)</span> +</span><span id="Generator-1762"><a href="#Generator-1762"><span class="linenos">1762</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">INVERSE_ESCAPE_SEQUENCES</span><span class="p">:</span> +</span><span id="Generator-1763"><a href="#Generator-1763"><span class="linenos">1763</span></a> <span class="n">text</span> <span class="o">=</span> <span class="s2">""</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">INVERSE_ESCAPE_SEQUENCES</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">ch</span><span class="p">,</span> <span class="n">ch</span><span class="p">)</span> <span class="k">for</span> <span class="n">ch</span> <span class="ow">in</span> <span class="n">text</span><span class="p">)</span> +</span><span id="Generator-1764"><a href="#Generator-1764"><span class="linenos">1764</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span><span class="p">:</span> +</span><span id="Generator-1765"><a href="#Generator-1765"><span class="linenos">1765</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">text</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">SENTINEL_LINE_BREAK</span><span class="p">)</span> +</span><span id="Generator-1766"><a href="#Generator-1766"><span class="linenos">1766</span></a> <span class="k">return</span> <span class="n">text</span> +</span><span id="Generator-1767"><a href="#Generator-1767"><span class="linenos">1767</span></a> +</span><span id="Generator-1768"><a href="#Generator-1768"><span class="linenos">1768</span></a> <span class="k">def</span> <span class="nf">loaddata_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">LoadData</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1769"><a href="#Generator-1769"><span class="linenos">1769</span></a> <span class="n">local</span> <span class="o">=</span> <span class="s2">" LOCAL"</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">"local"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1770"><a href="#Generator-1770"><span class="linenos">1770</span></a> <span class="n">inpath</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" INPATH </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">'inpath'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1771"><a href="#Generator-1771"><span class="linenos">1771</span></a> <span class="n">overwrite</span> <span class="o">=</span> <span class="s2">" OVERWRITE"</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">"overwrite"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1772"><a href="#Generator-1772"><span class="linenos">1772</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" INTO TABLE </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-1773"><a href="#Generator-1773"><span class="linenos">1773</span></a> <span class="n">partition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"partition"</span><span class="p">)</span> +</span><span id="Generator-1774"><a href="#Generator-1774"><span class="linenos">1774</span></a> <span class="n">partition</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">partition</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">partition</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1775"><a href="#Generator-1775"><span class="linenos">1775</span></a> <span class="n">input_format</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"input_format"</span><span class="p">)</span> +</span><span id="Generator-1776"><a href="#Generator-1776"><span class="linenos">1776</span></a> <span class="n">input_format</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" INPUTFORMAT </span><span class="si">{</span><span class="n">input_format</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">input_format</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1777"><a href="#Generator-1777"><span class="linenos">1777</span></a> <span class="n">serde</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"serde"</span><span class="p">)</span> +</span><span id="Generator-1778"><a href="#Generator-1778"><span class="linenos">1778</span></a> <span class="n">serde</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" SERDE </span><span class="si">{</span><span class="n">serde</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">serde</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1779"><a href="#Generator-1779"><span class="linenos">1779</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"LOAD DATA</span><span class="si">{</span><span class="n">local</span><span class="si">}{</span><span class="n">inpath</span><span class="si">}{</span><span class="n">overwrite</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="n">partition</span><span class="si">}{</span><span class="n">input_format</span><span class="si">}{</span><span class="n">serde</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1780"><a href="#Generator-1780"><span class="linenos">1780</span></a> +</span><span id="Generator-1781"><a href="#Generator-1781"><span class="linenos">1781</span></a> <span class="k">def</span> <span class="nf">null_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">_</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1782"><a href="#Generator-1782"><span class="linenos">1782</span></a> <span class="k">return</span> <span class="s2">"NULL"</span> +</span><span id="Generator-1783"><a href="#Generator-1783"><span class="linenos">1783</span></a> +</span><span id="Generator-1784"><a href="#Generator-1784"><span class="linenos">1784</span></a> <span class="k">def</span> <span class="nf">boolean_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</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 class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1785"><a href="#Generator-1785"><span class="linenos">1785</span></a> <span class="k">return</span> <span class="s2">"TRUE"</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">"FALSE"</span> </span><span id="Generator-1786"><a href="#Generator-1786"><span class="linenos">1786</span></a> -</span><span id="Generator-1787"><a href="#Generator-1787"><span class="linenos">1787</span></a> <span class="k">def</span> <span class="nf">cluster_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cluster</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1788"><a href="#Generator-1788"><span class="linenos">1788</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">op_expressions</span><span class="p">(</span><span class="s2">"CLUSTER BY"</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> -</span><span id="Generator-1789"><a href="#Generator-1789"><span class="linenos">1789</span></a> -</span><span id="Generator-1790"><a href="#Generator-1790"><span class="linenos">1790</span></a> <span class="k">def</span> <span class="nf">distribute_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Distribute</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1791"><a href="#Generator-1791"><span class="linenos">1791</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">op_expressions</span><span class="p">(</span><span class="s2">"DISTRIBUTE BY"</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> -</span><span id="Generator-1792"><a href="#Generator-1792"><span class="linenos">1792</span></a> -</span><span id="Generator-1793"><a href="#Generator-1793"><span class="linenos">1793</span></a> <span class="k">def</span> <span class="nf">sort_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Sort</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1794"><a href="#Generator-1794"><span class="linenos">1794</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">op_expressions</span><span class="p">(</span><span class="s2">"SORT BY"</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> -</span><span id="Generator-1795"><a href="#Generator-1795"><span class="linenos">1795</span></a> -</span><span id="Generator-1796"><a href="#Generator-1796"><span class="linenos">1796</span></a> <span class="k">def</span> <span class="nf">ordered_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Ordered</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1797"><a href="#Generator-1797"><span class="linenos">1797</span></a> <span class="n">desc</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">"desc"</span><span class="p">)</span> -</span><span id="Generator-1798"><a href="#Generator-1798"><span class="linenos">1798</span></a> <span class="n">asc</span> <span class="o">=</span> <span class="ow">not</span> <span class="n">desc</span> -</span><span id="Generator-1799"><a href="#Generator-1799"><span class="linenos">1799</span></a> -</span><span id="Generator-1800"><a href="#Generator-1800"><span class="linenos">1800</span></a> <span class="n">nulls_first</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">"nulls_first"</span><span class="p">)</span> -</span><span id="Generator-1801"><a href="#Generator-1801"><span class="linenos">1801</span></a> <span class="n">nulls_last</span> <span class="o">=</span> <span class="ow">not</span> <span class="n">nulls_first</span> -</span><span id="Generator-1802"><a href="#Generator-1802"><span class="linenos">1802</span></a> <span class="n">nulls_are_large</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">NULL_ORDERING</span> <span class="o">==</span> <span class="s2">"nulls_are_large"</span> -</span><span id="Generator-1803"><a href="#Generator-1803"><span class="linenos">1803</span></a> <span class="n">nulls_are_small</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">NULL_ORDERING</span> <span class="o">==</span> <span class="s2">"nulls_are_small"</span> -</span><span id="Generator-1804"><a href="#Generator-1804"><span class="linenos">1804</span></a> <span class="n">nulls_are_last</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">NULL_ORDERING</span> <span class="o">==</span> <span class="s2">"nulls_are_last"</span> -</span><span id="Generator-1805"><a href="#Generator-1805"><span class="linenos">1805</span></a> -</span><span id="Generator-1806"><a href="#Generator-1806"><span class="linenos">1806</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-1807"><a href="#Generator-1807"><span class="linenos">1807</span></a> -</span><span id="Generator-1808"><a href="#Generator-1808"><span class="linenos">1808</span></a> <span class="n">sort_order</span> <span class="o">=</span> <span class="s2">" DESC"</span> <span class="k">if</span> <span class="n">desc</span> <span class="k">else</span> <span class="p">(</span><span class="s2">" ASC"</span> <span class="k">if</span> <span class="n">desc</span> <span class="ow">is</span> <span class="kc">False</span> <span class="k">else</span> <span class="s2">""</span><span class="p">)</span> -</span><span id="Generator-1809"><a href="#Generator-1809"><span class="linenos">1809</span></a> <span class="n">nulls_sort_change</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator-1810"><a href="#Generator-1810"><span class="linenos">1810</span></a> <span class="k">if</span> <span class="n">nulls_first</span> <span class="ow">and</span> <span class="p">(</span> -</span><span id="Generator-1811"><a href="#Generator-1811"><span class="linenos">1811</span></a> <span class="p">(</span><span class="n">asc</span> <span class="ow">and</span> <span class="n">nulls_are_large</span><span class="p">)</span> <span class="ow">or</span> <span class="p">(</span><span class="n">desc</span> <span class="ow">and</span> <span class="n">nulls_are_small</span><span class="p">)</span> <span class="ow">or</span> <span class="n">nulls_are_last</span> -</span><span id="Generator-1812"><a href="#Generator-1812"><span class="linenos">1812</span></a> <span class="p">):</span> -</span><span id="Generator-1813"><a href="#Generator-1813"><span class="linenos">1813</span></a> <span class="n">nulls_sort_change</span> <span class="o">=</span> <span class="s2">" NULLS FIRST"</span> -</span><span id="Generator-1814"><a href="#Generator-1814"><span class="linenos">1814</span></a> <span class="k">elif</span> <span class="p">(</span> -</span><span id="Generator-1815"><a href="#Generator-1815"><span class="linenos">1815</span></a> <span class="n">nulls_last</span> -</span><span id="Generator-1816"><a href="#Generator-1816"><span class="linenos">1816</span></a> <span class="ow">and</span> <span class="p">((</span><span class="n">asc</span> <span class="ow">and</span> <span class="n">nulls_are_small</span><span class="p">)</span> <span class="ow">or</span> <span class="p">(</span><span class="n">desc</span> <span class="ow">and</span> <span class="n">nulls_are_large</span><span class="p">))</span> -</span><span id="Generator-1817"><a href="#Generator-1817"><span class="linenos">1817</span></a> <span class="ow">and</span> <span class="ow">not</span> <span class="n">nulls_are_last</span> -</span><span id="Generator-1818"><a href="#Generator-1818"><span class="linenos">1818</span></a> <span class="p">):</span> -</span><span id="Generator-1819"><a href="#Generator-1819"><span class="linenos">1819</span></a> <span class="n">nulls_sort_change</span> <span class="o">=</span> <span class="s2">" NULLS LAST"</span> -</span><span id="Generator-1820"><a href="#Generator-1820"><span class="linenos">1820</span></a> -</span><span id="Generator-1821"><a href="#Generator-1821"><span class="linenos">1821</span></a> <span class="c1"># If the NULLS FIRST/LAST clause is unsupported, we add another sort key to simulate it</span> -</span><span id="Generator-1822"><a href="#Generator-1822"><span class="linenos">1822</span></a> <span class="k">if</span> <span class="n">nulls_sort_change</span> <span class="ow">and</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">NULL_ORDERING_SUPPORTED</span><span class="p">:</span> -</span><span id="Generator-1823"><a href="#Generator-1823"><span class="linenos">1823</span></a> <span class="n">null_sort_order</span> <span class="o">=</span> <span class="s2">" DESC"</span> <span class="k">if</span> <span class="n">nulls_sort_change</span> <span class="o">==</span> <span class="s2">" NULLS FIRST"</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1824"><a href="#Generator-1824"><span class="linenos">1824</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"CASE WHEN </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> IS NULL THEN 1 ELSE 0 END</span><span class="si">{</span><span class="n">null_sort_order</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">"</span> -</span><span id="Generator-1825"><a href="#Generator-1825"><span class="linenos">1825</span></a> <span class="n">nulls_sort_change</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator-1826"><a href="#Generator-1826"><span class="linenos">1826</span></a> -</span><span id="Generator-1827"><a href="#Generator-1827"><span class="linenos">1827</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">sort_order</span><span class="si">}{</span><span class="n">nulls_sort_change</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1828"><a href="#Generator-1828"><span class="linenos">1828</span></a> -</span><span id="Generator-1829"><a href="#Generator-1829"><span class="linenos">1829</span></a> <span class="k">def</span> <span class="nf">matchrecognize_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">MatchRecognize</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1830"><a href="#Generator-1830"><span class="linenos">1830</span></a> <span class="n">partition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">partition_by_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Generator-1831"><a href="#Generator-1831"><span class="linenos">1831</span></a> <span class="n">order</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"order"</span><span class="p">)</span> -</span><span id="Generator-1832"><a href="#Generator-1832"><span class="linenos">1832</span></a> <span class="n">measures</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">"measures"</span><span class="p">)</span> -</span><span id="Generator-1833"><a href="#Generator-1833"><span class="linenos">1833</span></a> <span class="n">measures</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="sa">f</span><span class="s2">"MEASURES</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">measures</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> <span class="k">if</span> <span class="n">measures</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1834"><a href="#Generator-1834"><span class="linenos">1834</span></a> <span class="n">rows</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"rows"</span><span class="p">)</span> -</span><span id="Generator-1835"><a href="#Generator-1835"><span class="linenos">1835</span></a> <span class="n">rows</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">rows</span><span class="p">)</span> <span class="k">if</span> <span class="n">rows</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1836"><a href="#Generator-1836"><span class="linenos">1836</span></a> <span class="n">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">"after"</span><span class="p">)</span> -</span><span id="Generator-1837"><a href="#Generator-1837"><span class="linenos">1837</span></a> <span class="n">after</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">after</span><span class="p">)</span> <span class="k">if</span> <span class="n">after</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1838"><a href="#Generator-1838"><span class="linenos">1838</span></a> <span class="n">pattern</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"pattern"</span><span class="p">)</span> -</span><span id="Generator-1839"><a href="#Generator-1839"><span class="linenos">1839</span></a> <span class="n">pattern</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="sa">f</span><span class="s2">"PATTERN (</span><span class="si">{</span><span class="n">pattern</span><span class="si">}</span><span class="s2">)"</span><span class="p">)</span> <span class="k">if</span> <span class="n">pattern</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1840"><a href="#Generator-1840"><span class="linenos">1840</span></a> <span class="n">definition_sqls</span> <span class="o">=</span> <span class="p">[</span> -</span><span id="Generator-1841"><a href="#Generator-1841"><span class="linenos">1841</span></a> <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">definition</span><span class="p">,</span><span class="w"> </span><span class="s1">'alias'</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">definition</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-1842"><a href="#Generator-1842"><span class="linenos">1842</span></a> <span class="k">for</span> <span class="n">definition</span> <span class="ow">in</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">"define"</span><span class="p">,</span> <span class="p">[])</span> -</span><span id="Generator-1843"><a href="#Generator-1843"><span class="linenos">1843</span></a> <span class="p">]</span> -</span><span id="Generator-1844"><a href="#Generator-1844"><span class="linenos">1844</span></a> <span class="n">definitions</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">sqls</span><span class="o">=</span><span class="n">definition_sqls</span><span class="p">)</span> -</span><span id="Generator-1845"><a href="#Generator-1845"><span class="linenos">1845</span></a> <span class="n">define</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="sa">f</span><span class="s2">"DEFINE</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">definitions</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> <span class="k">if</span> <span class="n">definitions</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1846"><a href="#Generator-1846"><span class="linenos">1846</span></a> <span class="n">body</span> <span class="o">=</span> <span class="s2">""</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> -</span><span id="Generator-1847"><a href="#Generator-1847"><span class="linenos">1847</span></a> <span class="p">(</span> -</span><span id="Generator-1848"><a href="#Generator-1848"><span class="linenos">1848</span></a> <span class="n">partition</span><span class="p">,</span> -</span><span id="Generator-1849"><a href="#Generator-1849"><span class="linenos">1849</span></a> <span class="n">order</span><span class="p">,</span> -</span><span id="Generator-1850"><a href="#Generator-1850"><span class="linenos">1850</span></a> <span class="n">measures</span><span class="p">,</span> -</span><span id="Generator-1851"><a href="#Generator-1851"><span class="linenos">1851</span></a> <span class="n">rows</span><span class="p">,</span> -</span><span id="Generator-1852"><a href="#Generator-1852"><span class="linenos">1852</span></a> <span class="n">after</span><span class="p">,</span> -</span><span id="Generator-1853"><a href="#Generator-1853"><span class="linenos">1853</span></a> <span class="n">pattern</span><span class="p">,</span> -</span><span id="Generator-1854"><a href="#Generator-1854"><span class="linenos">1854</span></a> <span class="n">define</span><span class="p">,</span> -</span><span id="Generator-1855"><a href="#Generator-1855"><span class="linenos">1855</span></a> <span class="p">)</span> -</span><span id="Generator-1856"><a href="#Generator-1856"><span class="linenos">1856</span></a> <span class="p">)</span> -</span><span id="Generator-1857"><a href="#Generator-1857"><span class="linenos">1857</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-1858"><a href="#Generator-1858"><span class="linenos">1858</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </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-1859"><a href="#Generator-1859"><span class="linenos">1859</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="s1">'MATCH_RECOGNIZE'</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">wrap</span><span class="p">(</span><span class="n">body</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-1860"><a href="#Generator-1860"><span class="linenos">1860</span></a> -</span><span id="Generator-1861"><a href="#Generator-1861"><span class="linenos">1861</span></a> <span class="k">def</span> <span class="nf">query_modifiers</span><span class="p">(</span><span class="bp">self</span><span 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">sqls</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-1862"><a href="#Generator-1862"><span class="linenos">1862</span></a> <span class="n">limit</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">Fetch</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">]</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">"limit"</span><span class="p">)</span> -</span><span id="Generator-1863"><a href="#Generator-1863"><span class="linenos">1863</span></a> -</span><span id="Generator-1864"><a href="#Generator-1864"><span class="linenos">1864</span></a> <span class="c1"># If the limit is generated as TOP, we need to ensure it's not generated twice</span> -</span><span id="Generator-1865"><a href="#Generator-1865"><span class="linenos">1865</span></a> <span class="n">with_offset_limit_modifiers</span> <span class="o">=</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">limit</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">)</span> <span class="ow">or</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">LIMIT_IS_TOP</span> -</span><span id="Generator-1866"><a href="#Generator-1866"><span class="linenos">1866</span></a> -</span><span id="Generator-1867"><a href="#Generator-1867"><span class="linenos">1867</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">LIMIT_FETCH</span> <span class="o">==</span> <span class="s2">"LIMIT"</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">limit</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span><span class="p">):</span> -</span><span id="Generator-1868"><a href="#Generator-1868"><span class="linenos">1868</span></a> <span class="n">limit</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">(</span><span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">maybe_copy</span><span class="p">(</span><span class="n">limit</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">"count"</span><span class="p">)))</span> -</span><span id="Generator-1869"><a href="#Generator-1869"><span class="linenos">1869</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">LIMIT_FETCH</span> <span class="o">==</span> <span class="s2">"FETCH"</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">limit</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">):</span> -</span><span id="Generator-1870"><a href="#Generator-1870"><span class="linenos">1870</span></a> <span class="n">limit</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span><span class="p">(</span><span class="n">direction</span><span class="o">=</span><span class="s2">"FIRST"</span><span class="p">,</span> <span class="n">count</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">maybe_copy</span><span class="p">(</span><span class="n">limit</span><span class="o">.</span><span class="n">expression</span><span class="p">))</span> +</span><span id="Generator-1787"><a href="#Generator-1787"><span class="linenos">1787</span></a> <span class="k">def</span> <span class="nf">order_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Order</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-1788"><a href="#Generator-1788"><span class="linenos">1788</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-1789"><a href="#Generator-1789"><span class="linenos">1789</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="n">this</span> +</span><span id="Generator-1790"><a href="#Generator-1790"><span class="linenos">1790</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">op_expressions</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="s2">ORDER BY"</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">this</span> <span class="ow">or</span> <span class="n">flat</span><span class="p">)</span> <span class="c1"># type: ignore</span> +</span><span id="Generator-1791"><a href="#Generator-1791"><span class="linenos">1791</span></a> +</span><span id="Generator-1792"><a href="#Generator-1792"><span class="linenos">1792</span></a> <span class="k">def</span> <span class="nf">cluster_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cluster</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1793"><a href="#Generator-1793"><span class="linenos">1793</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">op_expressions</span><span class="p">(</span><span class="s2">"CLUSTER BY"</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> +</span><span id="Generator-1794"><a href="#Generator-1794"><span class="linenos">1794</span></a> +</span><span id="Generator-1795"><a href="#Generator-1795"><span class="linenos">1795</span></a> <span class="k">def</span> <span class="nf">distribute_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Distribute</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1796"><a href="#Generator-1796"><span class="linenos">1796</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">op_expressions</span><span class="p">(</span><span class="s2">"DISTRIBUTE BY"</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> +</span><span id="Generator-1797"><a href="#Generator-1797"><span class="linenos">1797</span></a> +</span><span id="Generator-1798"><a href="#Generator-1798"><span class="linenos">1798</span></a> <span class="k">def</span> <span class="nf">sort_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Sort</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1799"><a href="#Generator-1799"><span class="linenos">1799</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">op_expressions</span><span class="p">(</span><span class="s2">"SORT BY"</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> +</span><span id="Generator-1800"><a href="#Generator-1800"><span class="linenos">1800</span></a> +</span><span id="Generator-1801"><a href="#Generator-1801"><span class="linenos">1801</span></a> <span class="k">def</span> <span class="nf">ordered_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Ordered</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1802"><a href="#Generator-1802"><span class="linenos">1802</span></a> <span class="n">desc</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">"desc"</span><span class="p">)</span> +</span><span id="Generator-1803"><a href="#Generator-1803"><span class="linenos">1803</span></a> <span class="n">asc</span> <span class="o">=</span> <span class="ow">not</span> <span class="n">desc</span> +</span><span id="Generator-1804"><a href="#Generator-1804"><span class="linenos">1804</span></a> +</span><span id="Generator-1805"><a href="#Generator-1805"><span class="linenos">1805</span></a> <span class="n">nulls_first</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">"nulls_first"</span><span class="p">)</span> +</span><span id="Generator-1806"><a href="#Generator-1806"><span class="linenos">1806</span></a> <span class="n">nulls_last</span> <span class="o">=</span> <span class="ow">not</span> <span class="n">nulls_first</span> +</span><span id="Generator-1807"><a href="#Generator-1807"><span class="linenos">1807</span></a> <span class="n">nulls_are_large</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">NULL_ORDERING</span> <span class="o">==</span> <span class="s2">"nulls_are_large"</span> +</span><span id="Generator-1808"><a href="#Generator-1808"><span class="linenos">1808</span></a> <span class="n">nulls_are_small</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">NULL_ORDERING</span> <span class="o">==</span> <span class="s2">"nulls_are_small"</span> +</span><span id="Generator-1809"><a href="#Generator-1809"><span class="linenos">1809</span></a> <span class="n">nulls_are_last</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">NULL_ORDERING</span> <span class="o">==</span> <span class="s2">"nulls_are_last"</span> +</span><span id="Generator-1810"><a href="#Generator-1810"><span class="linenos">1810</span></a> +</span><span id="Generator-1811"><a href="#Generator-1811"><span class="linenos">1811</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-1812"><a href="#Generator-1812"><span class="linenos">1812</span></a> +</span><span id="Generator-1813"><a href="#Generator-1813"><span class="linenos">1813</span></a> <span class="n">sort_order</span> <span class="o">=</span> <span class="s2">" DESC"</span> <span class="k">if</span> <span class="n">desc</span> <span class="k">else</span> <span class="p">(</span><span class="s2">" ASC"</span> <span class="k">if</span> <span class="n">desc</span> <span class="ow">is</span> <span class="kc">False</span> <span class="k">else</span> <span class="s2">""</span><span class="p">)</span> +</span><span id="Generator-1814"><a href="#Generator-1814"><span class="linenos">1814</span></a> <span class="n">nulls_sort_change</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator-1815"><a href="#Generator-1815"><span class="linenos">1815</span></a> <span class="k">if</span> <span class="n">nulls_first</span> <span class="ow">and</span> <span class="p">(</span> +</span><span id="Generator-1816"><a href="#Generator-1816"><span class="linenos">1816</span></a> <span class="p">(</span><span class="n">asc</span> <span class="ow">and</span> <span class="n">nulls_are_large</span><span class="p">)</span> <span class="ow">or</span> <span class="p">(</span><span class="n">desc</span> <span class="ow">and</span> <span class="n">nulls_are_small</span><span class="p">)</span> <span class="ow">or</span> <span class="n">nulls_are_last</span> +</span><span id="Generator-1817"><a href="#Generator-1817"><span class="linenos">1817</span></a> <span class="p">):</span> +</span><span id="Generator-1818"><a href="#Generator-1818"><span class="linenos">1818</span></a> <span class="n">nulls_sort_change</span> <span class="o">=</span> <span class="s2">" NULLS FIRST"</span> +</span><span id="Generator-1819"><a href="#Generator-1819"><span class="linenos">1819</span></a> <span class="k">elif</span> <span class="p">(</span> +</span><span id="Generator-1820"><a href="#Generator-1820"><span class="linenos">1820</span></a> <span class="n">nulls_last</span> +</span><span id="Generator-1821"><a href="#Generator-1821"><span class="linenos">1821</span></a> <span class="ow">and</span> <span class="p">((</span><span class="n">asc</span> <span class="ow">and</span> <span class="n">nulls_are_small</span><span class="p">)</span> <span class="ow">or</span> <span class="p">(</span><span class="n">desc</span> <span class="ow">and</span> <span class="n">nulls_are_large</span><span class="p">))</span> +</span><span id="Generator-1822"><a href="#Generator-1822"><span class="linenos">1822</span></a> <span class="ow">and</span> <span class="ow">not</span> <span class="n">nulls_are_last</span> +</span><span id="Generator-1823"><a href="#Generator-1823"><span class="linenos">1823</span></a> <span class="p">):</span> +</span><span id="Generator-1824"><a href="#Generator-1824"><span class="linenos">1824</span></a> <span class="n">nulls_sort_change</span> <span class="o">=</span> <span class="s2">" NULLS LAST"</span> +</span><span id="Generator-1825"><a href="#Generator-1825"><span class="linenos">1825</span></a> +</span><span id="Generator-1826"><a href="#Generator-1826"><span class="linenos">1826</span></a> <span class="c1"># If the NULLS FIRST/LAST clause is unsupported, we add another sort key to simulate it</span> +</span><span id="Generator-1827"><a href="#Generator-1827"><span class="linenos">1827</span></a> <span class="k">if</span> <span class="n">nulls_sort_change</span> <span class="ow">and</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">NULL_ORDERING_SUPPORTED</span><span class="p">:</span> +</span><span id="Generator-1828"><a href="#Generator-1828"><span class="linenos">1828</span></a> <span class="n">null_sort_order</span> <span class="o">=</span> <span class="s2">" DESC"</span> <span class="k">if</span> <span class="n">nulls_sort_change</span> <span class="o">==</span> <span class="s2">" NULLS FIRST"</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1829"><a href="#Generator-1829"><span class="linenos">1829</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"CASE WHEN </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> IS NULL THEN 1 ELSE 0 END</span><span class="si">{</span><span class="n">null_sort_order</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">"</span> +</span><span id="Generator-1830"><a href="#Generator-1830"><span class="linenos">1830</span></a> <span class="n">nulls_sort_change</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator-1831"><a href="#Generator-1831"><span class="linenos">1831</span></a> +</span><span id="Generator-1832"><a href="#Generator-1832"><span class="linenos">1832</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">sort_order</span><span class="si">}{</span><span class="n">nulls_sort_change</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1833"><a href="#Generator-1833"><span class="linenos">1833</span></a> +</span><span id="Generator-1834"><a href="#Generator-1834"><span class="linenos">1834</span></a> <span class="k">def</span> <span class="nf">matchrecognize_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">MatchRecognize</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1835"><a href="#Generator-1835"><span class="linenos">1835</span></a> <span class="n">partition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">partition_by_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Generator-1836"><a href="#Generator-1836"><span class="linenos">1836</span></a> <span class="n">order</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"order"</span><span class="p">)</span> +</span><span id="Generator-1837"><a href="#Generator-1837"><span class="linenos">1837</span></a> <span class="n">measures</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">"measures"</span><span class="p">)</span> +</span><span id="Generator-1838"><a href="#Generator-1838"><span class="linenos">1838</span></a> <span class="n">measures</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="sa">f</span><span class="s2">"MEASURES</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">measures</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> <span class="k">if</span> <span class="n">measures</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1839"><a href="#Generator-1839"><span class="linenos">1839</span></a> <span class="n">rows</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"rows"</span><span class="p">)</span> +</span><span id="Generator-1840"><a href="#Generator-1840"><span class="linenos">1840</span></a> <span class="n">rows</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">rows</span><span class="p">)</span> <span class="k">if</span> <span class="n">rows</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1841"><a href="#Generator-1841"><span class="linenos">1841</span></a> <span class="n">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">"after"</span><span class="p">)</span> +</span><span id="Generator-1842"><a href="#Generator-1842"><span class="linenos">1842</span></a> <span class="n">after</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">after</span><span class="p">)</span> <span class="k">if</span> <span class="n">after</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1843"><a href="#Generator-1843"><span class="linenos">1843</span></a> <span class="n">pattern</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"pattern"</span><span class="p">)</span> +</span><span id="Generator-1844"><a href="#Generator-1844"><span class="linenos">1844</span></a> <span class="n">pattern</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="sa">f</span><span class="s2">"PATTERN (</span><span class="si">{</span><span class="n">pattern</span><span class="si">}</span><span class="s2">)"</span><span class="p">)</span> <span class="k">if</span> <span class="n">pattern</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1845"><a href="#Generator-1845"><span class="linenos">1845</span></a> <span class="n">definition_sqls</span> <span class="o">=</span> <span class="p">[</span> +</span><span id="Generator-1846"><a href="#Generator-1846"><span class="linenos">1846</span></a> <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">definition</span><span class="p">,</span><span class="w"> </span><span class="s1">'alias'</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">definition</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-1847"><a href="#Generator-1847"><span class="linenos">1847</span></a> <span class="k">for</span> <span class="n">definition</span> <span class="ow">in</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">"define"</span><span class="p">,</span> <span class="p">[])</span> +</span><span id="Generator-1848"><a href="#Generator-1848"><span class="linenos">1848</span></a> <span class="p">]</span> +</span><span id="Generator-1849"><a href="#Generator-1849"><span class="linenos">1849</span></a> <span class="n">definitions</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">sqls</span><span class="o">=</span><span class="n">definition_sqls</span><span class="p">)</span> +</span><span id="Generator-1850"><a href="#Generator-1850"><span class="linenos">1850</span></a> <span class="n">define</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="sa">f</span><span class="s2">"DEFINE</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">definitions</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> <span class="k">if</span> <span class="n">definitions</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1851"><a href="#Generator-1851"><span class="linenos">1851</span></a> <span class="n">body</span> <span class="o">=</span> <span class="s2">""</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> +</span><span id="Generator-1852"><a href="#Generator-1852"><span class="linenos">1852</span></a> <span class="p">(</span> +</span><span id="Generator-1853"><a href="#Generator-1853"><span class="linenos">1853</span></a> <span class="n">partition</span><span class="p">,</span> +</span><span id="Generator-1854"><a href="#Generator-1854"><span class="linenos">1854</span></a> <span class="n">order</span><span class="p">,</span> +</span><span id="Generator-1855"><a href="#Generator-1855"><span class="linenos">1855</span></a> <span class="n">measures</span><span class="p">,</span> +</span><span id="Generator-1856"><a href="#Generator-1856"><span class="linenos">1856</span></a> <span class="n">rows</span><span class="p">,</span> +</span><span id="Generator-1857"><a href="#Generator-1857"><span class="linenos">1857</span></a> <span class="n">after</span><span class="p">,</span> +</span><span id="Generator-1858"><a href="#Generator-1858"><span class="linenos">1858</span></a> <span class="n">pattern</span><span class="p">,</span> +</span><span id="Generator-1859"><a href="#Generator-1859"><span class="linenos">1859</span></a> <span class="n">define</span><span class="p">,</span> +</span><span id="Generator-1860"><a href="#Generator-1860"><span class="linenos">1860</span></a> <span class="p">)</span> +</span><span id="Generator-1861"><a href="#Generator-1861"><span class="linenos">1861</span></a> <span class="p">)</span> +</span><span id="Generator-1862"><a href="#Generator-1862"><span class="linenos">1862</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-1863"><a href="#Generator-1863"><span class="linenos">1863</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </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-1864"><a href="#Generator-1864"><span class="linenos">1864</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="s1">'MATCH_RECOGNIZE'</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">wrap</span><span class="p">(</span><span class="n">body</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-1865"><a href="#Generator-1865"><span class="linenos">1865</span></a> +</span><span id="Generator-1866"><a href="#Generator-1866"><span class="linenos">1866</span></a> <span class="k">def</span> <span class="nf">query_modifiers</span><span class="p">(</span><span class="bp">self</span><span 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">sqls</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-1867"><a href="#Generator-1867"><span class="linenos">1867</span></a> <span class="n">limit</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">Fetch</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">]</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">"limit"</span><span class="p">)</span> +</span><span id="Generator-1868"><a href="#Generator-1868"><span class="linenos">1868</span></a> +</span><span id="Generator-1869"><a href="#Generator-1869"><span class="linenos">1869</span></a> <span class="c1"># If the limit is generated as TOP, we need to ensure it's not generated twice</span> +</span><span id="Generator-1870"><a href="#Generator-1870"><span class="linenos">1870</span></a> <span class="n">with_offset_limit_modifiers</span> <span class="o">=</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">limit</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">)</span> <span class="ow">or</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">LIMIT_IS_TOP</span> </span><span id="Generator-1871"><a href="#Generator-1871"><span class="linenos">1871</span></a> -</span><span id="Generator-1872"><a href="#Generator-1872"><span class="linenos">1872</span></a> <span class="n">fetch</span> <span class="o">=</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">limit</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span><span class="p">)</span> -</span><span id="Generator-1873"><a href="#Generator-1873"><span class="linenos">1873</span></a> -</span><span id="Generator-1874"><a href="#Generator-1874"><span class="linenos">1874</span></a> <span class="n">offset_limit_modifiers</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Generator-1875"><a href="#Generator-1875"><span class="linenos">1875</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">offset_limit_modifiers</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">fetch</span><span class="p">,</span> <span class="n">limit</span><span class="p">)</span> -</span><span id="Generator-1876"><a href="#Generator-1876"><span class="linenos">1876</span></a> <span class="k">if</span> <span class="n">with_offset_limit_modifiers</span> -</span><span id="Generator-1877"><a href="#Generator-1877"><span class="linenos">1877</span></a> <span class="k">else</span> <span class="p">[]</span> -</span><span id="Generator-1878"><a href="#Generator-1878"><span class="linenos">1878</span></a> <span class="p">)</span> -</span><span id="Generator-1879"><a href="#Generator-1879"><span class="linenos">1879</span></a> -</span><span id="Generator-1880"><a href="#Generator-1880"><span class="linenos">1880</span></a> <span class="k">return</span> <span class="n">csv</span><span class="p">(</span> -</span><span id="Generator-1881"><a href="#Generator-1881"><span class="linenos">1881</span></a> <span class="o">*</span><span class="n">sqls</span><span class="p">,</span> -</span><span id="Generator-1882"><a href="#Generator-1882"><span class="linenos">1882</span></a> <span class="o">*</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">join</span><span class="p">)</span> <span class="k">for</span> <span class="n">join</span> <span class="ow">in</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">"joins"</span><span class="p">)</span> <span class="ow">or</span> <span class="p">[]],</span> -</span><span id="Generator-1883"><a href="#Generator-1883"><span class="linenos">1883</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">"connect"</span><span class="p">),</span> -</span><span id="Generator-1884"><a href="#Generator-1884"><span class="linenos">1884</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">"match"</span><span class="p">),</span> -</span><span id="Generator-1885"><a href="#Generator-1885"><span class="linenos">1885</span></a> <span class="o">*</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">lateral</span><span class="p">)</span> <span class="k">for</span> <span class="n">lateral</span> <span class="ow">in</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">"laterals"</span><span class="p">)</span> <span class="ow">or</span> <span class="p">[]],</span> -</span><span id="Generator-1886"><a href="#Generator-1886"><span class="linenos">1886</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">"where"</span><span class="p">),</span> -</span><span id="Generator-1887"><a href="#Generator-1887"><span class="linenos">1887</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">"group"</span><span class="p">),</span> -</span><span id="Generator-1888"><a href="#Generator-1888"><span class="linenos">1888</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">"having"</span><span class="p">),</span> -</span><span id="Generator-1889"><a href="#Generator-1889"><span class="linenos">1889</span></a> <span class="o">*</span><span class="bp">self</span><span class="o">.</span><span class="n">after_having_modifiers</span><span class="p">(</span><span class="n">expression</span><span class="p">),</span> -</span><span id="Generator-1890"><a href="#Generator-1890"><span class="linenos">1890</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">"order"</span><span class="p">),</span> -</span><span id="Generator-1891"><a href="#Generator-1891"><span class="linenos">1891</span></a> <span class="o">*</span><span class="n">offset_limit_modifiers</span><span class="p">,</span> -</span><span id="Generator-1892"><a href="#Generator-1892"><span class="linenos">1892</span></a> <span class="o">*</span><span class="bp">self</span><span class="o">.</span><span class="n">after_limit_modifiers</span><span class="p">(</span><span class="n">expression</span><span class="p">),</span> -</span><span id="Generator-1893"><a href="#Generator-1893"><span class="linenos">1893</span></a> <span class="n">sep</span><span class="o">=</span><span class="s2">""</span><span class="p">,</span> -</span><span id="Generator-1894"><a href="#Generator-1894"><span class="linenos">1894</span></a> <span class="p">)</span> -</span><span id="Generator-1895"><a href="#Generator-1895"><span class="linenos">1895</span></a> -</span><span id="Generator-1896"><a href="#Generator-1896"><span class="linenos">1896</span></a> <span class="k">def</span> <span class="nf">offset_limit_modifiers</span><span class="p">(</span> -</span><span id="Generator-1897"><a href="#Generator-1897"><span class="linenos">1897</span></a> <span class="bp">self</span><span 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">fetch</span><span class="p">:</span> <span class="nb">bool</span><span class="p">,</span> <span class="n">limit</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">Fetch</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">]</span> -</span><span id="Generator-1898"><a href="#Generator-1898"><span class="linenos">1898</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> -</span><span id="Generator-1899"><a href="#Generator-1899"><span class="linenos">1899</span></a> <span class="k">return</span> <span class="p">[</span> -</span><span id="Generator-1900"><a href="#Generator-1900"><span class="linenos">1900</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">"offset"</span><span class="p">)</span> <span class="k">if</span> <span class="n">fetch</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">limit</span><span class="p">),</span> -</span><span id="Generator-1901"><a href="#Generator-1901"><span class="linenos">1901</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">limit</span><span class="p">)</span> <span class="k">if</span> <span class="n">fetch</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">expression</span><span class="p">,</span> <span class="s2">"offset"</span><span class="p">),</span> -</span><span id="Generator-1902"><a href="#Generator-1902"><span class="linenos">1902</span></a> <span class="p">]</span> -</span><span id="Generator-1903"><a href="#Generator-1903"><span class="linenos">1903</span></a> -</span><span id="Generator-1904"><a href="#Generator-1904"><span class="linenos">1904</span></a> <span class="k">def</span> <span class="nf">after_having_modifiers</span><span class="p">(</span><span class="bp">self</span><span 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">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> -</span><span id="Generator-1905"><a href="#Generator-1905"><span class="linenos">1905</span></a> <span class="k">return</span> <span class="p">[</span> -</span><span id="Generator-1906"><a href="#Generator-1906"><span class="linenos">1906</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">"qualify"</span><span class="p">),</span> -</span><span id="Generator-1907"><a href="#Generator-1907"><span class="linenos">1907</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s2">"WINDOW "</span><span class="p">)</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">"windows"</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-1908"><a href="#Generator-1908"><span class="linenos">1908</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">"windows"</span><span class="p">)</span> -</span><span id="Generator-1909"><a href="#Generator-1909"><span class="linenos">1909</span></a> <span class="k">else</span> <span class="s2">""</span><span class="p">,</span> -</span><span id="Generator-1910"><a href="#Generator-1910"><span class="linenos">1910</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">"distribute"</span><span class="p">),</span> -</span><span id="Generator-1911"><a href="#Generator-1911"><span class="linenos">1911</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">"sort"</span><span class="p">),</span> -</span><span id="Generator-1912"><a href="#Generator-1912"><span class="linenos">1912</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">"cluster"</span><span class="p">),</span> -</span><span id="Generator-1913"><a href="#Generator-1913"><span class="linenos">1913</span></a> <span class="p">]</span> -</span><span id="Generator-1914"><a href="#Generator-1914"><span class="linenos">1914</span></a> -</span><span id="Generator-1915"><a href="#Generator-1915"><span class="linenos">1915</span></a> <span class="k">def</span> <span class="nf">after_limit_modifiers</span><span class="p">(</span><span class="bp">self</span><span 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">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> -</span><span id="Generator-1916"><a href="#Generator-1916"><span class="linenos">1916</span></a> <span class="n">locks</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">"locks"</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-1917"><a href="#Generator-1917"><span class="linenos">1917</span></a> <span class="n">locks</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">locks</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">locks</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1918"><a href="#Generator-1918"><span class="linenos">1918</span></a> <span class="k">return</span> <span class="p">[</span><span class="n">locks</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">"sample"</span><span class="p">)]</span> +</span><span id="Generator-1872"><a href="#Generator-1872"><span class="linenos">1872</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">LIMIT_FETCH</span> <span class="o">==</span> <span class="s2">"LIMIT"</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">limit</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span><span class="p">):</span> +</span><span id="Generator-1873"><a href="#Generator-1873"><span class="linenos">1873</span></a> <span class="n">limit</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">(</span><span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">maybe_copy</span><span class="p">(</span><span class="n">limit</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">"count"</span><span class="p">)))</span> +</span><span id="Generator-1874"><a href="#Generator-1874"><span class="linenos">1874</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">LIMIT_FETCH</span> <span class="o">==</span> <span class="s2">"FETCH"</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">limit</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">):</span> +</span><span id="Generator-1875"><a href="#Generator-1875"><span class="linenos">1875</span></a> <span class="n">limit</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span><span class="p">(</span><span class="n">direction</span><span class="o">=</span><span class="s2">"FIRST"</span><span class="p">,</span> <span class="n">count</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">maybe_copy</span><span class="p">(</span><span class="n">limit</span><span class="o">.</span><span class="n">expression</span><span class="p">))</span> +</span><span id="Generator-1876"><a href="#Generator-1876"><span class="linenos">1876</span></a> +</span><span id="Generator-1877"><a href="#Generator-1877"><span class="linenos">1877</span></a> <span class="n">fetch</span> <span class="o">=</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">limit</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span><span class="p">)</span> +</span><span id="Generator-1878"><a href="#Generator-1878"><span class="linenos">1878</span></a> +</span><span id="Generator-1879"><a href="#Generator-1879"><span class="linenos">1879</span></a> <span class="n">offset_limit_modifiers</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Generator-1880"><a href="#Generator-1880"><span class="linenos">1880</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">offset_limit_modifiers</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">fetch</span><span class="p">,</span> <span class="n">limit</span><span class="p">)</span> +</span><span id="Generator-1881"><a href="#Generator-1881"><span class="linenos">1881</span></a> <span class="k">if</span> <span class="n">with_offset_limit_modifiers</span> +</span><span id="Generator-1882"><a href="#Generator-1882"><span class="linenos">1882</span></a> <span class="k">else</span> <span class="p">[]</span> +</span><span id="Generator-1883"><a href="#Generator-1883"><span class="linenos">1883</span></a> <span class="p">)</span> +</span><span id="Generator-1884"><a href="#Generator-1884"><span class="linenos">1884</span></a> +</span><span id="Generator-1885"><a href="#Generator-1885"><span class="linenos">1885</span></a> <span class="k">return</span> <span class="n">csv</span><span class="p">(</span> +</span><span id="Generator-1886"><a href="#Generator-1886"><span class="linenos">1886</span></a> <span class="o">*</span><span class="n">sqls</span><span class="p">,</span> +</span><span id="Generator-1887"><a href="#Generator-1887"><span class="linenos">1887</span></a> <span class="o">*</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">join</span><span class="p">)</span> <span class="k">for</span> <span class="n">join</span> <span class="ow">in</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">"joins"</span><span class="p">)</span> <span class="ow">or</span> <span class="p">[]],</span> +</span><span id="Generator-1888"><a href="#Generator-1888"><span class="linenos">1888</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">"connect"</span><span class="p">),</span> +</span><span id="Generator-1889"><a href="#Generator-1889"><span class="linenos">1889</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">"match"</span><span class="p">),</span> +</span><span id="Generator-1890"><a href="#Generator-1890"><span class="linenos">1890</span></a> <span class="o">*</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">lateral</span><span class="p">)</span> <span class="k">for</span> <span class="n">lateral</span> <span class="ow">in</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">"laterals"</span><span class="p">)</span> <span class="ow">or</span> <span class="p">[]],</span> +</span><span id="Generator-1891"><a href="#Generator-1891"><span class="linenos">1891</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">"where"</span><span class="p">),</span> +</span><span id="Generator-1892"><a href="#Generator-1892"><span class="linenos">1892</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">"group"</span><span class="p">),</span> +</span><span id="Generator-1893"><a href="#Generator-1893"><span class="linenos">1893</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">"having"</span><span class="p">),</span> +</span><span id="Generator-1894"><a href="#Generator-1894"><span class="linenos">1894</span></a> <span class="o">*</span><span class="bp">self</span><span class="o">.</span><span class="n">after_having_modifiers</span><span class="p">(</span><span class="n">expression</span><span class="p">),</span> +</span><span id="Generator-1895"><a href="#Generator-1895"><span class="linenos">1895</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">"order"</span><span class="p">),</span> +</span><span id="Generator-1896"><a href="#Generator-1896"><span class="linenos">1896</span></a> <span class="o">*</span><span class="n">offset_limit_modifiers</span><span class="p">,</span> +</span><span id="Generator-1897"><a href="#Generator-1897"><span class="linenos">1897</span></a> <span class="o">*</span><span class="bp">self</span><span class="o">.</span><span class="n">after_limit_modifiers</span><span class="p">(</span><span class="n">expression</span><span class="p">),</span> +</span><span id="Generator-1898"><a href="#Generator-1898"><span class="linenos">1898</span></a> <span class="n">sep</span><span class="o">=</span><span class="s2">""</span><span class="p">,</span> +</span><span id="Generator-1899"><a href="#Generator-1899"><span class="linenos">1899</span></a> <span class="p">)</span> +</span><span id="Generator-1900"><a href="#Generator-1900"><span class="linenos">1900</span></a> +</span><span id="Generator-1901"><a href="#Generator-1901"><span class="linenos">1901</span></a> <span class="k">def</span> <span class="nf">offset_limit_modifiers</span><span class="p">(</span> +</span><span id="Generator-1902"><a href="#Generator-1902"><span class="linenos">1902</span></a> <span class="bp">self</span><span 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">fetch</span><span class="p">:</span> <span class="nb">bool</span><span class="p">,</span> <span class="n">limit</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">Fetch</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">]</span> +</span><span id="Generator-1903"><a href="#Generator-1903"><span class="linenos">1903</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> +</span><span id="Generator-1904"><a href="#Generator-1904"><span class="linenos">1904</span></a> <span class="k">return</span> <span class="p">[</span> +</span><span id="Generator-1905"><a href="#Generator-1905"><span class="linenos">1905</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">"offset"</span><span class="p">)</span> <span class="k">if</span> <span class="n">fetch</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">limit</span><span class="p">),</span> +</span><span id="Generator-1906"><a href="#Generator-1906"><span class="linenos">1906</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">limit</span><span class="p">)</span> <span class="k">if</span> <span class="n">fetch</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">expression</span><span class="p">,</span> <span class="s2">"offset"</span><span class="p">),</span> +</span><span id="Generator-1907"><a href="#Generator-1907"><span class="linenos">1907</span></a> <span class="p">]</span> +</span><span id="Generator-1908"><a href="#Generator-1908"><span class="linenos">1908</span></a> +</span><span id="Generator-1909"><a href="#Generator-1909"><span class="linenos">1909</span></a> <span class="k">def</span> <span class="nf">after_having_modifiers</span><span class="p">(</span><span class="bp">self</span><span 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">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> +</span><span id="Generator-1910"><a href="#Generator-1910"><span class="linenos">1910</span></a> <span class="k">return</span> <span class="p">[</span> +</span><span id="Generator-1911"><a href="#Generator-1911"><span class="linenos">1911</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">"qualify"</span><span class="p">),</span> +</span><span id="Generator-1912"><a href="#Generator-1912"><span class="linenos">1912</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s2">"WINDOW "</span><span class="p">)</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">"windows"</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-1913"><a href="#Generator-1913"><span class="linenos">1913</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">"windows"</span><span class="p">)</span> +</span><span id="Generator-1914"><a href="#Generator-1914"><span class="linenos">1914</span></a> <span class="k">else</span> <span class="s2">""</span><span class="p">,</span> +</span><span id="Generator-1915"><a href="#Generator-1915"><span class="linenos">1915</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">"distribute"</span><span class="p">),</span> +</span><span id="Generator-1916"><a href="#Generator-1916"><span class="linenos">1916</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">"sort"</span><span class="p">),</span> +</span><span id="Generator-1917"><a href="#Generator-1917"><span class="linenos">1917</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">"cluster"</span><span class="p">),</span> +</span><span id="Generator-1918"><a href="#Generator-1918"><span class="linenos">1918</span></a> <span class="p">]</span> </span><span id="Generator-1919"><a href="#Generator-1919"><span class="linenos">1919</span></a> -</span><span id="Generator-1920"><a href="#Generator-1920"><span class="linenos">1920</span></a> <span class="k">def</span> <span class="nf">select_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1921"><a href="#Generator-1921"><span class="linenos">1921</span></a> <span class="n">hint</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"hint"</span><span class="p">)</span> -</span><span id="Generator-1922"><a href="#Generator-1922"><span class="linenos">1922</span></a> <span class="n">distinct</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"distinct"</span><span class="p">)</span> -</span><span id="Generator-1923"><a href="#Generator-1923"><span class="linenos">1923</span></a> <span class="n">distinct</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">distinct</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">distinct</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1924"><a href="#Generator-1924"><span class="linenos">1924</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 class="o">.</span><span class="n">upper</span><span class="p">()</span> -</span><span id="Generator-1925"><a href="#Generator-1925"><span class="linenos">1925</span></a> <span class="n">limit</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">"limit"</span><span class="p">)</span> -</span><span id="Generator-1926"><a href="#Generator-1926"><span class="linenos">1926</span></a> <span class="n">top</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Generator-1927"><a href="#Generator-1927"><span class="linenos">1927</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">limit_sql</span><span class="p">(</span><span class="n">limit</span><span class="p">,</span> <span class="n">top</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator-1928"><a href="#Generator-1928"><span class="linenos">1928</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">limit</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">LIMIT_IS_TOP</span> -</span><span id="Generator-1929"><a href="#Generator-1929"><span class="linenos">1929</span></a> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1930"><a href="#Generator-1930"><span class="linenos">1930</span></a> <span class="p">)</span> -</span><span id="Generator-1931"><a href="#Generator-1931"><span class="linenos">1931</span></a> -</span><span id="Generator-1932"><a href="#Generator-1932"><span class="linenos">1932</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-1933"><a href="#Generator-1933"><span class="linenos">1933</span></a> -</span><span id="Generator-1934"><a href="#Generator-1934"><span class="linenos">1934</span></a> <span class="k">if</span> <span class="n">kind</span><span class="p">:</span> -</span><span id="Generator-1935"><a href="#Generator-1935"><span class="linenos">1935</span></a> <span class="k">if</span> <span class="n">kind</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">SELECT_KINDS</span><span class="p">:</span> -</span><span id="Generator-1936"><a href="#Generator-1936"><span class="linenos">1936</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1937"><a href="#Generator-1937"><span class="linenos">1937</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator-1938"><a href="#Generator-1938"><span class="linenos">1938</span></a> <span class="k">if</span> <span class="n">kind</span> <span class="o">==</span> <span class="s2">"STRUCT"</span><span class="p">:</span> -</span><span id="Generator-1939"><a href="#Generator-1939"><span class="linenos">1939</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><span id="Generator-1940"><a href="#Generator-1940"><span class="linenos">1940</span></a> <span class="n">sqls</span><span class="o">=</span><span class="p">[</span> -</span><span id="Generator-1941"><a href="#Generator-1941"><span class="linenos">1941</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span> -</span><span id="Generator-1942"><a href="#Generator-1942"><span class="linenos">1942</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Struct</span><span class="p">(</span> -</span><span id="Generator-1943"><a href="#Generator-1943"><span class="linenos">1943</span></a> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span> -</span><span id="Generator-1944"><a href="#Generator-1944"><span class="linenos">1944</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">column</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">output_name</span><span class="p">)</span><span class="o">.</span><span class="n">eq</span><span class="p">(</span> -</span><span id="Generator-1945"><a href="#Generator-1945"><span class="linenos">1945</span></a> <span class="n">e</span><span class="o">.</span><span class="n">this</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">Alias</span><span class="p">)</span> <span class="k">else</span> <span class="n">e</span> -</span><span id="Generator-1946"><a href="#Generator-1946"><span class="linenos">1946</span></a> <span class="p">)</span> -</span><span id="Generator-1947"><a href="#Generator-1947"><span class="linenos">1947</span></a> <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">expressions</span> -</span><span id="Generator-1948"><a href="#Generator-1948"><span class="linenos">1948</span></a> <span class="p">]</span> -</span><span id="Generator-1949"><a href="#Generator-1949"><span class="linenos">1949</span></a> <span class="p">)</span> -</span><span id="Generator-1950"><a href="#Generator-1950"><span class="linenos">1950</span></a> <span class="p">)</span> -</span><span id="Generator-1951"><a href="#Generator-1951"><span class="linenos">1951</span></a> <span class="p">]</span> -</span><span id="Generator-1952"><a href="#Generator-1952"><span class="linenos">1952</span></a> <span class="p">)</span> -</span><span id="Generator-1953"><a href="#Generator-1953"><span class="linenos">1953</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator-1954"><a href="#Generator-1954"><span class="linenos">1954</span></a> -</span><span id="Generator-1955"><a href="#Generator-1955"><span class="linenos">1955</span></a> <span class="c1"># We use LIMIT_IS_TOP as a proxy for whether DISTINCT should go first because tsql and Teradata</span> -</span><span id="Generator-1956"><a href="#Generator-1956"><span class="linenos">1956</span></a> <span class="c1"># are the only dialects that use LIMIT_IS_TOP and both place DISTINCT first.</span> -</span><span id="Generator-1957"><a href="#Generator-1957"><span class="linenos">1957</span></a> <span class="n">top_distinct</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">distinct</span><span class="si">}{</span><span class="n">hint</span><span class="si">}{</span><span class="n">top</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">LIMIT_IS_TOP</span> <span class="k">else</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">top</span><span class="si">}{</span><span class="n">hint</span><span class="si">}{</span><span class="n">distinct</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1958"><a href="#Generator-1958"><span class="linenos">1958</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="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</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="n">expressions</span> -</span><span id="Generator-1959"><a href="#Generator-1959"><span class="linenos">1959</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">query_modifiers</span><span class="p">(</span> -</span><span id="Generator-1960"><a href="#Generator-1960"><span class="linenos">1960</span></a> <span class="n">expression</span><span class="p">,</span> -</span><span id="Generator-1961"><a href="#Generator-1961"><span class="linenos">1961</span></a> <span class="sa">f</span><span class="s2">"SELECT</span><span class="si">{</span><span class="n">top_distinct</span><span class="si">}{</span><span class="n">kind</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> -</span><span id="Generator-1962"><a href="#Generator-1962"><span class="linenos">1962</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">"into"</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-1963"><a href="#Generator-1963"><span class="linenos">1963</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">"from"</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-1964"><a href="#Generator-1964"><span class="linenos">1964</span></a> <span class="p">)</span> -</span><span id="Generator-1965"><a href="#Generator-1965"><span class="linenos">1965</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-1966"><a href="#Generator-1966"><span class="linenos">1966</span></a> -</span><span id="Generator-1967"><a href="#Generator-1967"><span class="linenos">1967</span></a> <span class="k">def</span> <span class="nf">schema_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Schema</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1968"><a href="#Generator-1968"><span class="linenos">1968</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-1969"><a href="#Generator-1969"><span class="linenos">1969</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">schema_columns_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Generator-1970"><a href="#Generator-1970"><span class="linenos">1970</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">sql</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="ow">and</span> <span class="n">sql</span> <span class="k">else</span> <span class="n">this</span> <span class="ow">or</span> <span class="n">sql</span> +</span><span id="Generator-1920"><a href="#Generator-1920"><span class="linenos">1920</span></a> <span class="k">def</span> <span class="nf">after_limit_modifiers</span><span class="p">(</span><span class="bp">self</span><span 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">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> +</span><span id="Generator-1921"><a href="#Generator-1921"><span class="linenos">1921</span></a> <span class="n">locks</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">"locks"</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-1922"><a href="#Generator-1922"><span class="linenos">1922</span></a> <span class="n">locks</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">locks</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">locks</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1923"><a href="#Generator-1923"><span class="linenos">1923</span></a> <span class="k">return</span> <span class="p">[</span><span class="n">locks</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">"sample"</span><span class="p">)]</span> +</span><span id="Generator-1924"><a href="#Generator-1924"><span class="linenos">1924</span></a> +</span><span id="Generator-1925"><a href="#Generator-1925"><span class="linenos">1925</span></a> <span class="k">def</span> <span class="nf">select_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1926"><a href="#Generator-1926"><span class="linenos">1926</span></a> <span class="n">hint</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"hint"</span><span class="p">)</span> +</span><span id="Generator-1927"><a href="#Generator-1927"><span class="linenos">1927</span></a> <span class="n">distinct</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"distinct"</span><span class="p">)</span> +</span><span id="Generator-1928"><a href="#Generator-1928"><span class="linenos">1928</span></a> <span class="n">distinct</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">distinct</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">distinct</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1929"><a href="#Generator-1929"><span class="linenos">1929</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 class="o">.</span><span class="n">upper</span><span class="p">()</span> +</span><span id="Generator-1930"><a href="#Generator-1930"><span class="linenos">1930</span></a> <span class="n">limit</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">"limit"</span><span class="p">)</span> +</span><span id="Generator-1931"><a href="#Generator-1931"><span class="linenos">1931</span></a> <span class="n">top</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Generator-1932"><a href="#Generator-1932"><span class="linenos">1932</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">limit_sql</span><span class="p">(</span><span class="n">limit</span><span class="p">,</span> <span class="n">top</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator-1933"><a href="#Generator-1933"><span class="linenos">1933</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">limit</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">LIMIT_IS_TOP</span> +</span><span id="Generator-1934"><a href="#Generator-1934"><span class="linenos">1934</span></a> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1935"><a href="#Generator-1935"><span class="linenos">1935</span></a> <span class="p">)</span> +</span><span id="Generator-1936"><a href="#Generator-1936"><span class="linenos">1936</span></a> +</span><span id="Generator-1937"><a href="#Generator-1937"><span class="linenos">1937</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-1938"><a href="#Generator-1938"><span class="linenos">1938</span></a> +</span><span id="Generator-1939"><a href="#Generator-1939"><span class="linenos">1939</span></a> <span class="k">if</span> <span class="n">kind</span><span class="p">:</span> +</span><span id="Generator-1940"><a href="#Generator-1940"><span class="linenos">1940</span></a> <span class="k">if</span> <span class="n">kind</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">SELECT_KINDS</span><span class="p">:</span> +</span><span id="Generator-1941"><a href="#Generator-1941"><span class="linenos">1941</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1942"><a href="#Generator-1942"><span class="linenos">1942</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator-1943"><a href="#Generator-1943"><span class="linenos">1943</span></a> <span class="k">if</span> <span class="n">kind</span> <span class="o">==</span> <span class="s2">"STRUCT"</span><span class="p">:</span> +</span><span id="Generator-1944"><a href="#Generator-1944"><span class="linenos">1944</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><span id="Generator-1945"><a href="#Generator-1945"><span class="linenos">1945</span></a> <span class="n">sqls</span><span class="o">=</span><span class="p">[</span> +</span><span id="Generator-1946"><a href="#Generator-1946"><span class="linenos">1946</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span> +</span><span id="Generator-1947"><a href="#Generator-1947"><span class="linenos">1947</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Struct</span><span class="p">(</span> +</span><span id="Generator-1948"><a href="#Generator-1948"><span class="linenos">1948</span></a> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span> +</span><span id="Generator-1949"><a href="#Generator-1949"><span class="linenos">1949</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">column</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">output_name</span><span class="p">)</span><span class="o">.</span><span class="n">eq</span><span class="p">(</span> +</span><span id="Generator-1950"><a href="#Generator-1950"><span class="linenos">1950</span></a> <span class="n">e</span><span class="o">.</span><span class="n">this</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">Alias</span><span class="p">)</span> <span class="k">else</span> <span class="n">e</span> +</span><span id="Generator-1951"><a href="#Generator-1951"><span class="linenos">1951</span></a> <span class="p">)</span> +</span><span id="Generator-1952"><a href="#Generator-1952"><span class="linenos">1952</span></a> <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">expressions</span> +</span><span id="Generator-1953"><a href="#Generator-1953"><span class="linenos">1953</span></a> <span class="p">]</span> +</span><span id="Generator-1954"><a href="#Generator-1954"><span class="linenos">1954</span></a> <span class="p">)</span> +</span><span id="Generator-1955"><a href="#Generator-1955"><span class="linenos">1955</span></a> <span class="p">)</span> +</span><span id="Generator-1956"><a href="#Generator-1956"><span class="linenos">1956</span></a> <span class="p">]</span> +</span><span id="Generator-1957"><a href="#Generator-1957"><span class="linenos">1957</span></a> <span class="p">)</span> +</span><span id="Generator-1958"><a href="#Generator-1958"><span class="linenos">1958</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator-1959"><a href="#Generator-1959"><span class="linenos">1959</span></a> +</span><span id="Generator-1960"><a href="#Generator-1960"><span class="linenos">1960</span></a> <span class="c1"># We use LIMIT_IS_TOP as a proxy for whether DISTINCT should go first because tsql and Teradata</span> +</span><span id="Generator-1961"><a href="#Generator-1961"><span class="linenos">1961</span></a> <span class="c1"># are the only dialects that use LIMIT_IS_TOP and both place DISTINCT first.</span> +</span><span id="Generator-1962"><a href="#Generator-1962"><span class="linenos">1962</span></a> <span class="n">top_distinct</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">distinct</span><span class="si">}{</span><span class="n">hint</span><span class="si">}{</span><span class="n">top</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">LIMIT_IS_TOP</span> <span class="k">else</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">top</span><span class="si">}{</span><span class="n">hint</span><span class="si">}{</span><span class="n">distinct</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1963"><a href="#Generator-1963"><span class="linenos">1963</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="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</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="n">expressions</span> +</span><span id="Generator-1964"><a href="#Generator-1964"><span class="linenos">1964</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">query_modifiers</span><span class="p">(</span> +</span><span id="Generator-1965"><a href="#Generator-1965"><span class="linenos">1965</span></a> <span class="n">expression</span><span class="p">,</span> +</span><span id="Generator-1966"><a href="#Generator-1966"><span class="linenos">1966</span></a> <span class="sa">f</span><span class="s2">"SELECT</span><span class="si">{</span><span class="n">top_distinct</span><span class="si">}{</span><span class="n">kind</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> +</span><span id="Generator-1967"><a href="#Generator-1967"><span class="linenos">1967</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">"into"</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-1968"><a href="#Generator-1968"><span class="linenos">1968</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">"from"</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-1969"><a href="#Generator-1969"><span class="linenos">1969</span></a> <span class="p">)</span> +</span><span id="Generator-1970"><a href="#Generator-1970"><span class="linenos">1970</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-1971"><a href="#Generator-1971"><span class="linenos">1971</span></a> -</span><span id="Generator-1972"><a href="#Generator-1972"><span class="linenos">1972</span></a> <span class="k">def</span> <span class="nf">schema_columns_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Schema</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1973"><a href="#Generator-1973"><span class="linenos">1973</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> -</span><span id="Generator-1974"><a href="#Generator-1974"><span class="linenos">1974</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">sep</span><span class="p">(</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">expressions</span><span class="p">(</span><span class="n">expression</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-1975"><a href="#Generator-1975"><span class="linenos">1975</span></a> <span class="k">return</span> <span class="s2">""</span> +</span><span id="Generator-1972"><a href="#Generator-1972"><span class="linenos">1972</span></a> <span class="k">def</span> <span class="nf">schema_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Schema</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1973"><a href="#Generator-1973"><span class="linenos">1973</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-1974"><a href="#Generator-1974"><span class="linenos">1974</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">schema_columns_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Generator-1975"><a href="#Generator-1975"><span class="linenos">1975</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">sql</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="ow">and</span> <span class="n">sql</span> <span class="k">else</span> <span class="n">this</span> <span class="ow">or</span> <span class="n">sql</span> </span><span id="Generator-1976"><a href="#Generator-1976"><span class="linenos">1976</span></a> -</span><span id="Generator-1977"><a href="#Generator-1977"><span class="linenos">1977</span></a> <span class="k">def</span> <span class="nf">star_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Star</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1978"><a href="#Generator-1978"><span class="linenos">1978</span></a> <span class="n">except_</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">"except"</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-1979"><a href="#Generator-1979"><span class="linenos">1979</span></a> <span class="n">except_</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">seg</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">STAR_MAPPING</span><span class="p">[</span><span class="s1">'except'</span><span class="p">])</span><span class="si">}</span><span class="s2"> (</span><span class="si">{</span><span class="n">except_</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">except_</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1980"><a href="#Generator-1980"><span class="linenos">1980</span></a> <span class="n">replace</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">"replace"</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-1981"><a href="#Generator-1981"><span class="linenos">1981</span></a> <span class="n">replace</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">seg</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">STAR_MAPPING</span><span class="p">[</span><span class="s1">'replace'</span><span class="p">])</span><span class="si">}</span><span class="s2"> (</span><span class="si">{</span><span class="n">replace</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">replace</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1982"><a href="#Generator-1982"><span class="linenos">1982</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"*</span><span class="si">{</span><span class="n">except_</span><span class="si">}{</span><span class="n">replace</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1983"><a href="#Generator-1983"><span class="linenos">1983</span></a> -</span><span id="Generator-1984"><a href="#Generator-1984"><span class="linenos">1984</span></a> <span class="k">def</span> <span class="nf">parameter_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Parameter</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1985"><a href="#Generator-1985"><span class="linenos">1985</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-1986"><a href="#Generator-1986"><span class="linenos">1986</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">PARAMETER_TOKEN</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1987"><a href="#Generator-1987"><span class="linenos">1987</span></a> -</span><span id="Generator-1988"><a href="#Generator-1988"><span class="linenos">1988</span></a> <span class="k">def</span> <span class="nf">sessionparameter_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SessionParameter</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1989"><a href="#Generator-1989"><span class="linenos">1989</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-1990"><a href="#Generator-1990"><span class="linenos">1990</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">)</span> -</span><span id="Generator-1991"><a href="#Generator-1991"><span class="linenos">1991</span></a> <span class="k">if</span> <span class="n">kind</span><span class="p">:</span> -</span><span id="Generator-1992"><a href="#Generator-1992"><span class="linenos">1992</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><span id="Generator-1993"><a href="#Generator-1993"><span class="linenos">1993</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="s2">"</span> -</span><span id="Generator-1994"><a href="#Generator-1994"><span class="linenos">1994</span></a> -</span><span id="Generator-1995"><a href="#Generator-1995"><span class="linenos">1995</span></a> <span class="k">def</span> <span class="nf">placeholder_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Placeholder</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1996"><a href="#Generator-1996"><span class="linenos">1996</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">name</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">name</span> <span class="k">else</span> <span class="s2">"?"</span> -</span><span id="Generator-1997"><a href="#Generator-1997"><span class="linenos">1997</span></a> -</span><span id="Generator-1998"><a href="#Generator-1998"><span class="linenos">1998</span></a> <span class="k">def</span> <span class="nf">subquery_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</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="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">" AS "</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1999"><a href="#Generator-1999"><span class="linenos">1999</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-2000"><a href="#Generator-2000"><span class="linenos">2000</span></a> <span class="n">alias</span> <span class="o">=</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">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-2001"><a href="#Generator-2001"><span class="linenos">2001</span></a> -</span><span id="Generator-2002"><a href="#Generator-2002"><span class="linenos">2002</span></a> <span class="n">pivots</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">"pivots"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</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-2003"><a href="#Generator-2003"><span class="linenos">2003</span></a> <span class="n">pivots</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">pivots</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">pivots</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-2004"><a href="#Generator-2004"><span class="linenos">2004</span></a> -</span><span id="Generator-2005"><a href="#Generator-2005"><span class="linenos">2005</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">query_modifiers</span><span class="p">(</span><span class="n">expression</span><span class="p">,</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 class="n">alias</span><span class="p">,</span> <span class="n">pivots</span><span class="p">)</span> -</span><span id="Generator-2006"><a href="#Generator-2006"><span class="linenos">2006</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-2007"><a href="#Generator-2007"><span class="linenos">2007</span></a> -</span><span id="Generator-2008"><a href="#Generator-2008"><span class="linenos">2008</span></a> <span class="k">def</span> <span class="nf">qualify_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Qualify</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2009"><a href="#Generator-2009"><span class="linenos">2009</span></a> <span class="n">this</span> <span class="o">=</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><span id="Generator-2010"><a href="#Generator-2010"><span class="linenos">2010</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="s1">'QUALIFY'</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="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2011"><a href="#Generator-2011"><span class="linenos">2011</span></a> -</span><span id="Generator-2012"><a href="#Generator-2012"><span class="linenos">2012</span></a> <span class="k">def</span> <span class="nf">union_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Union</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2013"><a href="#Generator-2013"><span class="linenos">2013</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><span id="Generator-2014"><a href="#Generator-2014"><span class="linenos">2014</span></a> <span class="n">expression</span><span class="p">,</span> -</span><span id="Generator-2015"><a href="#Generator-2015"><span class="linenos">2015</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">set_operation</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">union_op</span><span class="p">(</span><span class="n">expression</span><span class="p">)),</span> -</span><span id="Generator-2016"><a href="#Generator-2016"><span class="linenos">2016</span></a> <span class="p">)</span> -</span><span id="Generator-2017"><a href="#Generator-2017"><span class="linenos">2017</span></a> -</span><span id="Generator-2018"><a href="#Generator-2018"><span class="linenos">2018</span></a> <span class="k">def</span> <span class="nf">union_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Union</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2019"><a href="#Generator-2019"><span class="linenos">2019</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="s2">" DISTINCT"</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">EXPLICIT_UNION</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-2020"><a href="#Generator-2020"><span class="linenos">2020</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">kind</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">"distinct"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">" ALL"</span> -</span><span id="Generator-2021"><a href="#Generator-2021"><span class="linenos">2021</span></a> <span class="n">by_name</span> <span class="o">=</span> <span class="s2">" BY NAME"</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">"by_name"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-2022"><a href="#Generator-2022"><span class="linenos">2022</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"UNION</span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">by_name</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2023"><a href="#Generator-2023"><span class="linenos">2023</span></a> -</span><span id="Generator-2024"><a href="#Generator-2024"><span class="linenos">2024</span></a> <span class="k">def</span> <span class="nf">unnest_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</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-2025"><a href="#Generator-2025"><span class="linenos">2025</span></a> <span class="n">args</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-2026"><a href="#Generator-2026"><span class="linenos">2026</span></a> -</span><span id="Generator-2027"><a href="#Generator-2027"><span class="linenos">2027</span></a> <span class="n">alias</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">"alias"</span><span class="p">)</span> -</span><span id="Generator-2028"><a href="#Generator-2028"><span class="linenos">2028</span></a> <span class="n">offset</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">"offset"</span><span class="p">)</span> -</span><span id="Generator-2029"><a href="#Generator-2029"><span class="linenos">2029</span></a> -</span><span id="Generator-2030"><a href="#Generator-2030"><span class="linenos">2030</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">UNNEST_WITH_ORDINALITY</span><span class="p">:</span> -</span><span id="Generator-2031"><a href="#Generator-2031"><span class="linenos">2031</span></a> <span class="k">if</span> <span class="n">alias</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">offset</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="Generator-2032"><a href="#Generator-2032"><span class="linenos">2032</span></a> <span class="n">alias</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"columns"</span><span class="p">,</span> <span class="n">offset</span><span class="p">)</span> -</span><span id="Generator-2033"><a href="#Generator-2033"><span class="linenos">2033</span></a> -</span><span id="Generator-2034"><a href="#Generator-2034"><span class="linenos">2034</span></a> <span class="k">if</span> <span class="n">alias</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">UNNEST_COLUMN_ONLY</span><span class="p">:</span> -</span><span id="Generator-2035"><a href="#Generator-2035"><span class="linenos">2035</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="n">alias</span><span class="o">.</span><span class="n">columns</span> -</span><span id="Generator-2036"><a href="#Generator-2036"><span class="linenos">2036</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">columns</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="k">if</span> <span class="n">columns</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-2037"><a href="#Generator-2037"><span class="linenos">2037</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator-2038"><a href="#Generator-2038"><span class="linenos">2038</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">alias</span><span class="p">)</span> -</span><span id="Generator-2039"><a href="#Generator-2039"><span class="linenos">2039</span></a> -</span><span id="Generator-2040"><a href="#Generator-2040"><span class="linenos">2040</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="n">alias</span> -</span><span id="Generator-2041"><a href="#Generator-2041"><span class="linenos">2041</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">UNNEST_WITH_ORDINALITY</span><span class="p">:</span> -</span><span id="Generator-2042"><a href="#Generator-2042"><span class="linenos">2042</span></a> <span class="n">suffix</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" WITH ORDINALITY</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">offset</span> <span class="k">else</span> <span class="n">alias</span> -</span><span id="Generator-2043"><a href="#Generator-2043"><span class="linenos">2043</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator-2044"><a href="#Generator-2044"><span class="linenos">2044</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">offset</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="Generator-2045"><a href="#Generator-2045"><span class="linenos">2045</span></a> <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">alias</span><span class="si">}</span><span class="s2"> WITH OFFSET 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">offset</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2046"><a href="#Generator-2046"><span class="linenos">2046</span></a> <span class="k">elif</span> <span class="n">offset</span><span class="p">:</span> -</span><span id="Generator-2047"><a href="#Generator-2047"><span class="linenos">2047</span></a> <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">alias</span><span class="si">}</span><span class="s2"> WITH OFFSET"</span> -</span><span id="Generator-2048"><a href="#Generator-2048"><span class="linenos">2048</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator-2049"><a href="#Generator-2049"><span class="linenos">2049</span></a> <span class="n">suffix</span> <span class="o">=</span> <span class="n">alias</span> -</span><span id="Generator-2050"><a href="#Generator-2050"><span class="linenos">2050</span></a> -</span><span id="Generator-2051"><a href="#Generator-2051"><span class="linenos">2051</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"UNNEST(</span><span class="si">{</span><span class="n">args</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="n">suffix</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2052"><a href="#Generator-2052"><span class="linenos">2052</span></a> -</span><span id="Generator-2053"><a href="#Generator-2053"><span class="linenos">2053</span></a> <span class="k">def</span> <span class="nf">where_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Where</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2054"><a href="#Generator-2054"><span class="linenos">2054</span></a> <span class="n">this</span> <span class="o">=</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><span id="Generator-2055"><a href="#Generator-2055"><span class="linenos">2055</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="s1">'WHERE'</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="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2056"><a href="#Generator-2056"><span class="linenos">2056</span></a> -</span><span id="Generator-2057"><a href="#Generator-2057"><span class="linenos">2057</span></a> <span class="k">def</span> <span class="nf">window_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Window</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2058"><a href="#Generator-2058"><span class="linenos">2058</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-2059"><a href="#Generator-2059"><span class="linenos">2059</span></a> <span class="n">partition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">partition_by_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Generator-2060"><a href="#Generator-2060"><span class="linenos">2060</span></a> <span class="n">order</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">"order"</span><span class="p">)</span> -</span><span id="Generator-2061"><a href="#Generator-2061"><span class="linenos">2061</span></a> <span class="n">order</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">order_sql</span><span class="p">(</span><span class="n">order</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="k">if</span> <span class="n">order</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-2062"><a href="#Generator-2062"><span class="linenos">2062</span></a> <span class="n">spec</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"spec"</span><span class="p">)</span> -</span><span id="Generator-2063"><a href="#Generator-2063"><span class="linenos">2063</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-2064"><a href="#Generator-2064"><span class="linenos">2064</span></a> <span class="n">over</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"over"</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">"OVER"</span> -</span><span id="Generator-2065"><a href="#Generator-2065"><span class="linenos">2065</span></a> -</span><span id="Generator-2066"><a href="#Generator-2066"><span class="linenos">2066</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="si">{</span><span class="s1">'AS'</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">arg_key</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="s1">'windows'</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="n">over</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2067"><a href="#Generator-2067"><span class="linenos">2067</span></a> -</span><span id="Generator-2068"><a href="#Generator-2068"><span class="linenos">2068</span></a> <span class="n">first</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">"first"</span><span class="p">)</span> -</span><span id="Generator-2069"><a href="#Generator-2069"><span class="linenos">2069</span></a> <span class="k">if</span> <span class="n">first</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Generator-2070"><a href="#Generator-2070"><span class="linenos">2070</span></a> <span class="n">first</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator-2071"><a href="#Generator-2071"><span class="linenos">2071</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator-2072"><a href="#Generator-2072"><span class="linenos">2072</span></a> <span class="n">first</span> <span class="o">=</span> <span class="s2">"FIRST"</span> <span class="k">if</span> <span class="n">first</span> <span class="k">else</span> <span class="s2">"LAST"</span> -</span><span id="Generator-2073"><a href="#Generator-2073"><span class="linenos">2073</span></a> -</span><span id="Generator-2074"><a href="#Generator-2074"><span class="linenos">2074</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">partition</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">order</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">spec</span> <span class="ow">and</span> <span class="n">alias</span><span class="p">:</span> -</span><span id="Generator-2075"><a href="#Generator-2075"><span class="linenos">2075</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">alias</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2076"><a href="#Generator-2076"><span class="linenos">2076</span></a> -</span><span id="Generator-2077"><a href="#Generator-2077"><span class="linenos">2077</span></a> <span class="n">args</span> <span class="o">=</span> <span class="s2">" "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">arg</span> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="p">(</span><span class="n">alias</span><span class="p">,</span> <span class="n">first</span><span class="p">,</span> <span class="n">partition</span><span class="p">,</span> <span class="n">order</span><span class="p">,</span> <span class="n">spec</span><span class="p">)</span> <span class="k">if</span> <span class="n">arg</span><span class="p">)</span> -</span><span id="Generator-2078"><a href="#Generator-2078"><span class="linenos">2078</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">args</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="Generator-2079"><a href="#Generator-2079"><span class="linenos">2079</span></a> -</span><span id="Generator-2080"><a href="#Generator-2080"><span class="linenos">2080</span></a> <span class="k">def</span> <span class="nf">partition_by_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Window</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">MatchRecognize</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2081"><a href="#Generator-2081"><span class="linenos">2081</span></a> <span class="n">partition</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">"partition_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-2082"><a href="#Generator-2082"><span class="linenos">2082</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PARTITION BY </span><span class="si">{</span><span class="n">partition</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">partition</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-2083"><a href="#Generator-2083"><span class="linenos">2083</span></a> -</span><span id="Generator-2084"><a href="#Generator-2084"><span class="linenos">2084</span></a> <span class="k">def</span> <span class="nf">windowspec_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">WindowSpec</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2085"><a href="#Generator-2085"><span class="linenos">2085</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-2086"><a href="#Generator-2086"><span class="linenos">2086</span></a> <span class="n">start</span> <span class="o">=</span> <span class="n">csv</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">"start"</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">"start_side"</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-2087"><a href="#Generator-2087"><span class="linenos">2087</span></a> <span class="n">end</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Generator-2088"><a href="#Generator-2088"><span class="linenos">2088</span></a> <span class="n">csv</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">"end"</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">"end_side"</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-2089"><a href="#Generator-2089"><span class="linenos">2089</span></a> <span class="ow">or</span> <span class="s2">"CURRENT ROW"</span> -</span><span id="Generator-2090"><a href="#Generator-2090"><span class="linenos">2090</span></a> <span class="p">)</span> -</span><span id="Generator-2091"><a href="#Generator-2091"><span class="linenos">2091</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="s2"> BETWEEN </span><span class="si">{</span><span class="n">start</span><span class="si">}</span><span class="s2"> AND </span><span class="si">{</span><span class="n">end</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2092"><a href="#Generator-2092"><span class="linenos">2092</span></a> -</span><span id="Generator-2093"><a href="#Generator-2093"><span class="linenos">2093</span></a> <span class="k">def</span> <span class="nf">withingroup_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">WithinGroup</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2094"><a href="#Generator-2094"><span class="linenos">2094</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-2095"><a href="#Generator-2095"><span class="linenos">2095</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 class="mi">1</span><span class="p">:]</span> <span class="c1"># order has a leading space</span> -</span><span id="Generator-2096"><a href="#Generator-2096"><span class="linenos">2096</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"> WITHIN GROUP (</span><span class="si">{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Generator-1977"><a href="#Generator-1977"><span class="linenos">1977</span></a> <span class="k">def</span> <span class="nf">schema_columns_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Schema</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1978"><a href="#Generator-1978"><span class="linenos">1978</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> +</span><span id="Generator-1979"><a href="#Generator-1979"><span class="linenos">1979</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">sep</span><span class="p">(</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">expressions</span><span class="p">(</span><span class="n">expression</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-1980"><a href="#Generator-1980"><span class="linenos">1980</span></a> <span class="k">return</span> <span class="s2">""</span> +</span><span id="Generator-1981"><a href="#Generator-1981"><span class="linenos">1981</span></a> +</span><span id="Generator-1982"><a href="#Generator-1982"><span class="linenos">1982</span></a> <span class="k">def</span> <span class="nf">star_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Star</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1983"><a href="#Generator-1983"><span class="linenos">1983</span></a> <span class="n">except_</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">"except"</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-1984"><a href="#Generator-1984"><span class="linenos">1984</span></a> <span class="n">except_</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">seg</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">STAR_MAPPING</span><span class="p">[</span><span class="s1">'except'</span><span class="p">])</span><span class="si">}</span><span class="s2"> (</span><span class="si">{</span><span class="n">except_</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">except_</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1985"><a href="#Generator-1985"><span class="linenos">1985</span></a> <span class="n">replace</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">"replace"</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-1986"><a href="#Generator-1986"><span class="linenos">1986</span></a> <span class="n">replace</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">seg</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">STAR_MAPPING</span><span class="p">[</span><span class="s1">'replace'</span><span class="p">])</span><span class="si">}</span><span class="s2"> (</span><span class="si">{</span><span class="n">replace</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">replace</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1987"><a href="#Generator-1987"><span class="linenos">1987</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"*</span><span class="si">{</span><span class="n">except_</span><span class="si">}{</span><span class="n">replace</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1988"><a href="#Generator-1988"><span class="linenos">1988</span></a> +</span><span id="Generator-1989"><a href="#Generator-1989"><span class="linenos">1989</span></a> <span class="k">def</span> <span class="nf">parameter_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Parameter</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1990"><a href="#Generator-1990"><span class="linenos">1990</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-1991"><a href="#Generator-1991"><span class="linenos">1991</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">PARAMETER_TOKEN</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1992"><a href="#Generator-1992"><span class="linenos">1992</span></a> +</span><span id="Generator-1993"><a href="#Generator-1993"><span class="linenos">1993</span></a> <span class="k">def</span> <span class="nf">sessionparameter_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SessionParameter</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1994"><a href="#Generator-1994"><span class="linenos">1994</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-1995"><a href="#Generator-1995"><span class="linenos">1995</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">)</span> +</span><span id="Generator-1996"><a href="#Generator-1996"><span class="linenos">1996</span></a> <span class="k">if</span> <span class="n">kind</span><span class="p">:</span> +</span><span id="Generator-1997"><a href="#Generator-1997"><span class="linenos">1997</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><span id="Generator-1998"><a href="#Generator-1998"><span class="linenos">1998</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="s2">"</span> +</span><span id="Generator-1999"><a href="#Generator-1999"><span class="linenos">1999</span></a> +</span><span id="Generator-2000"><a href="#Generator-2000"><span class="linenos">2000</span></a> <span class="k">def</span> <span class="nf">placeholder_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Placeholder</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2001"><a href="#Generator-2001"><span class="linenos">2001</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">name</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">name</span> <span class="k">else</span> <span class="s2">"?"</span> +</span><span id="Generator-2002"><a href="#Generator-2002"><span class="linenos">2002</span></a> +</span><span id="Generator-2003"><a href="#Generator-2003"><span class="linenos">2003</span></a> <span class="k">def</span> <span class="nf">subquery_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</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="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">" AS "</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2004"><a href="#Generator-2004"><span class="linenos">2004</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-2005"><a href="#Generator-2005"><span class="linenos">2005</span></a> <span class="n">alias</span> <span class="o">=</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">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-2006"><a href="#Generator-2006"><span class="linenos">2006</span></a> +</span><span id="Generator-2007"><a href="#Generator-2007"><span class="linenos">2007</span></a> <span class="n">pivots</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">"pivots"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</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-2008"><a href="#Generator-2008"><span class="linenos">2008</span></a> <span class="n">pivots</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">pivots</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">pivots</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2009"><a href="#Generator-2009"><span class="linenos">2009</span></a> +</span><span id="Generator-2010"><a href="#Generator-2010"><span class="linenos">2010</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">query_modifiers</span><span class="p">(</span><span class="n">expression</span><span class="p">,</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 class="n">alias</span><span class="p">,</span> <span class="n">pivots</span><span class="p">)</span> +</span><span id="Generator-2011"><a href="#Generator-2011"><span class="linenos">2011</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-2012"><a href="#Generator-2012"><span class="linenos">2012</span></a> +</span><span id="Generator-2013"><a href="#Generator-2013"><span class="linenos">2013</span></a> <span class="k">def</span> <span class="nf">qualify_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Qualify</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2014"><a href="#Generator-2014"><span class="linenos">2014</span></a> <span class="n">this</span> <span class="o">=</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><span id="Generator-2015"><a href="#Generator-2015"><span class="linenos">2015</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="s1">'QUALIFY'</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="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2016"><a href="#Generator-2016"><span class="linenos">2016</span></a> +</span><span id="Generator-2017"><a href="#Generator-2017"><span class="linenos">2017</span></a> <span class="k">def</span> <span class="nf">union_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Union</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2018"><a href="#Generator-2018"><span class="linenos">2018</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><span id="Generator-2019"><a href="#Generator-2019"><span class="linenos">2019</span></a> <span class="n">expression</span><span class="p">,</span> +</span><span id="Generator-2020"><a href="#Generator-2020"><span class="linenos">2020</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">set_operation</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">union_op</span><span class="p">(</span><span class="n">expression</span><span class="p">)),</span> +</span><span id="Generator-2021"><a href="#Generator-2021"><span class="linenos">2021</span></a> <span class="p">)</span> +</span><span id="Generator-2022"><a href="#Generator-2022"><span class="linenos">2022</span></a> +</span><span id="Generator-2023"><a href="#Generator-2023"><span class="linenos">2023</span></a> <span class="k">def</span> <span class="nf">union_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Union</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2024"><a href="#Generator-2024"><span class="linenos">2024</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="s2">" DISTINCT"</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">EXPLICIT_UNION</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2025"><a href="#Generator-2025"><span class="linenos">2025</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">kind</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">"distinct"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">" ALL"</span> +</span><span id="Generator-2026"><a href="#Generator-2026"><span class="linenos">2026</span></a> <span class="n">by_name</span> <span class="o">=</span> <span class="s2">" BY NAME"</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">"by_name"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2027"><a href="#Generator-2027"><span class="linenos">2027</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"UNION</span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">by_name</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2028"><a href="#Generator-2028"><span class="linenos">2028</span></a> +</span><span id="Generator-2029"><a href="#Generator-2029"><span class="linenos">2029</span></a> <span class="k">def</span> <span class="nf">unnest_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</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-2030"><a href="#Generator-2030"><span class="linenos">2030</span></a> <span class="n">args</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-2031"><a href="#Generator-2031"><span class="linenos">2031</span></a> +</span><span id="Generator-2032"><a href="#Generator-2032"><span class="linenos">2032</span></a> <span class="n">alias</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">"alias"</span><span class="p">)</span> +</span><span id="Generator-2033"><a href="#Generator-2033"><span class="linenos">2033</span></a> <span class="n">offset</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">"offset"</span><span class="p">)</span> +</span><span id="Generator-2034"><a href="#Generator-2034"><span class="linenos">2034</span></a> +</span><span id="Generator-2035"><a href="#Generator-2035"><span class="linenos">2035</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">UNNEST_WITH_ORDINALITY</span><span class="p">:</span> +</span><span id="Generator-2036"><a href="#Generator-2036"><span class="linenos">2036</span></a> <span class="k">if</span> <span class="n">alias</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">offset</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="Generator-2037"><a href="#Generator-2037"><span class="linenos">2037</span></a> <span class="n">alias</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"columns"</span><span class="p">,</span> <span class="n">offset</span><span class="p">)</span> +</span><span id="Generator-2038"><a href="#Generator-2038"><span class="linenos">2038</span></a> +</span><span id="Generator-2039"><a href="#Generator-2039"><span class="linenos">2039</span></a> <span class="k">if</span> <span class="n">alias</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">UNNEST_COLUMN_ONLY</span><span class="p">:</span> +</span><span id="Generator-2040"><a href="#Generator-2040"><span class="linenos">2040</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="n">alias</span><span class="o">.</span><span class="n">columns</span> +</span><span id="Generator-2041"><a href="#Generator-2041"><span class="linenos">2041</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">columns</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="k">if</span> <span class="n">columns</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2042"><a href="#Generator-2042"><span class="linenos">2042</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator-2043"><a href="#Generator-2043"><span class="linenos">2043</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">alias</span><span class="p">)</span> +</span><span id="Generator-2044"><a href="#Generator-2044"><span class="linenos">2044</span></a> +</span><span id="Generator-2045"><a href="#Generator-2045"><span class="linenos">2045</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="n">alias</span> +</span><span id="Generator-2046"><a href="#Generator-2046"><span class="linenos">2046</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">UNNEST_WITH_ORDINALITY</span><span class="p">:</span> +</span><span id="Generator-2047"><a href="#Generator-2047"><span class="linenos">2047</span></a> <span class="n">suffix</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" WITH ORDINALITY</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">offset</span> <span class="k">else</span> <span class="n">alias</span> +</span><span id="Generator-2048"><a href="#Generator-2048"><span class="linenos">2048</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator-2049"><a href="#Generator-2049"><span class="linenos">2049</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">offset</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="Generator-2050"><a href="#Generator-2050"><span class="linenos">2050</span></a> <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">alias</span><span class="si">}</span><span class="s2"> WITH OFFSET 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">offset</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2051"><a href="#Generator-2051"><span class="linenos">2051</span></a> <span class="k">elif</span> <span class="n">offset</span><span class="p">:</span> +</span><span id="Generator-2052"><a href="#Generator-2052"><span class="linenos">2052</span></a> <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">alias</span><span class="si">}</span><span class="s2"> WITH OFFSET"</span> +</span><span id="Generator-2053"><a href="#Generator-2053"><span class="linenos">2053</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator-2054"><a href="#Generator-2054"><span class="linenos">2054</span></a> <span class="n">suffix</span> <span class="o">=</span> <span class="n">alias</span> +</span><span id="Generator-2055"><a href="#Generator-2055"><span class="linenos">2055</span></a> +</span><span id="Generator-2056"><a href="#Generator-2056"><span class="linenos">2056</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"UNNEST(</span><span class="si">{</span><span class="n">args</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="n">suffix</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2057"><a href="#Generator-2057"><span class="linenos">2057</span></a> +</span><span id="Generator-2058"><a href="#Generator-2058"><span class="linenos">2058</span></a> <span class="k">def</span> <span class="nf">where_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Where</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2059"><a href="#Generator-2059"><span class="linenos">2059</span></a> <span class="n">this</span> <span class="o">=</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><span id="Generator-2060"><a href="#Generator-2060"><span class="linenos">2060</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="s1">'WHERE'</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="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2061"><a href="#Generator-2061"><span class="linenos">2061</span></a> +</span><span id="Generator-2062"><a href="#Generator-2062"><span class="linenos">2062</span></a> <span class="k">def</span> <span class="nf">window_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Window</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2063"><a href="#Generator-2063"><span class="linenos">2063</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-2064"><a href="#Generator-2064"><span class="linenos">2064</span></a> <span class="n">partition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">partition_by_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Generator-2065"><a href="#Generator-2065"><span class="linenos">2065</span></a> <span class="n">order</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">"order"</span><span class="p">)</span> +</span><span id="Generator-2066"><a href="#Generator-2066"><span class="linenos">2066</span></a> <span class="n">order</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">order_sql</span><span class="p">(</span><span class="n">order</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="k">if</span> <span class="n">order</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2067"><a href="#Generator-2067"><span class="linenos">2067</span></a> <span class="n">spec</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"spec"</span><span class="p">)</span> +</span><span id="Generator-2068"><a href="#Generator-2068"><span class="linenos">2068</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-2069"><a href="#Generator-2069"><span class="linenos">2069</span></a> <span class="n">over</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"over"</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">"OVER"</span> +</span><span id="Generator-2070"><a href="#Generator-2070"><span class="linenos">2070</span></a> +</span><span id="Generator-2071"><a href="#Generator-2071"><span class="linenos">2071</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="si">{</span><span class="s1">'AS'</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">arg_key</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="s1">'windows'</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="n">over</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2072"><a href="#Generator-2072"><span class="linenos">2072</span></a> +</span><span id="Generator-2073"><a href="#Generator-2073"><span class="linenos">2073</span></a> <span class="n">first</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">"first"</span><span class="p">)</span> +</span><span id="Generator-2074"><a href="#Generator-2074"><span class="linenos">2074</span></a> <span class="k">if</span> <span class="n">first</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Generator-2075"><a href="#Generator-2075"><span class="linenos">2075</span></a> <span class="n">first</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator-2076"><a href="#Generator-2076"><span class="linenos">2076</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator-2077"><a href="#Generator-2077"><span class="linenos">2077</span></a> <span class="n">first</span> <span class="o">=</span> <span class="s2">"FIRST"</span> <span class="k">if</span> <span class="n">first</span> <span class="k">else</span> <span class="s2">"LAST"</span> +</span><span id="Generator-2078"><a href="#Generator-2078"><span class="linenos">2078</span></a> +</span><span id="Generator-2079"><a href="#Generator-2079"><span class="linenos">2079</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">partition</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">order</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">spec</span> <span class="ow">and</span> <span class="n">alias</span><span class="p">:</span> +</span><span id="Generator-2080"><a href="#Generator-2080"><span class="linenos">2080</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">alias</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2081"><a href="#Generator-2081"><span class="linenos">2081</span></a> +</span><span id="Generator-2082"><a href="#Generator-2082"><span class="linenos">2082</span></a> <span class="n">args</span> <span class="o">=</span> <span class="s2">" "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">arg</span> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="p">(</span><span class="n">alias</span><span class="p">,</span> <span class="n">first</span><span class="p">,</span> <span class="n">partition</span><span class="p">,</span> <span class="n">order</span><span class="p">,</span> <span class="n">spec</span><span class="p">)</span> <span class="k">if</span> <span class="n">arg</span><span class="p">)</span> +</span><span id="Generator-2083"><a href="#Generator-2083"><span class="linenos">2083</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">args</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Generator-2084"><a href="#Generator-2084"><span class="linenos">2084</span></a> +</span><span id="Generator-2085"><a href="#Generator-2085"><span class="linenos">2085</span></a> <span class="k">def</span> <span class="nf">partition_by_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Window</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">MatchRecognize</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2086"><a href="#Generator-2086"><span class="linenos">2086</span></a> <span class="n">partition</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">"partition_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-2087"><a href="#Generator-2087"><span class="linenos">2087</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PARTITION BY </span><span class="si">{</span><span class="n">partition</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">partition</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2088"><a href="#Generator-2088"><span class="linenos">2088</span></a> +</span><span id="Generator-2089"><a href="#Generator-2089"><span class="linenos">2089</span></a> <span class="k">def</span> <span class="nf">windowspec_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">WindowSpec</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2090"><a href="#Generator-2090"><span class="linenos">2090</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-2091"><a href="#Generator-2091"><span class="linenos">2091</span></a> <span class="n">start</span> <span class="o">=</span> <span class="n">csv</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">"start"</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">"start_side"</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-2092"><a href="#Generator-2092"><span class="linenos">2092</span></a> <span class="n">end</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Generator-2093"><a href="#Generator-2093"><span class="linenos">2093</span></a> <span class="n">csv</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">"end"</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">"end_side"</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-2094"><a href="#Generator-2094"><span class="linenos">2094</span></a> <span class="ow">or</span> <span class="s2">"CURRENT ROW"</span> +</span><span id="Generator-2095"><a href="#Generator-2095"><span class="linenos">2095</span></a> <span class="p">)</span> +</span><span id="Generator-2096"><a href="#Generator-2096"><span class="linenos">2096</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="s2"> BETWEEN </span><span class="si">{</span><span class="n">start</span><span class="si">}</span><span class="s2"> AND </span><span class="si">{</span><span class="n">end</span><span class="si">}</span><span class="s2">"</span> </span><span id="Generator-2097"><a href="#Generator-2097"><span class="linenos">2097</span></a> -</span><span id="Generator-2098"><a href="#Generator-2098"><span class="linenos">2098</span></a> <span class="k">def</span> <span class="nf">between_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Between</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2098"><a href="#Generator-2098"><span class="linenos">2098</span></a> <span class="k">def</span> <span class="nf">withingroup_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">WithinGroup</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> </span><span id="Generator-2099"><a href="#Generator-2099"><span class="linenos">2099</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-2100"><a href="#Generator-2100"><span class="linenos">2100</span></a> <span class="n">low</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"low"</span><span class="p">)</span> -</span><span id="Generator-2101"><a href="#Generator-2101"><span class="linenos">2101</span></a> <span class="n">high</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"high"</span><span class="p">)</span> -</span><span id="Generator-2102"><a href="#Generator-2102"><span class="linenos">2102</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"> BETWEEN </span><span class="si">{</span><span class="n">low</span><span class="si">}</span><span class="s2"> AND </span><span class="si">{</span><span class="n">high</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2103"><a href="#Generator-2103"><span class="linenos">2103</span></a> -</span><span id="Generator-2104"><a href="#Generator-2104"><span class="linenos">2104</span></a> <span class="k">def</span> <span class="nf">bracket_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Bracket</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2105"><a href="#Generator-2105"><span class="linenos">2105</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="n">apply_index_offset</span><span class="p">(</span> -</span><span id="Generator-2106"><a href="#Generator-2106"><span class="linenos">2106</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> -</span><span id="Generator-2107"><a href="#Generator-2107"><span class="linenos">2107</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">,</span> -</span><span id="Generator-2108"><a href="#Generator-2108"><span class="linenos">2108</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">INDEX_OFFSET</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">"offset"</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> -</span><span id="Generator-2109"><a href="#Generator-2109"><span class="linenos">2109</span></a> <span class="p">)</span> -</span><span id="Generator-2110"><a href="#Generator-2110"><span class="linenos">2110</span></a> <span class="n">expressions_sql</span> <span class="o">=</span> <span class="s2">", "</span><span class="o">.</span><span class="n">join</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><span id="Generator-2111"><a href="#Generator-2111"><span class="linenos">2111</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">expressions_sql</span><span class="si">}</span><span class="s2">]"</span> -</span><span id="Generator-2112"><a href="#Generator-2112"><span class="linenos">2112</span></a> -</span><span id="Generator-2113"><a href="#Generator-2113"><span class="linenos">2113</span></a> <span class="k">def</span> <span class="nf">all_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">All</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2114"><a href="#Generator-2114"><span class="linenos">2114</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ALL </span><span class="si">{</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 class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2115"><a href="#Generator-2115"><span class="linenos">2115</span></a> -</span><span id="Generator-2116"><a href="#Generator-2116"><span class="linenos">2116</span></a> <span class="k">def</span> <span class="nf">any_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Any</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2117"><a href="#Generator-2117"><span class="linenos">2117</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-2118"><a href="#Generator-2118"><span class="linenos">2118</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">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Subqueryable</span><span class="p">):</span> -</span><span id="Generator-2119"><a href="#Generator-2119"><span class="linenos">2119</span></a> <span class="n">this</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">this</span><span class="p">)</span> -</span><span id="Generator-2120"><a href="#Generator-2120"><span class="linenos">2120</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ANY </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2121"><a href="#Generator-2121"><span class="linenos">2121</span></a> -</span><span id="Generator-2122"><a href="#Generator-2122"><span class="linenos">2122</span></a> <span class="k">def</span> <span class="nf">exists_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Exists</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2123"><a href="#Generator-2123"><span class="linenos">2123</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"EXISTS</span><span class="si">{</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 class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2124"><a href="#Generator-2124"><span class="linenos">2124</span></a> -</span><span id="Generator-2125"><a href="#Generator-2125"><span class="linenos">2125</span></a> <span class="k">def</span> <span class="nf">case_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</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="nb">str</span><span class="p">:</span> -</span><span id="Generator-2126"><a href="#Generator-2126"><span class="linenos">2126</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-2127"><a href="#Generator-2127"><span class="linenos">2127</span></a> <span class="n">statements</span> <span class="o">=</span> <span class="p">[</span><span class="sa">f</span><span class="s2">"CASE </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">"CASE"</span><span class="p">]</span> -</span><span id="Generator-2128"><a href="#Generator-2128"><span class="linenos">2128</span></a> -</span><span id="Generator-2129"><a href="#Generator-2129"><span class="linenos">2129</span></a> <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">args</span><span class="p">[</span><span class="s2">"ifs"</span><span class="p">]:</span> -</span><span id="Generator-2130"><a href="#Generator-2130"><span class="linenos">2130</span></a> <span class="n">statements</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="sa">f</span><span class="s2">"WHEN </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">e</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="p">)</span> -</span><span id="Generator-2131"><a href="#Generator-2131"><span class="linenos">2131</span></a> <span class="n">statements</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="sa">f</span><span class="s2">"THEN </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">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'true'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="Generator-2132"><a href="#Generator-2132"><span class="linenos">2132</span></a> -</span><span id="Generator-2133"><a href="#Generator-2133"><span class="linenos">2133</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-2134"><a href="#Generator-2134"><span class="linenos">2134</span></a> -</span><span id="Generator-2135"><a href="#Generator-2135"><span class="linenos">2135</span></a> <span class="k">if</span> <span class="n">default</span><span class="p">:</span> -</span><span id="Generator-2136"><a href="#Generator-2136"><span class="linenos">2136</span></a> <span class="n">statements</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="sa">f</span><span class="s2">"ELSE </span><span class="si">{</span><span class="n">default</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="Generator-2100"><a href="#Generator-2100"><span class="linenos">2100</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 class="mi">1</span><span class="p">:]</span> <span class="c1"># order has a leading space</span> +</span><span id="Generator-2101"><a href="#Generator-2101"><span class="linenos">2101</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"> WITHIN GROUP (</span><span class="si">{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Generator-2102"><a href="#Generator-2102"><span class="linenos">2102</span></a> +</span><span id="Generator-2103"><a href="#Generator-2103"><span class="linenos">2103</span></a> <span class="k">def</span> <span class="nf">between_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Between</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2104"><a href="#Generator-2104"><span class="linenos">2104</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-2105"><a href="#Generator-2105"><span class="linenos">2105</span></a> <span class="n">low</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"low"</span><span class="p">)</span> +</span><span id="Generator-2106"><a href="#Generator-2106"><span class="linenos">2106</span></a> <span class="n">high</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"high"</span><span class="p">)</span> +</span><span id="Generator-2107"><a href="#Generator-2107"><span class="linenos">2107</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"> BETWEEN </span><span class="si">{</span><span class="n">low</span><span class="si">}</span><span class="s2"> AND </span><span class="si">{</span><span class="n">high</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2108"><a href="#Generator-2108"><span class="linenos">2108</span></a> +</span><span id="Generator-2109"><a href="#Generator-2109"><span class="linenos">2109</span></a> <span class="k">def</span> <span class="nf">bracket_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Bracket</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2110"><a href="#Generator-2110"><span class="linenos">2110</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="n">apply_index_offset</span><span class="p">(</span> +</span><span id="Generator-2111"><a href="#Generator-2111"><span class="linenos">2111</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> +</span><span id="Generator-2112"><a href="#Generator-2112"><span class="linenos">2112</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">,</span> +</span><span id="Generator-2113"><a href="#Generator-2113"><span class="linenos">2113</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">INDEX_OFFSET</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">"offset"</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> +</span><span id="Generator-2114"><a href="#Generator-2114"><span class="linenos">2114</span></a> <span class="p">)</span> +</span><span id="Generator-2115"><a href="#Generator-2115"><span class="linenos">2115</span></a> <span class="n">expressions_sql</span> <span class="o">=</span> <span class="s2">", "</span><span class="o">.</span><span class="n">join</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><span id="Generator-2116"><a href="#Generator-2116"><span class="linenos">2116</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">expressions_sql</span><span class="si">}</span><span class="s2">]"</span> +</span><span id="Generator-2117"><a href="#Generator-2117"><span class="linenos">2117</span></a> +</span><span id="Generator-2118"><a href="#Generator-2118"><span class="linenos">2118</span></a> <span class="k">def</span> <span class="nf">all_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">All</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2119"><a href="#Generator-2119"><span class="linenos">2119</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ALL </span><span class="si">{</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 class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2120"><a href="#Generator-2120"><span class="linenos">2120</span></a> +</span><span id="Generator-2121"><a href="#Generator-2121"><span class="linenos">2121</span></a> <span class="k">def</span> <span class="nf">any_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Any</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2122"><a href="#Generator-2122"><span class="linenos">2122</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-2123"><a href="#Generator-2123"><span class="linenos">2123</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">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Subqueryable</span><span class="p">):</span> +</span><span id="Generator-2124"><a href="#Generator-2124"><span class="linenos">2124</span></a> <span class="n">this</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">this</span><span class="p">)</span> +</span><span id="Generator-2125"><a href="#Generator-2125"><span class="linenos">2125</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ANY </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2126"><a href="#Generator-2126"><span class="linenos">2126</span></a> +</span><span id="Generator-2127"><a href="#Generator-2127"><span class="linenos">2127</span></a> <span class="k">def</span> <span class="nf">exists_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Exists</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2128"><a href="#Generator-2128"><span class="linenos">2128</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"EXISTS</span><span class="si">{</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 class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2129"><a href="#Generator-2129"><span class="linenos">2129</span></a> +</span><span id="Generator-2130"><a href="#Generator-2130"><span class="linenos">2130</span></a> <span class="k">def</span> <span class="nf">case_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</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="nb">str</span><span class="p">:</span> +</span><span id="Generator-2131"><a href="#Generator-2131"><span class="linenos">2131</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-2132"><a href="#Generator-2132"><span class="linenos">2132</span></a> <span class="n">statements</span> <span class="o">=</span> <span class="p">[</span><span class="sa">f</span><span class="s2">"CASE </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">"CASE"</span><span class="p">]</span> +</span><span id="Generator-2133"><a href="#Generator-2133"><span class="linenos">2133</span></a> +</span><span id="Generator-2134"><a href="#Generator-2134"><span class="linenos">2134</span></a> <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">args</span><span class="p">[</span><span class="s2">"ifs"</span><span class="p">]:</span> +</span><span id="Generator-2135"><a href="#Generator-2135"><span class="linenos">2135</span></a> <span class="n">statements</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="sa">f</span><span class="s2">"WHEN </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">e</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="p">)</span> +</span><span id="Generator-2136"><a href="#Generator-2136"><span class="linenos">2136</span></a> <span class="n">statements</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="sa">f</span><span class="s2">"THEN </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">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'true'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> </span><span id="Generator-2137"><a href="#Generator-2137"><span class="linenos">2137</span></a> -</span><span id="Generator-2138"><a href="#Generator-2138"><span class="linenos">2138</span></a> <span class="n">statements</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"END"</span><span class="p">)</span> +</span><span id="Generator-2138"><a href="#Generator-2138"><span class="linenos">2138</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-2139"><a href="#Generator-2139"><span class="linenos">2139</span></a> -</span><span id="Generator-2140"><a href="#Generator-2140"><span class="linenos">2140</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">statements</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-2141"><a href="#Generator-2141"><span class="linenos">2141</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="n">join</span><span class="p">(</span><span class="n">statements</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-2140"><a href="#Generator-2140"><span class="linenos">2140</span></a> <span class="k">if</span> <span class="n">default</span><span class="p">:</span> +</span><span id="Generator-2141"><a href="#Generator-2141"><span class="linenos">2141</span></a> <span class="n">statements</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="sa">f</span><span class="s2">"ELSE </span><span class="si">{</span><span class="n">default</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> </span><span id="Generator-2142"><a href="#Generator-2142"><span class="linenos">2142</span></a> -</span><span id="Generator-2143"><a href="#Generator-2143"><span class="linenos">2143</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">statements</span><span class="p">)</span> +</span><span id="Generator-2143"><a href="#Generator-2143"><span class="linenos">2143</span></a> <span class="n">statements</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"END"</span><span class="p">)</span> </span><span id="Generator-2144"><a href="#Generator-2144"><span class="linenos">2144</span></a> -</span><span id="Generator-2145"><a href="#Generator-2145"><span class="linenos">2145</span></a> <span class="k">def</span> <span class="nf">constraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Constraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2146"><a href="#Generator-2146"><span class="linenos">2146</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-2147"><a href="#Generator-2147"><span class="linenos">2147</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-2148"><a href="#Generator-2148"><span class="linenos">2148</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CONSTRAINT </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-2145"><a href="#Generator-2145"><span class="linenos">2145</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">statements</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-2146"><a href="#Generator-2146"><span class="linenos">2146</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="n">join</span><span class="p">(</span><span class="n">statements</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-2147"><a href="#Generator-2147"><span class="linenos">2147</span></a> +</span><span id="Generator-2148"><a href="#Generator-2148"><span class="linenos">2148</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">statements</span><span class="p">)</span> </span><span id="Generator-2149"><a href="#Generator-2149"><span class="linenos">2149</span></a> -</span><span id="Generator-2150"><a href="#Generator-2150"><span class="linenos">2150</span></a> <span class="k">def</span> <span class="nf">nextvaluefor_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">NextValueFor</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2151"><a href="#Generator-2151"><span class="linenos">2151</span></a> <span class="n">order</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">"order"</span><span class="p">)</span> -</span><span id="Generator-2152"><a href="#Generator-2152"><span class="linenos">2152</span></a> <span class="n">order</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" OVER (</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">order_sql</span><span class="p">(</span><span class="n">order</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 class="k">if</span> <span class="n">order</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-2153"><a href="#Generator-2153"><span class="linenos">2153</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"NEXT VALUE FOR </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">order</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2150"><a href="#Generator-2150"><span class="linenos">2150</span></a> <span class="k">def</span> <span class="nf">constraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Constraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2151"><a href="#Generator-2151"><span class="linenos">2151</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-2152"><a href="#Generator-2152"><span class="linenos">2152</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-2153"><a href="#Generator-2153"><span class="linenos">2153</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CONSTRAINT </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-2154"><a href="#Generator-2154"><span class="linenos">2154</span></a> -</span><span id="Generator-2155"><a href="#Generator-2155"><span class="linenos">2155</span></a> <span class="k">def</span> <span class="nf">extract_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Extract</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2156"><a href="#Generator-2156"><span class="linenos">2156</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 class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">EXTRACT_ALLOWS_QUOTES</span> <span class="k">else</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><span id="Generator-2157"><a href="#Generator-2157"><span class="linenos">2157</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-2158"><a href="#Generator-2158"><span class="linenos">2158</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"EXTRACT(</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> FROM </span><span class="si">{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Generator-2155"><a href="#Generator-2155"><span class="linenos">2155</span></a> <span class="k">def</span> <span class="nf">nextvaluefor_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">NextValueFor</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2156"><a href="#Generator-2156"><span class="linenos">2156</span></a> <span class="n">order</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">"order"</span><span class="p">)</span> +</span><span id="Generator-2157"><a href="#Generator-2157"><span class="linenos">2157</span></a> <span class="n">order</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" OVER (</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">order_sql</span><span class="p">(</span><span class="n">order</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 class="k">if</span> <span class="n">order</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2158"><a href="#Generator-2158"><span class="linenos">2158</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"NEXT VALUE FOR </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">order</span><span class="si">}</span><span class="s2">"</span> </span><span id="Generator-2159"><a href="#Generator-2159"><span class="linenos">2159</span></a> -</span><span id="Generator-2160"><a href="#Generator-2160"><span class="linenos">2160</span></a> <span class="k">def</span> <span class="nf">trim_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Trim</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2161"><a href="#Generator-2161"><span class="linenos">2161</span></a> <span class="n">trim_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">"position"</span><span class="p">)</span> -</span><span id="Generator-2162"><a href="#Generator-2162"><span class="linenos">2162</span></a> -</span><span id="Generator-2163"><a href="#Generator-2163"><span class="linenos">2163</span></a> <span class="k">if</span> <span class="n">trim_type</span> <span class="o">==</span> <span class="s2">"LEADING"</span><span class="p">:</span> -</span><span id="Generator-2164"><a href="#Generator-2164"><span class="linenos">2164</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">"LTRIM"</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-2165"><a href="#Generator-2165"><span class="linenos">2165</span></a> <span class="k">elif</span> <span class="n">trim_type</span> <span class="o">==</span> <span class="s2">"TRAILING"</span><span class="p">:</span> -</span><span id="Generator-2166"><a href="#Generator-2166"><span class="linenos">2166</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">"RTRIM"</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-2167"><a href="#Generator-2167"><span class="linenos">2167</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator-2168"><a href="#Generator-2168"><span class="linenos">2168</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">"TRIM"</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="n">expression</span><span class="o">.</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Generator-2169"><a href="#Generator-2169"><span class="linenos">2169</span></a> -</span><span id="Generator-2170"><a href="#Generator-2170"><span class="linenos">2170</span></a> <span class="k">def</span> <span class="nf">concat_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Concat</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2171"><a href="#Generator-2171"><span class="linenos">2171</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> -</span><span id="Generator-2172"><a href="#Generator-2172"><span class="linenos">2172</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">STRICT_STRING_CONCAT</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">"safe"</span><span class="p">):</span> -</span><span id="Generator-2173"><a href="#Generator-2173"><span class="linenos">2173</span></a> <span class="n">expressions</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">expressions</span><span class="p">]</span> -</span><span id="Generator-2174"><a href="#Generator-2174"><span class="linenos">2174</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="n">expressions</span><span class="p">)</span> -</span><span id="Generator-2175"><a href="#Generator-2175"><span class="linenos">2175</span></a> -</span><span id="Generator-2176"><a href="#Generator-2176"><span class="linenos">2176</span></a> <span class="k">def</span> <span class="nf">check_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Check</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2177"><a href="#Generator-2177"><span class="linenos">2177</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="n">key</span><span class="o">=</span><span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-2178"><a href="#Generator-2178"><span class="linenos">2178</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CHECK (</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Generator-2160"><a href="#Generator-2160"><span class="linenos">2160</span></a> <span class="k">def</span> <span class="nf">extract_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Extract</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2161"><a href="#Generator-2161"><span class="linenos">2161</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 class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">EXTRACT_ALLOWS_QUOTES</span> <span class="k">else</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><span id="Generator-2162"><a href="#Generator-2162"><span class="linenos">2162</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-2163"><a href="#Generator-2163"><span class="linenos">2163</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"EXTRACT(</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> FROM </span><span class="si">{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Generator-2164"><a href="#Generator-2164"><span class="linenos">2164</span></a> +</span><span id="Generator-2165"><a href="#Generator-2165"><span class="linenos">2165</span></a> <span class="k">def</span> <span class="nf">trim_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Trim</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2166"><a href="#Generator-2166"><span class="linenos">2166</span></a> <span class="n">trim_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">"position"</span><span class="p">)</span> +</span><span id="Generator-2167"><a href="#Generator-2167"><span class="linenos">2167</span></a> +</span><span id="Generator-2168"><a href="#Generator-2168"><span class="linenos">2168</span></a> <span class="k">if</span> <span class="n">trim_type</span> <span class="o">==</span> <span class="s2">"LEADING"</span><span class="p">:</span> +</span><span id="Generator-2169"><a href="#Generator-2169"><span class="linenos">2169</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">"LTRIM"</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-2170"><a href="#Generator-2170"><span class="linenos">2170</span></a> <span class="k">elif</span> <span class="n">trim_type</span> <span class="o">==</span> <span class="s2">"TRAILING"</span><span class="p">:</span> +</span><span id="Generator-2171"><a href="#Generator-2171"><span class="linenos">2171</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">"RTRIM"</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-2172"><a href="#Generator-2172"><span class="linenos">2172</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator-2173"><a href="#Generator-2173"><span class="linenos">2173</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">"TRIM"</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="n">expression</span><span class="o">.</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Generator-2174"><a href="#Generator-2174"><span class="linenos">2174</span></a> +</span><span id="Generator-2175"><a href="#Generator-2175"><span class="linenos">2175</span></a> <span class="k">def</span> <span class="nf">convert_concat_args</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Concat</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">ConcatWs</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]:</span> +</span><span id="Generator-2176"><a href="#Generator-2176"><span class="linenos">2176</span></a> <span class="n">args</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> +</span><span id="Generator-2177"><a href="#Generator-2177"><span class="linenos">2177</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">ConcatWs</span><span class="p">):</span> +</span><span id="Generator-2178"><a href="#Generator-2178"><span class="linenos">2178</span></a> <span class="n">args</span> <span class="o">=</span> <span class="n">args</span><span class="p">[</span><span class="mi">1</span><span class="p">:]</span> <span class="c1"># Skip the delimiter</span> </span><span id="Generator-2179"><a href="#Generator-2179"><span class="linenos">2179</span></a> -</span><span id="Generator-2180"><a href="#Generator-2180"><span class="linenos">2180</span></a> <span class="k">def</span> <span class="nf">foreignkey_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ForeignKey</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2181"><a href="#Generator-2181"><span class="linenos">2181</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-2182"><a href="#Generator-2182"><span class="linenos">2182</span></a> <span class="n">reference</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"reference"</span><span class="p">)</span> -</span><span id="Generator-2183"><a href="#Generator-2183"><span class="linenos">2183</span></a> <span class="n">reference</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">reference</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">reference</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-2184"><a href="#Generator-2184"><span class="linenos">2184</span></a> <span class="n">delete</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"delete"</span><span class="p">)</span> -</span><span id="Generator-2185"><a href="#Generator-2185"><span class="linenos">2185</span></a> <span class="n">delete</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" ON DELETE </span><span class="si">{</span><span class="n">delete</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">delete</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">update</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"update"</span><span class="p">)</span> -</span><span id="Generator-2187"><a href="#Generator-2187"><span class="linenos">2187</span></a> <span class="n">update</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" ON UPDATE </span><span class="si">{</span><span class="n">update</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">update</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">"FOREIGN KEY (</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">reference</span><span class="si">}{</span><span class="n">delete</span><span class="si">}{</span><span class="n">update</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">primarykey_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ForeignKey</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">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-2192"><a href="#Generator-2192"><span class="linenos">2192</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-2193"><a href="#Generator-2193"><span class="linenos">2193</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-2194"><a href="#Generator-2194"><span class="linenos">2194</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PRIMARY KEY (</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">options</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2195"><a href="#Generator-2195"><span class="linenos">2195</span></a> -</span><span id="Generator-2196"><a href="#Generator-2196"><span class="linenos">2196</span></a> <span class="k">def</span> <span class="nf">if_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">If</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2197"><a href="#Generator-2197"><span class="linenos">2197</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">case_sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Case</span><span class="p">(</span><span class="n">ifs</span><span class="o">=</span><span class="p">[</span><span class="n">expression</span><span class="p">],</span> <span class="n">default</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-2198"><a href="#Generator-2198"><span class="linenos">2198</span></a> -</span><span id="Generator-2199"><a href="#Generator-2199"><span class="linenos">2199</span></a> <span class="k">def</span> <span class="nf">matchagainst_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">MatchAgainst</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2200"><a href="#Generator-2200"><span class="linenos">2200</span></a> <span class="n">modifier</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">"modifier"</span><span class="p">)</span> -</span><span id="Generator-2201"><a href="#Generator-2201"><span class="linenos">2201</span></a> <span class="n">modifier</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">modifier</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">modifier</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="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">func</span><span class="p">(</span><span class="s1">'MATCH'</span><span class="p">,</span><span class="w"> </span><span class="o">*</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span><span class="si">}</span><span class="s2"> AGAINST(</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">modifier</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="Generator-2203"><a href="#Generator-2203"><span class="linenos">2203</span></a> -</span><span id="Generator-2204"><a href="#Generator-2204"><span class="linenos">2204</span></a> <span class="k">def</span> <span class="nf">jsonkeyvalue_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">JSONKeyValue</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2205"><a href="#Generator-2205"><span class="linenos">2205</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-2206"><a href="#Generator-2206"><span class="linenos">2206</span></a> -</span><span id="Generator-2207"><a href="#Generator-2207"><span class="linenos">2207</span></a> <span class="k">def</span> <span class="nf">formatjson_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">FormatJson</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2208"><a href="#Generator-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="bp">self</span><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"> FORMAT JSON"</span> -</span><span id="Generator-2209"><a href="#Generator-2209"><span class="linenos">2209</span></a> -</span><span id="Generator-2210"><a href="#Generator-2210"><span class="linenos">2210</span></a> <span class="k">def</span> <span class="nf">jsonobject_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">JSONObject</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="n">null_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">"null_handling"</span><span class="p">)</span> -</span><span id="Generator-2212"><a href="#Generator-2212"><span class="linenos">2212</span></a> <span class="n">null_handling</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">null_handling</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">null_handling</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-2213"><a href="#Generator-2213"><span class="linenos">2213</span></a> <span class="n">unique_keys</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">"unique_keys"</span><span class="p">)</span> -</span><span id="Generator-2214"><a href="#Generator-2214"><span class="linenos">2214</span></a> <span class="k">if</span> <span class="n">unique_keys</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Generator-2215"><a href="#Generator-2215"><span class="linenos">2215</span></a> <span class="n">unique_keys</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="s1">'WITH'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">unique_keys</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">'WITHOUT'</span><span class="si">}</span><span class="s2"> UNIQUE KEYS"</span> -</span><span id="Generator-2216"><a href="#Generator-2216"><span class="linenos">2216</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator-2217"><a href="#Generator-2217"><span class="linenos">2217</span></a> <span class="n">unique_keys</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator-2218"><a href="#Generator-2218"><span class="linenos">2218</span></a> <span class="n">return_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">"return_type"</span><span class="p">)</span> -</span><span id="Generator-2219"><a href="#Generator-2219"><span class="linenos">2219</span></a> <span class="n">return_type</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" RETURNING </span><span class="si">{</span><span class="n">return_type</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">return_type</span> <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="n">encoding</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"encoding"</span><span class="p">)</span> -</span><span id="Generator-2221"><a href="#Generator-2221"><span class="linenos">2221</span></a> <span class="n">encoding</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" ENCODING </span><span class="si">{</span><span class="n">encoding</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">encoding</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-2222"><a href="#Generator-2222"><span class="linenos">2222</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-2223"><a href="#Generator-2223"><span class="linenos">2223</span></a> <span class="s2">"JSON_OBJECT"</span><span class="p">,</span> -</span><span id="Generator-2224"><a href="#Generator-2224"><span class="linenos">2224</span></a> <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-2225"><a href="#Generator-2225"><span class="linenos">2225</span></a> <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">null_handling</span><span class="si">}{</span><span class="n">unique_keys</span><span class="si">}{</span><span class="n">return_type</span><span class="si">}{</span><span class="n">encoding</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="Generator-2226"><a href="#Generator-2226"><span class="linenos">2226</span></a> <span class="p">)</span> -</span><span id="Generator-2227"><a href="#Generator-2227"><span class="linenos">2227</span></a> -</span><span id="Generator-2228"><a href="#Generator-2228"><span class="linenos">2228</span></a> <span class="k">def</span> <span class="nf">jsonarray_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">JSONArray</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2229"><a href="#Generator-2229"><span class="linenos">2229</span></a> <span class="n">null_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">"null_handling"</span><span class="p">)</span> -</span><span id="Generator-2230"><a href="#Generator-2230"><span class="linenos">2230</span></a> <span class="n">null_handling</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">null_handling</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">null_handling</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-2231"><a href="#Generator-2231"><span class="linenos">2231</span></a> <span class="n">return_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">"return_type"</span><span class="p">)</span> -</span><span id="Generator-2232"><a href="#Generator-2232"><span class="linenos">2232</span></a> <span class="n">return_type</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" RETURNING </span><span class="si">{</span><span class="n">return_type</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">return_type</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-2233"><a href="#Generator-2233"><span class="linenos">2233</span></a> <span class="n">strict</span> <span class="o">=</span> <span class="s2">" STRICT"</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">"strict"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-2234"><a href="#Generator-2234"><span class="linenos">2234</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-2235"><a href="#Generator-2235"><span class="linenos">2235</span></a> <span class="s2">"JSON_ARRAY"</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 class="n">suffix</span><span class="o">=</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">null_handling</span><span class="si">}{</span><span class="n">return_type</span><span class="si">}{</span><span class="n">strict</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="Generator-2236"><a href="#Generator-2236"><span class="linenos">2236</span></a> <span class="p">)</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">def</span> <span class="nf">jsonarrayagg_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">JSONArrayAgg</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2239"><a href="#Generator-2239"><span class="linenos">2239</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-2240"><a href="#Generator-2240"><span class="linenos">2240</span></a> <span class="n">order</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"order"</span><span class="p">)</span> -</span><span id="Generator-2241"><a href="#Generator-2241"><span class="linenos">2241</span></a> <span class="n">null_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">"null_handling"</span><span class="p">)</span> -</span><span id="Generator-2242"><a href="#Generator-2242"><span class="linenos">2242</span></a> <span class="n">null_handling</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">null_handling</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">null_handling</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-2243"><a href="#Generator-2243"><span class="linenos">2243</span></a> <span class="n">return_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">"return_type"</span><span class="p">)</span> -</span><span id="Generator-2244"><a href="#Generator-2244"><span class="linenos">2244</span></a> <span class="n">return_type</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" RETURNING </span><span class="si">{</span><span class="n">return_type</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">return_type</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-2245"><a href="#Generator-2245"><span class="linenos">2245</span></a> <span class="n">strict</span> <span class="o">=</span> <span class="s2">" STRICT"</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">"strict"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-2246"><a href="#Generator-2246"><span class="linenos">2246</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-2247"><a href="#Generator-2247"><span class="linenos">2247</span></a> <span class="s2">"JSON_ARRAYAGG"</span><span class="p">,</span> -</span><span id="Generator-2248"><a href="#Generator-2248"><span class="linenos">2248</span></a> <span class="n">this</span><span class="p">,</span> -</span><span id="Generator-2249"><a href="#Generator-2249"><span class="linenos">2249</span></a> <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">order</span><span class="si">}{</span><span class="n">null_handling</span><span class="si">}{</span><span class="n">return_type</span><span class="si">}{</span><span class="n">strict</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="Generator-2250"><a href="#Generator-2250"><span class="linenos">2250</span></a> <span class="p">)</span> -</span><span id="Generator-2251"><a href="#Generator-2251"><span class="linenos">2251</span></a> -</span><span id="Generator-2252"><a href="#Generator-2252"><span class="linenos">2252</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-2253"><a href="#Generator-2253"><span class="linenos">2253</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-2254"><a href="#Generator-2254"><span class="linenos">2254</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-2255"><a href="#Generator-2255"><span class="linenos">2255</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-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="n">nested_schema</span><span class="p">:</span> -</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">"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-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="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-2261"><a href="#Generator-2261"><span class="linenos">2261</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-2262"><a href="#Generator-2262"><span class="linenos">2262</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-2263"><a href="#Generator-2263"><span class="linenos">2263</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-2264"><a href="#Generator-2264"><span class="linenos">2264</span></a> -</span><span id="Generator-2265"><a href="#Generator-2265"><span class="linenos">2265</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-2266"><a href="#Generator-2266"><span class="linenos">2266</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-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">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-2269"><a href="#Generator-2269"><span class="linenos">2269</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-2270"><a href="#Generator-2270"><span class="linenos">2270</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-2271"><a href="#Generator-2271"><span class="linenos">2271</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-2272"><a href="#Generator-2272"><span class="linenos">2272</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-2273"><a href="#Generator-2273"><span class="linenos">2273</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-2274"><a href="#Generator-2274"><span class="linenos">2274</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-2275"><a href="#Generator-2275"><span class="linenos">2275</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-2276"><a href="#Generator-2276"><span class="linenos">2276</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-2277"><a href="#Generator-2277"><span class="linenos">2277</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-2278"><a href="#Generator-2278"><span class="linenos">2278</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-2279"><a href="#Generator-2279"><span class="linenos">2279</span></a> <span class="p">)</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">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-2282"><a href="#Generator-2282"><span class="linenos">2282</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-2283"><a href="#Generator-2283"><span class="linenos">2283</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-2284"><a href="#Generator-2284"><span class="linenos">2284</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-2285"><a href="#Generator-2285"><span class="linenos">2285</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-2286"><a href="#Generator-2286"><span class="linenos">2286</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-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">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-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">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-2290"><a href="#Generator-2290"><span class="linenos">2290</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-2291"><a href="#Generator-2291"><span class="linenos">2291</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-2292"><a href="#Generator-2292"><span class="linenos">2292</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-2293"><a href="#Generator-2293"><span class="linenos">2293</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-2294"><a href="#Generator-2294"><span class="linenos">2294</span></a> <span class="n">with_</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Generator-2295"><a href="#Generator-2295"><span class="linenos">2295</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-2296"><a href="#Generator-2296"><span class="linenos">2296</span></a> <span class="k">if</span> <span class="n">expressions</span> -</span><span id="Generator-2297"><a href="#Generator-2297"><span class="linenos">2297</span></a> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-2298"><a href="#Generator-2298"><span class="linenos">2298</span></a> <span class="p">)</span> -</span><span id="Generator-2299"><a href="#Generator-2299"><span class="linenos">2299</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-2300"><a href="#Generator-2300"><span class="linenos">2300</span></a> -</span><span id="Generator-2301"><a href="#Generator-2301"><span class="linenos">2301</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-2302"><a href="#Generator-2302"><span class="linenos">2302</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-2303"><a href="#Generator-2303"><span class="linenos">2303</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-2304"><a href="#Generator-2304"><span class="linenos">2304</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-2305"><a href="#Generator-2305"><span class="linenos">2305</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-2180"><a href="#Generator-2180"><span class="linenos">2180</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">STRICT_STRING_CONCAT</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">"safe"</span><span class="p">):</span> +</span><span id="Generator-2181"><a href="#Generator-2181"><span class="linenos">2181</span></a> <span class="n">args</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">args</span><span class="p">]</span> +</span><span id="Generator-2182"><a href="#Generator-2182"><span class="linenos">2182</span></a> +</span><span id="Generator-2183"><a href="#Generator-2183"><span class="linenos">2183</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">CONCAT_COALESCE</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">"coalesce"</span><span class="p">):</span> +</span><span id="Generator-2184"><a href="#Generator-2184"><span class="linenos">2184</span></a> <span class="n">args</span> <span class="o">=</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="s2">"coalesce"</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">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="s2">""</span><span class="p">))</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">args</span><span class="p">]</span> +</span><span id="Generator-2185"><a href="#Generator-2185"><span class="linenos">2185</span></a> +</span><span id="Generator-2186"><a href="#Generator-2186"><span class="linenos">2186</span></a> <span class="k">return</span> <span class="n">args</span> +</span><span id="Generator-2187"><a href="#Generator-2187"><span class="linenos">2187</span></a> +</span><span id="Generator-2188"><a href="#Generator-2188"><span class="linenos">2188</span></a> <span class="k">def</span> <span class="nf">concat_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Concat</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2189"><a href="#Generator-2189"><span class="linenos">2189</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">convert_concat_args</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Generator-2190"><a href="#Generator-2190"><span class="linenos">2190</span></a> +</span><span id="Generator-2191"><a href="#Generator-2191"><span class="linenos">2191</span></a> <span class="c1"># Some dialects don't allow a single-argument CONCAT call</span> +</span><span id="Generator-2192"><a href="#Generator-2192"><span class="linenos">2192</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">SUPPORTS_SINGLE_ARG_CONCAT</span> <span class="ow">and</span> <span class="nb">len</span><span class="p">(</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-2193"><a href="#Generator-2193"><span class="linenos">2193</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">expressions</span><span class="p">[</span><span class="mi">0</span><span class="p">])</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">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="n">expressions</span><span class="p">)</span> +</span><span id="Generator-2196"><a href="#Generator-2196"><span class="linenos">2196</span></a> +</span><span id="Generator-2197"><a href="#Generator-2197"><span class="linenos">2197</span></a> <span class="k">def</span> <span class="nf">concatws_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ConcatWs</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2198"><a href="#Generator-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="Generator-2199"><a href="#Generator-2199"><span class="linenos">2199</span></a> <span class="s2">"CONCAT_WS"</span><span class="p">,</span> <span class="n">seq_get</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="mi">0</span><span class="p">),</span> <span class="o">*</span><span class="bp">self</span><span class="o">.</span><span class="n">convert_concat_args</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Generator-2200"><a href="#Generator-2200"><span class="linenos">2200</span></a> <span class="p">)</span> +</span><span id="Generator-2201"><a href="#Generator-2201"><span class="linenos">2201</span></a> +</span><span id="Generator-2202"><a href="#Generator-2202"><span class="linenos">2202</span></a> <span class="k">def</span> <span class="nf">check_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Check</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2203"><a href="#Generator-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="n">key</span><span class="o">=</span><span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-2204"><a href="#Generator-2204"><span class="linenos">2204</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CHECK (</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Generator-2205"><a href="#Generator-2205"><span class="linenos">2205</span></a> +</span><span id="Generator-2206"><a href="#Generator-2206"><span class="linenos">2206</span></a> <span class="k">def</span> <span class="nf">foreignkey_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ForeignKey</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2207"><a href="#Generator-2207"><span class="linenos">2207</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-2208"><a href="#Generator-2208"><span class="linenos">2208</span></a> <span class="n">reference</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"reference"</span><span class="p">)</span> +</span><span id="Generator-2209"><a href="#Generator-2209"><span class="linenos">2209</span></a> <span class="n">reference</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">reference</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">reference</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2210"><a href="#Generator-2210"><span class="linenos">2210</span></a> <span class="n">delete</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"delete"</span><span class="p">)</span> +</span><span id="Generator-2211"><a href="#Generator-2211"><span class="linenos">2211</span></a> <span class="n">delete</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" ON DELETE </span><span class="si">{</span><span class="n">delete</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">delete</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2212"><a href="#Generator-2212"><span class="linenos">2212</span></a> <span class="n">update</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"update"</span><span class="p">)</span> +</span><span id="Generator-2213"><a href="#Generator-2213"><span class="linenos">2213</span></a> <span class="n">update</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" ON UPDATE </span><span class="si">{</span><span class="n">update</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">update</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2214"><a href="#Generator-2214"><span class="linenos">2214</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"FOREIGN KEY (</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">reference</span><span class="si">}{</span><span class="n">delete</span><span class="si">}{</span><span class="n">update</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2215"><a href="#Generator-2215"><span class="linenos">2215</span></a> +</span><span id="Generator-2216"><a href="#Generator-2216"><span class="linenos">2216</span></a> <span class="k">def</span> <span class="nf">primarykey_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ForeignKey</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2217"><a href="#Generator-2217"><span class="linenos">2217</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-2218"><a href="#Generator-2218"><span class="linenos">2218</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-2219"><a href="#Generator-2219"><span class="linenos">2219</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-2220"><a href="#Generator-2220"><span class="linenos">2220</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PRIMARY KEY (</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">options</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2221"><a href="#Generator-2221"><span class="linenos">2221</span></a> +</span><span id="Generator-2222"><a href="#Generator-2222"><span class="linenos">2222</span></a> <span class="k">def</span> <span class="nf">if_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">If</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2223"><a href="#Generator-2223"><span class="linenos">2223</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">case_sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Case</span><span class="p">(</span><span class="n">ifs</span><span class="o">=</span><span class="p">[</span><span class="n">expression</span><span class="p">],</span> <span class="n">default</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-2224"><a href="#Generator-2224"><span class="linenos">2224</span></a> +</span><span id="Generator-2225"><a href="#Generator-2225"><span class="linenos">2225</span></a> <span class="k">def</span> <span class="nf">matchagainst_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">MatchAgainst</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2226"><a href="#Generator-2226"><span class="linenos">2226</span></a> <span class="n">modifier</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">"modifier"</span><span class="p">)</span> +</span><span id="Generator-2227"><a href="#Generator-2227"><span class="linenos">2227</span></a> <span class="n">modifier</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">modifier</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">modifier</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 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">func</span><span class="p">(</span><span class="s1">'MATCH'</span><span class="p">,</span><span class="w"> </span><span class="o">*</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span><span class="si">}</span><span class="s2"> AGAINST(</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">modifier</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Generator-2229"><a href="#Generator-2229"><span class="linenos">2229</span></a> +</span><span id="Generator-2230"><a href="#Generator-2230"><span class="linenos">2230</span></a> <span class="k">def</span> <span class="nf">jsonkeyvalue_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">JSONKeyValue</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2231"><a href="#Generator-2231"><span class="linenos">2231</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-2232"><a href="#Generator-2232"><span class="linenos">2232</span></a> +</span><span id="Generator-2233"><a href="#Generator-2233"><span class="linenos">2233</span></a> <span class="k">def</span> <span class="nf">formatjson_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">FormatJson</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2234"><a href="#Generator-2234"><span class="linenos">2234</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"> FORMAT JSON"</span> +</span><span id="Generator-2235"><a href="#Generator-2235"><span class="linenos">2235</span></a> +</span><span id="Generator-2236"><a href="#Generator-2236"><span class="linenos">2236</span></a> <span class="k">def</span> <span class="nf">jsonobject_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">JSONObject</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2237"><a href="#Generator-2237"><span class="linenos">2237</span></a> <span class="n">null_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">"null_handling"</span><span class="p">)</span> +</span><span id="Generator-2238"><a href="#Generator-2238"><span class="linenos">2238</span></a> <span class="n">null_handling</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">null_handling</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">null_handling</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2239"><a href="#Generator-2239"><span class="linenos">2239</span></a> <span class="n">unique_keys</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">"unique_keys"</span><span class="p">)</span> +</span><span id="Generator-2240"><a href="#Generator-2240"><span class="linenos">2240</span></a> <span class="k">if</span> <span class="n">unique_keys</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Generator-2241"><a href="#Generator-2241"><span class="linenos">2241</span></a> <span class="n">unique_keys</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="s1">'WITH'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">unique_keys</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">'WITHOUT'</span><span class="si">}</span><span class="s2"> UNIQUE KEYS"</span> +</span><span id="Generator-2242"><a href="#Generator-2242"><span class="linenos">2242</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator-2243"><a href="#Generator-2243"><span class="linenos">2243</span></a> <span class="n">unique_keys</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator-2244"><a href="#Generator-2244"><span class="linenos">2244</span></a> <span class="n">return_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">"return_type"</span><span class="p">)</span> +</span><span id="Generator-2245"><a href="#Generator-2245"><span class="linenos">2245</span></a> <span class="n">return_type</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" RETURNING </span><span class="si">{</span><span class="n">return_type</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">return_type</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2246"><a href="#Generator-2246"><span class="linenos">2246</span></a> <span class="n">encoding</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"encoding"</span><span class="p">)</span> +</span><span id="Generator-2247"><a href="#Generator-2247"><span class="linenos">2247</span></a> <span class="n">encoding</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" ENCODING </span><span class="si">{</span><span class="n">encoding</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">encoding</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 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-2249"><a href="#Generator-2249"><span class="linenos">2249</span></a> <span class="s2">"JSON_OBJECT"</span><span class="p">,</span> +</span><span id="Generator-2250"><a href="#Generator-2250"><span class="linenos">2250</span></a> <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-2251"><a href="#Generator-2251"><span class="linenos">2251</span></a> <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">null_handling</span><span class="si">}{</span><span class="n">unique_keys</span><span class="si">}{</span><span class="n">return_type</span><span class="si">}{</span><span class="n">encoding</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="Generator-2252"><a href="#Generator-2252"><span class="linenos">2252</span></a> <span class="p">)</span> +</span><span id="Generator-2253"><a href="#Generator-2253"><span class="linenos">2253</span></a> +</span><span id="Generator-2254"><a href="#Generator-2254"><span class="linenos">2254</span></a> <span class="k">def</span> <span class="nf">jsonarray_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">JSONArray</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2255"><a href="#Generator-2255"><span class="linenos">2255</span></a> <span class="n">null_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">"null_handling"</span><span class="p">)</span> +</span><span id="Generator-2256"><a href="#Generator-2256"><span class="linenos">2256</span></a> <span class="n">null_handling</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">null_handling</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">null_handling</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2257"><a href="#Generator-2257"><span class="linenos">2257</span></a> <span class="n">return_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">"return_type"</span><span class="p">)</span> +</span><span id="Generator-2258"><a href="#Generator-2258"><span class="linenos">2258</span></a> <span class="n">return_type</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" RETURNING </span><span class="si">{</span><span class="n">return_type</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">return_type</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="n">strict</span> <span class="o">=</span> <span class="s2">" STRICT"</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">"strict"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2260"><a href="#Generator-2260"><span class="linenos">2260</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-2261"><a href="#Generator-2261"><span class="linenos">2261</span></a> <span class="s2">"JSON_ARRAY"</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 class="n">suffix</span><span class="o">=</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">null_handling</span><span class="si">}{</span><span class="n">return_type</span><span class="si">}{</span><span class="n">strict</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 class="p">)</span> +</span><span id="Generator-2263"><a href="#Generator-2263"><span class="linenos">2263</span></a> +</span><span id="Generator-2264"><a href="#Generator-2264"><span class="linenos">2264</span></a> <span class="k">def</span> <span class="nf">jsonarrayagg_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">JSONArrayAgg</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2265"><a href="#Generator-2265"><span class="linenos">2265</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-2266"><a href="#Generator-2266"><span class="linenos">2266</span></a> <span class="n">order</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"order"</span><span class="p">)</span> +</span><span id="Generator-2267"><a href="#Generator-2267"><span class="linenos">2267</span></a> <span class="n">null_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">"null_handling"</span><span class="p">)</span> +</span><span id="Generator-2268"><a href="#Generator-2268"><span class="linenos">2268</span></a> <span class="n">null_handling</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">null_handling</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">null_handling</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="n">return_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">"return_type"</span><span class="p">)</span> +</span><span id="Generator-2270"><a href="#Generator-2270"><span class="linenos">2270</span></a> <span class="n">return_type</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" RETURNING </span><span class="si">{</span><span class="n">return_type</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">return_type</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2271"><a href="#Generator-2271"><span class="linenos">2271</span></a> <span class="n">strict</span> <span class="o">=</span> <span class="s2">" STRICT"</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">"strict"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</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><span id="Generator-2273"><a href="#Generator-2273"><span class="linenos">2273</span></a> <span class="s2">"JSON_ARRAYAGG"</span><span class="p">,</span> +</span><span id="Generator-2274"><a href="#Generator-2274"><span class="linenos">2274</span></a> <span class="n">this</span><span class="p">,</span> +</span><span id="Generator-2275"><a href="#Generator-2275"><span class="linenos">2275</span></a> <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">order</span><span class="si">}{</span><span class="n">null_handling</span><span class="si">}{</span><span class="n">return_type</span><span class="si">}{</span><span class="n">strict</span><span class="si">}</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="p">)</span> +</span><span id="Generator-2277"><a href="#Generator-2277"><span class="linenos">2277</span></a> +</span><span id="Generator-2278"><a href="#Generator-2278"><span class="linenos">2278</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-2279"><a href="#Generator-2279"><span class="linenos">2279</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-2280"><a href="#Generator-2280"><span class="linenos">2280</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-2281"><a href="#Generator-2281"><span class="linenos">2281</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-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">if</span> <span class="n">nested_schema</span><span class="p">:</span> +</span><span id="Generator-2284"><a href="#Generator-2284"><span class="linenos">2284</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-2285"><a href="#Generator-2285"><span class="linenos">2285</span></a> +</span><span id="Generator-2286"><a href="#Generator-2286"><span class="linenos">2286</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-2287"><a href="#Generator-2287"><span class="linenos">2287</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-2288"><a href="#Generator-2288"><span class="linenos">2288</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-2289"><a href="#Generator-2289"><span class="linenos">2289</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-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">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-2292"><a href="#Generator-2292"><span class="linenos">2292</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-2293"><a href="#Generator-2293"><span class="linenos">2293</span></a> +</span><span id="Generator-2294"><a href="#Generator-2294"><span class="linenos">2294</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-2295"><a href="#Generator-2295"><span class="linenos">2295</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-2296"><a href="#Generator-2296"><span class="linenos">2296</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-2297"><a href="#Generator-2297"><span class="linenos">2297</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-2298"><a href="#Generator-2298"><span class="linenos">2298</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-2299"><a href="#Generator-2299"><span class="linenos">2299</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-2300"><a href="#Generator-2300"><span class="linenos">2300</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-2301"><a href="#Generator-2301"><span class="linenos">2301</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-2302"><a href="#Generator-2302"><span class="linenos">2302</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-2303"><a href="#Generator-2303"><span class="linenos">2303</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-2304"><a href="#Generator-2304"><span class="linenos">2304</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-2305"><a href="#Generator-2305"><span class="linenos">2305</span></a> <span class="p">)</span> </span><span id="Generator-2306"><a href="#Generator-2306"><span class="linenos">2306</span></a> -</span><span id="Generator-2307"><a href="#Generator-2307"><span class="linenos">2307</span></a> <span class="k">if</span> <span class="n">query</span><span class="p">:</span> -</span><span id="Generator-2308"><a href="#Generator-2308"><span class="linenos">2308</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-2309"><a href="#Generator-2309"><span class="linenos">2309</span></a> <span class="k">elif</span> <span class="n">unnest</span><span class="p">:</span> -</span><span id="Generator-2310"><a href="#Generator-2310"><span class="linenos">2310</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-2311"><a href="#Generator-2311"><span class="linenos">2311</span></a> <span class="k">elif</span> <span class="n">field</span><span class="p">:</span> -</span><span id="Generator-2312"><a href="#Generator-2312"><span class="linenos">2312</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-2313"><a href="#Generator-2313"><span class="linenos">2313</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator-2314"><a href="#Generator-2314"><span class="linenos">2314</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-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">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-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="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-2319"><a href="#Generator-2319"><span class="linenos">2319</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-2320"><a href="#Generator-2320"><span class="linenos">2320</span></a> -</span><span id="Generator-2321"><a href="#Generator-2321"><span class="linenos">2321</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-2322"><a href="#Generator-2322"><span class="linenos">2322</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-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">INTERVAL_ALLOWS_PLURAL_FORM</span><span class="p">:</span> -</span><span id="Generator-2324"><a href="#Generator-2324"><span class="linenos">2324</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-2325"><a href="#Generator-2325"><span class="linenos">2325</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-2307"><a href="#Generator-2307"><span class="linenos">2307</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-2308"><a href="#Generator-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="Generator-2309"><a href="#Generator-2309"><span class="linenos">2309</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-2310"><a href="#Generator-2310"><span class="linenos">2310</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-2311"><a href="#Generator-2311"><span class="linenos">2311</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-2312"><a href="#Generator-2312"><span class="linenos">2312</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-2313"><a href="#Generator-2313"><span class="linenos">2313</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-2314"><a href="#Generator-2314"><span class="linenos">2314</span></a> +</span><span id="Generator-2315"><a href="#Generator-2315"><span class="linenos">2315</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-2316"><a href="#Generator-2316"><span class="linenos">2316</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-2317"><a href="#Generator-2317"><span class="linenos">2317</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-2318"><a href="#Generator-2318"><span class="linenos">2318</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-2319"><a href="#Generator-2319"><span class="linenos">2319</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-2320"><a href="#Generator-2320"><span class="linenos">2320</span></a> <span class="n">with_</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Generator-2321"><a href="#Generator-2321"><span class="linenos">2321</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-2322"><a href="#Generator-2322"><span class="linenos">2322</span></a> <span class="k">if</span> <span class="n">expressions</span> +</span><span id="Generator-2323"><a href="#Generator-2323"><span class="linenos">2323</span></a> <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="p">)</span> +</span><span id="Generator-2325"><a href="#Generator-2325"><span class="linenos">2325</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-2326"><a href="#Generator-2326"><span class="linenos">2326</span></a> -</span><span id="Generator-2327"><a href="#Generator-2327"><span class="linenos">2327</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-2328"><a href="#Generator-2328"><span class="linenos">2328</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-2329"><a href="#Generator-2329"><span class="linenos">2329</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-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">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-2332"><a href="#Generator-2332"><span class="linenos">2332</span></a> <span class="k">if</span> <span class="n">this</span><span class="p">:</span> -</span><span id="Generator-2333"><a href="#Generator-2333"><span class="linenos">2333</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-2334"><a href="#Generator-2334"><span class="linenos">2334</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-2335"><a href="#Generator-2335"><span class="linenos">2335</span></a> -</span><span id="Generator-2336"><a href="#Generator-2336"><span class="linenos">2336</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-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">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-2339"><a href="#Generator-2339"><span class="linenos">2339</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-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">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-2342"><a href="#Generator-2342"><span class="linenos">2342</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-2343"><a href="#Generator-2343"><span class="linenos">2343</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-2344"><a href="#Generator-2344"><span class="linenos">2344</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-2345"><a href="#Generator-2345"><span class="linenos">2345</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-2346"><a href="#Generator-2346"><span class="linenos">2346</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-2347"><a href="#Generator-2347"><span class="linenos">2347</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-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">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-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">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-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">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-2353"><a href="#Generator-2353"><span class="linenos">2353</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-2354"><a href="#Generator-2354"><span class="linenos">2354</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-2355"><a href="#Generator-2355"><span class="linenos">2355</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator-2356"><a href="#Generator-2356"><span class="linenos">2356</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-2357"><a href="#Generator-2357"><span class="linenos">2357</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-2358"><a href="#Generator-2358"><span class="linenos">2358</span></a> -</span><span id="Generator-2359"><a href="#Generator-2359"><span class="linenos">2359</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-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">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-2362"><a href="#Generator-2362"><span class="linenos">2362</span></a> <span class="c1"># This makes sure we don't convert "- - 5" to "--5", which is a comment</span> -</span><span id="Generator-2363"><a href="#Generator-2363"><span class="linenos">2363</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-2364"><a href="#Generator-2364"><span class="linenos">2364</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-2365"><a href="#Generator-2365"><span class="linenos">2365</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-2327"><a href="#Generator-2327"><span class="linenos">2327</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-2328"><a href="#Generator-2328"><span class="linenos">2328</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-2329"><a href="#Generator-2329"><span class="linenos">2329</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-2330"><a href="#Generator-2330"><span class="linenos">2330</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-2331"><a href="#Generator-2331"><span class="linenos">2331</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-2332"><a href="#Generator-2332"><span class="linenos">2332</span></a> +</span><span id="Generator-2333"><a href="#Generator-2333"><span class="linenos">2333</span></a> <span class="k">if</span> <span class="n">query</span><span class="p">:</span> +</span><span id="Generator-2334"><a href="#Generator-2334"><span class="linenos">2334</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-2335"><a href="#Generator-2335"><span class="linenos">2335</span></a> <span class="k">elif</span> <span class="n">unnest</span><span class="p">:</span> +</span><span id="Generator-2336"><a href="#Generator-2336"><span class="linenos">2336</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-2337"><a href="#Generator-2337"><span class="linenos">2337</span></a> <span class="k">elif</span> <span class="n">field</span><span class="p">:</span> +</span><span id="Generator-2338"><a href="#Generator-2338"><span class="linenos">2338</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-2339"><a href="#Generator-2339"><span class="linenos">2339</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator-2340"><a href="#Generator-2340"><span class="linenos">2340</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-2341"><a href="#Generator-2341"><span class="linenos">2341</span></a> +</span><span id="Generator-2342"><a href="#Generator-2342"><span class="linenos">2342</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-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">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-2345"><a href="#Generator-2345"><span class="linenos">2345</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-2346"><a href="#Generator-2346"><span class="linenos">2346</span></a> +</span><span id="Generator-2347"><a href="#Generator-2347"><span class="linenos">2347</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-2348"><a href="#Generator-2348"><span class="linenos">2348</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-2349"><a href="#Generator-2349"><span class="linenos">2349</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-2350"><a href="#Generator-2350"><span class="linenos">2350</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-2351"><a href="#Generator-2351"><span class="linenos">2351</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-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">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-2354"><a href="#Generator-2354"><span class="linenos">2354</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-2355"><a href="#Generator-2355"><span class="linenos">2355</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-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="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-2358"><a href="#Generator-2358"><span class="linenos">2358</span></a> <span class="k">if</span> <span class="n">this</span><span class="p">:</span> +</span><span id="Generator-2359"><a href="#Generator-2359"><span class="linenos">2359</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-2360"><a href="#Generator-2360"><span class="linenos">2360</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-2361"><a href="#Generator-2361"><span class="linenos">2361</span></a> +</span><span id="Generator-2362"><a href="#Generator-2362"><span class="linenos">2362</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-2363"><a href="#Generator-2363"><span class="linenos">2363</span></a> +</span><span id="Generator-2364"><a href="#Generator-2364"><span class="linenos">2364</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-2365"><a href="#Generator-2365"><span class="linenos">2365</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-2366"><a href="#Generator-2366"><span class="linenos">2366</span></a> -</span><span id="Generator-2367"><a href="#Generator-2367"><span class="linenos">2367</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-2368"><a href="#Generator-2368"><span class="linenos">2368</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-2369"><a href="#Generator-2369"><span class="linenos">2369</span></a> -</span><span id="Generator-2370"><a href="#Generator-2370"><span class="linenos">2370</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-2371"><a href="#Generator-2371"><span class="linenos">2371</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-2372"><a href="#Generator-2372"><span class="linenos">2372</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-2373"><a href="#Generator-2373"><span class="linenos">2373</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-2367"><a href="#Generator-2367"><span class="linenos">2367</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-2368"><a href="#Generator-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="Generator-2369"><a href="#Generator-2369"><span class="linenos">2369</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-2370"><a href="#Generator-2370"><span class="linenos">2370</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-2371"><a href="#Generator-2371"><span class="linenos">2371</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-2372"><a href="#Generator-2372"><span class="linenos">2372</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-2373"><a href="#Generator-2373"><span class="linenos">2373</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-2374"><a href="#Generator-2374"><span class="linenos">2374</span></a> -</span><span id="Generator-2375"><a href="#Generator-2375"><span class="linenos">2375</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-2376"><a href="#Generator-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="bp">self</span><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-2375"><a href="#Generator-2375"><span class="linenos">2375</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-2376"><a href="#Generator-2376"><span class="linenos">2376</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-2377"><a href="#Generator-2377"><span class="linenos">2377</span></a> -</span><span id="Generator-2378"><a href="#Generator-2378"><span class="linenos">2378</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-2379"><a href="#Generator-2379"><span class="linenos">2379</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-2380"><a href="#Generator-2380"><span class="linenos">2380</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-2381"><a href="#Generator-2381"><span class="linenos">2381</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-2382"><a href="#Generator-2382"><span class="linenos">2382</span></a> -</span><span id="Generator-2383"><a href="#Generator-2383"><span class="linenos">2383</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-2384"><a href="#Generator-2384"><span class="linenos">2384</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-2385"><a href="#Generator-2385"><span class="linenos">2385</span></a> -</span><span id="Generator-2386"><a href="#Generator-2386"><span class="linenos">2386</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-2387"><a href="#Generator-2387"><span class="linenos">2387</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-2388"><a href="#Generator-2388"><span class="linenos">2388</span></a> -</span><span id="Generator-2389"><a href="#Generator-2389"><span class="linenos">2389</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-2390"><a href="#Generator-2390"><span class="linenos">2390</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-2391"><a href="#Generator-2391"><span class="linenos">2391</span></a> -</span><span id="Generator-2392"><a href="#Generator-2392"><span class="linenos">2392</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-2393"><a href="#Generator-2393"><span class="linenos">2393</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-2394"><a href="#Generator-2394"><span class="linenos">2394</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-2378"><a href="#Generator-2378"><span class="linenos">2378</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-2379"><a href="#Generator-2379"><span class="linenos">2379</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-2380"><a href="#Generator-2380"><span class="linenos">2380</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-2381"><a href="#Generator-2381"><span class="linenos">2381</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator-2382"><a href="#Generator-2382"><span class="linenos">2382</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-2383"><a href="#Generator-2383"><span class="linenos">2383</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-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">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-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">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-2388"><a href="#Generator-2388"><span class="linenos">2388</span></a> <span class="c1"># This makes sure we don't convert "- - 5" to "--5", which is a comment</span> +</span><span id="Generator-2389"><a href="#Generator-2389"><span class="linenos">2389</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-2390"><a href="#Generator-2390"><span class="linenos">2390</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-2391"><a href="#Generator-2391"><span class="linenos">2391</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-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">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-2394"><a href="#Generator-2394"><span class="linenos">2394</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-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="n">sqls</span> <span class="o">=</span> <span class="nb">tuple</span><span class="p">(</span> -</span><span id="Generator-2397"><a href="#Generator-2397"><span class="linenos">2397</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-2398"><a href="#Generator-2398"><span class="linenos">2398</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-2399"><a href="#Generator-2399"><span class="linenos">2399</span></a> <span class="p">)</span> +</span><span id="Generator-2396"><a href="#Generator-2396"><span class="linenos">2396</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-2397"><a href="#Generator-2397"><span class="linenos">2397</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-2398"><a href="#Generator-2398"><span class="linenos">2398</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-2399"><a href="#Generator-2399"><span class="linenos">2399</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-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="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-2402"><a href="#Generator-2402"><span class="linenos">2402</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-2401"><a href="#Generator-2401"><span class="linenos">2401</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-2402"><a href="#Generator-2402"><span class="linenos">2402</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-2403"><a href="#Generator-2403"><span class="linenos">2403</span></a> -</span><span id="Generator-2404"><a href="#Generator-2404"><span class="linenos">2404</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-2405"><a href="#Generator-2405"><span class="linenos">2405</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-2406"><a href="#Generator-2406"><span class="linenos">2406</span></a> -</span><span id="Generator-2407"><a href="#Generator-2407"><span class="linenos">2407</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-2408"><a href="#Generator-2408"><span class="linenos">2408</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-2409"><a href="#Generator-2409"><span class="linenos">2409</span></a> -</span><span id="Generator-2410"><a href="#Generator-2410"><span class="linenos">2410</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-2411"><a href="#Generator-2411"><span class="linenos">2411</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-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">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-2414"><a href="#Generator-2414"><span class="linenos">2414</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-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="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-2417"><a href="#Generator-2417"><span class="linenos">2417</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-2418"><a href="#Generator-2418"><span class="linenos">2418</span></a> -</span><span id="Generator-2419"><a href="#Generator-2419"><span class="linenos">2419</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-2420"><a href="#Generator-2420"><span class="linenos">2420</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-2404"><a href="#Generator-2404"><span class="linenos">2404</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-2405"><a href="#Generator-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="Generator-2406"><a href="#Generator-2406"><span class="linenos">2406</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-2407"><a href="#Generator-2407"><span class="linenos">2407</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-2408"><a href="#Generator-2408"><span class="linenos">2408</span></a> +</span><span id="Generator-2409"><a href="#Generator-2409"><span class="linenos">2409</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-2410"><a href="#Generator-2410"><span class="linenos">2410</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-2411"><a href="#Generator-2411"><span class="linenos">2411</span></a> +</span><span id="Generator-2412"><a href="#Generator-2412"><span class="linenos">2412</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-2413"><a href="#Generator-2413"><span class="linenos">2413</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-2414"><a href="#Generator-2414"><span class="linenos">2414</span></a> +</span><span id="Generator-2415"><a href="#Generator-2415"><span class="linenos">2415</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-2416"><a href="#Generator-2416"><span class="linenos">2416</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-2417"><a href="#Generator-2417"><span class="linenos">2417</span></a> +</span><span id="Generator-2418"><a href="#Generator-2418"><span class="linenos">2418</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-2419"><a href="#Generator-2419"><span class="linenos">2419</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-2420"><a href="#Generator-2420"><span class="linenos">2420</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-2421"><a href="#Generator-2421"><span class="linenos">2421</span></a> -</span><span id="Generator-2422"><a href="#Generator-2422"><span class="linenos">2422</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-2423"><a href="#Generator-2423"><span class="linenos">2423</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-2424"><a href="#Generator-2424"><span class="linenos">2424</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-2425"><a href="#Generator-2425"><span class="linenos">2425</span></a> <span class="n">to_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">"to"</span><span class="p">)</span> -</span><span id="Generator-2426"><a href="#Generator-2426"><span class="linenos">2426</span></a> <span class="n">to_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">to_sql</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">to_sql</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-2427"><a href="#Generator-2427"><span class="linenos">2427</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="n">to_sql</span><span class="si">}{</span><span class="n">format_sql</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="Generator-2428"><a href="#Generator-2428"><span class="linenos">2428</span></a> -</span><span id="Generator-2429"><a href="#Generator-2429"><span class="linenos">2429</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-2430"><a href="#Generator-2430"><span class="linenos">2430</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-2431"><a href="#Generator-2431"><span class="linenos">2431</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-2422"><a href="#Generator-2422"><span class="linenos">2422</span></a> <span class="n">sqls</span> <span class="o">=</span> <span class="nb">tuple</span><span class="p">(</span> +</span><span id="Generator-2423"><a href="#Generator-2423"><span class="linenos">2423</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-2424"><a href="#Generator-2424"><span class="linenos">2424</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-2425"><a href="#Generator-2425"><span class="linenos">2425</span></a> <span class="p">)</span> +</span><span id="Generator-2426"><a href="#Generator-2426"><span class="linenos">2426</span></a> +</span><span id="Generator-2427"><a href="#Generator-2427"><span class="linenos">2427</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-2428"><a href="#Generator-2428"><span class="linenos">2428</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-2429"><a href="#Generator-2429"><span class="linenos">2429</span></a> +</span><span id="Generator-2430"><a href="#Generator-2430"><span class="linenos">2430</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-2431"><a href="#Generator-2431"><span class="linenos">2431</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-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">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-2434"><a href="#Generator-2434"><span class="linenos">2434</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-2435"><a href="#Generator-2435"><span class="linenos">2435</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-2436"><a href="#Generator-2436"><span class="linenos">2436</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-2437"><a href="#Generator-2437"><span class="linenos">2437</span></a> -</span><span id="Generator-2438"><a href="#Generator-2438"><span class="linenos">2438</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-2439"><a href="#Generator-2439"><span class="linenos">2439</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-2440"><a href="#Generator-2440"><span class="linenos">2440</span></a> -</span><span id="Generator-2441"><a href="#Generator-2441"><span class="linenos">2441</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-2442"><a href="#Generator-2442"><span class="linenos">2442</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-2443"><a href="#Generator-2443"><span class="linenos">2443</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-2444"><a href="#Generator-2444"><span class="linenos">2444</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-2445"><a href="#Generator-2445"><span class="linenos">2445</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-2446"><a href="#Generator-2446"><span class="linenos">2446</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-2433"><a href="#Generator-2433"><span class="linenos">2433</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-2434"><a href="#Generator-2434"><span class="linenos">2434</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-2435"><a href="#Generator-2435"><span class="linenos">2435</span></a> +</span><span id="Generator-2436"><a href="#Generator-2436"><span class="linenos">2436</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-2437"><a href="#Generator-2437"><span class="linenos">2437</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-2438"><a href="#Generator-2438"><span class="linenos">2438</span></a> +</span><span id="Generator-2439"><a href="#Generator-2439"><span class="linenos">2439</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-2440"><a href="#Generator-2440"><span class="linenos">2440</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-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">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-2443"><a href="#Generator-2443"><span class="linenos">2443</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-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">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-2446"><a href="#Generator-2446"><span class="linenos">2446</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-2447"><a href="#Generator-2447"><span class="linenos">2447</span></a> -</span><span id="Generator-2448"><a href="#Generator-2448"><span class="linenos">2448</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-2449"><a href="#Generator-2449"><span class="linenos">2449</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-2450"><a href="#Generator-2450"><span class="linenos">2450</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-2451"><a href="#Generator-2451"><span class="linenos">2451</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-2452"><a href="#Generator-2452"><span class="linenos">2452</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-2453"><a href="#Generator-2453"><span class="linenos">2453</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-2454"><a href="#Generator-2454"><span class="linenos">2454</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-2455"><a href="#Generator-2455"><span class="linenos">2455</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-2456"><a href="#Generator-2456"><span class="linenos">2456</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-2457"><a href="#Generator-2457"><span class="linenos">2457</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-2448"><a href="#Generator-2448"><span class="linenos">2448</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-2449"><a href="#Generator-2449"><span class="linenos">2449</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-2450"><a href="#Generator-2450"><span class="linenos">2450</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-2451"><a href="#Generator-2451"><span class="linenos">2451</span></a> <span class="n">to_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">"to"</span><span class="p">)</span> +</span><span id="Generator-2452"><a href="#Generator-2452"><span class="linenos">2452</span></a> <span class="n">to_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">to_sql</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">to_sql</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2453"><a href="#Generator-2453"><span class="linenos">2453</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="n">to_sql</span><span class="si">}{</span><span class="n">format_sql</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><span id="Generator-2455"><a href="#Generator-2455"><span class="linenos">2455</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-2456"><a href="#Generator-2456"><span class="linenos">2456</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-2457"><a href="#Generator-2457"><span class="linenos">2457</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-2458"><a href="#Generator-2458"><span class="linenos">2458</span></a> -</span><span id="Generator-2459"><a href="#Generator-2459"><span class="linenos">2459</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-2460"><a href="#Generator-2460"><span class="linenos">2460</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-2461"><a href="#Generator-2461"><span class="linenos">2461</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-2462"><a href="#Generator-2462"><span class="linenos">2462</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-2463"><a href="#Generator-2463"><span class="linenos">2463</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-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">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-2466"><a href="#Generator-2466"><span class="linenos">2466</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-2467"><a href="#Generator-2467"><span class="linenos">2467</span></a> -</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">"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-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">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-2471"><a href="#Generator-2471"><span class="linenos">2471</span></a> <span class="k">return</span> <span class="s2">"BEGIN"</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">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-2474"><a href="#Generator-2474"><span class="linenos">2474</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-2475"><a href="#Generator-2475"><span class="linenos">2475</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-2476"><a href="#Generator-2476"><span class="linenos">2476</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-2477"><a href="#Generator-2477"><span class="linenos">2477</span></a> -</span><span id="Generator-2478"><a href="#Generator-2478"><span class="linenos">2478</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-2479"><a href="#Generator-2479"><span class="linenos">2479</span></a> -</span><span id="Generator-2480"><a href="#Generator-2480"><span class="linenos">2480</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-2481"><a href="#Generator-2481"><span class="linenos">2481</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-2482"><a href="#Generator-2482"><span class="linenos">2482</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-2483"><a href="#Generator-2483"><span class="linenos">2483</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-2459"><a href="#Generator-2459"><span class="linenos">2459</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-2460"><a href="#Generator-2460"><span class="linenos">2460</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-2461"><a href="#Generator-2461"><span class="linenos">2461</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-2462"><a href="#Generator-2462"><span class="linenos">2462</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-2463"><a href="#Generator-2463"><span class="linenos">2463</span></a> +</span><span id="Generator-2464"><a href="#Generator-2464"><span class="linenos">2464</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-2465"><a href="#Generator-2465"><span class="linenos">2465</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-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="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-2468"><a href="#Generator-2468"><span class="linenos">2468</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-2469"><a href="#Generator-2469"><span class="linenos">2469</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-2470"><a href="#Generator-2470"><span class="linenos">2470</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-2471"><a href="#Generator-2471"><span class="linenos">2471</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-2472"><a href="#Generator-2472"><span class="linenos">2472</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-2473"><a href="#Generator-2473"><span class="linenos">2473</span></a> +</span><span id="Generator-2474"><a href="#Generator-2474"><span class="linenos">2474</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-2475"><a href="#Generator-2475"><span class="linenos">2475</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-2476"><a href="#Generator-2476"><span class="linenos">2476</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-2477"><a href="#Generator-2477"><span class="linenos">2477</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-2478"><a href="#Generator-2478"><span class="linenos">2478</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-2479"><a href="#Generator-2479"><span class="linenos">2479</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-2480"><a href="#Generator-2480"><span class="linenos">2480</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-2481"><a href="#Generator-2481"><span class="linenos">2481</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-2482"><a href="#Generator-2482"><span class="linenos">2482</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-2483"><a href="#Generator-2483"><span class="linenos">2483</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-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="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-2486"><a href="#Generator-2486"><span class="linenos">2486</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-2487"><a href="#Generator-2487"><span class="linenos">2487</span></a> -</span><span id="Generator-2488"><a href="#Generator-2488"><span class="linenos">2488</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-2489"><a href="#Generator-2489"><span class="linenos">2489</span></a> <span class="k">if</span> <span class="n">dtype</span><span class="p">:</span> -</span><span id="Generator-2490"><a href="#Generator-2490"><span class="linenos">2490</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-2491"><a href="#Generator-2491"><span class="linenos">2491</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-2492"><a href="#Generator-2492"><span class="linenos">2492</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-2493"><a href="#Generator-2493"><span class="linenos">2493</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-2494"><a href="#Generator-2494"><span class="linenos">2494</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-2485"><a href="#Generator-2485"><span class="linenos">2485</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-2486"><a href="#Generator-2486"><span class="linenos">2486</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-2487"><a href="#Generator-2487"><span class="linenos">2487</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-2488"><a href="#Generator-2488"><span class="linenos">2488</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-2489"><a href="#Generator-2489"><span class="linenos">2489</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-2490"><a href="#Generator-2490"><span class="linenos">2490</span></a> +</span><span id="Generator-2491"><a href="#Generator-2491"><span class="linenos">2491</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-2492"><a href="#Generator-2492"><span class="linenos">2492</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-2493"><a href="#Generator-2493"><span class="linenos">2493</span></a> +</span><span id="Generator-2494"><a href="#Generator-2494"><span class="linenos">2494</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-2495"><a href="#Generator-2495"><span class="linenos">2495</span></a> -</span><span id="Generator-2496"><a href="#Generator-2496"><span class="linenos">2496</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-2497"><a href="#Generator-2497"><span class="linenos">2497</span></a> <span class="k">if</span> <span class="n">default</span><span class="p">:</span> -</span><span id="Generator-2498"><a href="#Generator-2498"><span class="linenos">2498</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-2499"><a href="#Generator-2499"><span class="linenos">2499</span></a> -</span><span id="Generator-2500"><a href="#Generator-2500"><span class="linenos">2500</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-2501"><a href="#Generator-2501"><span class="linenos">2501</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-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">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-2504"><a href="#Generator-2504"><span class="linenos">2504</span></a> -</span><span id="Generator-2505"><a href="#Generator-2505"><span class="linenos">2505</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-2506"><a href="#Generator-2506"><span class="linenos">2506</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-2507"><a href="#Generator-2507"><span class="linenos">2507</span></a> <span class="c1"># Remove db from tables</span> -</span><span id="Generator-2508"><a href="#Generator-2508"><span class="linenos">2508</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-2509"><a href="#Generator-2509"><span class="linenos">2509</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-2510"><a href="#Generator-2510"><span class="linenos">2510</span></a> <span class="p">)</span> -</span><span id="Generator-2511"><a href="#Generator-2511"><span class="linenos">2511</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-2512"><a href="#Generator-2512"><span class="linenos">2512</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-2496"><a href="#Generator-2496"><span class="linenos">2496</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-2497"><a href="#Generator-2497"><span class="linenos">2497</span></a> <span class="k">return</span> <span class="s2">"BEGIN"</span> +</span><span id="Generator-2498"><a href="#Generator-2498"><span class="linenos">2498</span></a> +</span><span id="Generator-2499"><a href="#Generator-2499"><span class="linenos">2499</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-2500"><a href="#Generator-2500"><span class="linenos">2500</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-2501"><a href="#Generator-2501"><span class="linenos">2501</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-2502"><a href="#Generator-2502"><span class="linenos">2502</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-2503"><a href="#Generator-2503"><span class="linenos">2503</span></a> +</span><span id="Generator-2504"><a href="#Generator-2504"><span class="linenos">2504</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-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">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-2507"><a href="#Generator-2507"><span class="linenos">2507</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-2508"><a href="#Generator-2508"><span class="linenos">2508</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-2509"><a href="#Generator-2509"><span class="linenos">2509</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-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">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-2512"><a href="#Generator-2512"><span class="linenos">2512</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-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">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-2515"><a href="#Generator-2515"><span class="linenos">2515</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-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">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-2518"><a href="#Generator-2518"><span class="linenos">2518</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">add_column_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Generator-2519"><a href="#Generator-2519"><span class="linenos">2519</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-2520"><a href="#Generator-2520"><span class="linenos">2520</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-2521"><a href="#Generator-2521"><span class="linenos">2521</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-2522"><a href="#Generator-2522"><span class="linenos">2522</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-2523"><a href="#Generator-2523"><span class="linenos">2523</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator-2524"><a href="#Generator-2524"><span class="linenos">2524</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-2514"><a href="#Generator-2514"><span class="linenos">2514</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-2515"><a href="#Generator-2515"><span class="linenos">2515</span></a> <span class="k">if</span> <span class="n">dtype</span><span class="p">:</span> +</span><span id="Generator-2516"><a href="#Generator-2516"><span class="linenos">2516</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-2517"><a href="#Generator-2517"><span class="linenos">2517</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-2518"><a href="#Generator-2518"><span class="linenos">2518</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-2519"><a href="#Generator-2519"><span class="linenos">2519</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-2520"><a href="#Generator-2520"><span class="linenos">2520</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-2521"><a href="#Generator-2521"><span class="linenos">2521</span></a> +</span><span id="Generator-2522"><a href="#Generator-2522"><span class="linenos">2522</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-2523"><a href="#Generator-2523"><span class="linenos">2523</span></a> <span class="k">if</span> <span class="n">default</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="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-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="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-2527"><a href="#Generator-2527"><span class="linenos">2527</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-2528"><a href="#Generator-2528"><span class="linenos">2528</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-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">add_column_sql</span><span class="p">(</span><span class="bp">self</span><span 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-2531"><a href="#Generator-2531"><span class="linenos">2531</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">ALTER_TABLE_INCLUDE_COLUMN_KEYWORD</span><span class="p">:</span> -</span><span id="Generator-2532"><a href="#Generator-2532"><span class="linenos">2532</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span> -</span><span id="Generator-2533"><a href="#Generator-2533"><span class="linenos">2533</span></a> <span class="n">expression</span><span class="p">,</span> -</span><span id="Generator-2534"><a href="#Generator-2534"><span class="linenos">2534</span></a> <span class="n">key</span><span class="o">=</span><span class="s2">"actions"</span><span class="p">,</span> -</span><span id="Generator-2535"><a href="#Generator-2535"><span class="linenos">2535</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-2526"><a href="#Generator-2526"><span class="linenos">2526</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-2527"><a href="#Generator-2527"><span class="linenos">2527</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-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">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-2530"><a href="#Generator-2530"><span class="linenos">2530</span></a> +</span><span id="Generator-2531"><a href="#Generator-2531"><span class="linenos">2531</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-2532"><a href="#Generator-2532"><span class="linenos">2532</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-2533"><a href="#Generator-2533"><span class="linenos">2533</span></a> <span class="c1"># Remove db from tables</span> +</span><span id="Generator-2534"><a href="#Generator-2534"><span class="linenos">2534</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-2535"><a href="#Generator-2535"><span class="linenos">2535</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-2536"><a href="#Generator-2536"><span class="linenos">2536</span></a> <span class="p">)</span> -</span><span id="Generator-2537"><a href="#Generator-2537"><span class="linenos">2537</span></a> <span class="k">return</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="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-2538"><a href="#Generator-2538"><span class="linenos">2538</span></a> -</span><span id="Generator-2539"><a href="#Generator-2539"><span class="linenos">2539</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-2540"><a href="#Generator-2540"><span class="linenos">2540</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-2541"><a href="#Generator-2541"><span class="linenos">2541</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-2542"><a href="#Generator-2542"><span class="linenos">2542</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-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">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-2545"><a href="#Generator-2545"><span class="linenos">2545</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-2546"><a href="#Generator-2546"><span class="linenos">2546</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-2547"><a href="#Generator-2547"><span class="linenos">2547</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-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="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-2550"><a href="#Generator-2550"><span class="linenos">2550</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-2551"><a href="#Generator-2551"><span class="linenos">2551</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-2552"><a href="#Generator-2552"><span class="linenos">2552</span></a> -</span><span id="Generator-2553"><a href="#Generator-2553"><span class="linenos">2553</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-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">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-2556"><a href="#Generator-2556"><span class="linenos">2556</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-2557"><a href="#Generator-2557"><span class="linenos">2557</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-2558"><a href="#Generator-2558"><span class="linenos">2558</span></a> -</span><span id="Generator-2559"><a href="#Generator-2559"><span class="linenos">2559</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-2560"><a href="#Generator-2560"><span class="linenos">2560</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-2561"><a href="#Generator-2561"><span class="linenos">2561</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-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">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-2564"><a href="#Generator-2564"><span class="linenos">2564</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-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">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-2567"><a href="#Generator-2567"><span class="linenos">2567</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-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">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-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">sql</span><span class="p">(</span> -</span><span id="Generator-2571"><a href="#Generator-2571"><span class="linenos">2571</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">(</span> -</span><span id="Generator-2572"><a href="#Generator-2572"><span class="linenos">2572</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="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="p">),</span> -</span><span id="Generator-2573"><a href="#Generator-2573"><span class="linenos">2573</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-2574"><a href="#Generator-2574"><span class="linenos">2574</span></a> <span class="p">)</span> -</span><span id="Generator-2575"><a href="#Generator-2575"><span class="linenos">2575</span></a> <span class="p">)</span> -</span><span id="Generator-2576"><a href="#Generator-2576"><span class="linenos">2576</span></a> -</span><span id="Generator-2577"><a href="#Generator-2577"><span class="linenos">2577</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-2578"><a href="#Generator-2578"><span class="linenos">2578</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">STRICT_STRING_CONCAT</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">"safe"</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">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-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">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-2583"><a href="#Generator-2583"><span class="linenos">2583</span></a> <span class="n">l</span><span class="p">,</span> <span class="n">r</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">left</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">right</span> +</span><span id="Generator-2537"><a href="#Generator-2537"><span class="linenos">2537</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-2538"><a href="#Generator-2538"><span class="linenos">2538</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-2539"><a href="#Generator-2539"><span class="linenos">2539</span></a> +</span><span id="Generator-2540"><a href="#Generator-2540"><span class="linenos">2540</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-2541"><a href="#Generator-2541"><span class="linenos">2541</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-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">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-2544"><a href="#Generator-2544"><span class="linenos">2544</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">add_column_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Generator-2545"><a href="#Generator-2545"><span class="linenos">2545</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-2546"><a href="#Generator-2546"><span class="linenos">2546</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-2547"><a href="#Generator-2547"><span class="linenos">2547</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-2548"><a href="#Generator-2548"><span class="linenos">2548</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-2549"><a href="#Generator-2549"><span class="linenos">2549</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator-2550"><a href="#Generator-2550"><span class="linenos">2550</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-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="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-2553"><a href="#Generator-2553"><span class="linenos">2553</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-2554"><a href="#Generator-2554"><span class="linenos">2554</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-2555"><a href="#Generator-2555"><span class="linenos">2555</span></a> +</span><span id="Generator-2556"><a href="#Generator-2556"><span class="linenos">2556</span></a> <span class="k">def</span> <span class="nf">add_column_sql</span><span class="p">(</span><span class="bp">self</span><span 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-2557"><a href="#Generator-2557"><span class="linenos">2557</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">ALTER_TABLE_INCLUDE_COLUMN_KEYWORD</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">expressions</span><span class="p">(</span> +</span><span id="Generator-2559"><a href="#Generator-2559"><span class="linenos">2559</span></a> <span class="n">expression</span><span class="p">,</span> +</span><span id="Generator-2560"><a href="#Generator-2560"><span class="linenos">2560</span></a> <span class="n">key</span><span class="o">=</span><span class="s2">"actions"</span><span class="p">,</span> +</span><span id="Generator-2561"><a href="#Generator-2561"><span class="linenos">2561</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-2562"><a href="#Generator-2562"><span class="linenos">2562</span></a> <span class="p">)</span> +</span><span id="Generator-2563"><a href="#Generator-2563"><span class="linenos">2563</span></a> <span class="k">return</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="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-2564"><a href="#Generator-2564"><span class="linenos">2564</span></a> +</span><span id="Generator-2565"><a href="#Generator-2565"><span class="linenos">2565</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-2566"><a href="#Generator-2566"><span class="linenos">2566</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-2567"><a href="#Generator-2567"><span class="linenos">2567</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-2568"><a href="#Generator-2568"><span class="linenos">2568</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-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">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-2571"><a href="#Generator-2571"><span class="linenos">2571</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-2572"><a href="#Generator-2572"><span class="linenos">2572</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-2573"><a href="#Generator-2573"><span class="linenos">2573</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-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="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-2576"><a href="#Generator-2576"><span class="linenos">2576</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-2577"><a href="#Generator-2577"><span class="linenos">2577</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-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">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-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">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-2582"><a href="#Generator-2582"><span class="linenos">2582</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-2583"><a href="#Generator-2583"><span class="linenos">2583</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-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">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">SAFE_DIVISION</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">"safe"</span><span class="p">):</span> -</span><span id="Generator-2586"><a href="#Generator-2586"><span class="linenos">2586</span></a> <span class="n">r</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Nullif</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">r</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">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">number</span><span class="p">(</span><span class="mi">0</span><span class="p">)))</span> -</span><span id="Generator-2587"><a href="#Generator-2587"><span class="linenos">2587</span></a> -</span><span id="Generator-2588"><a href="#Generator-2588"><span class="linenos">2588</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">TYPED_DIVISION</span> <span class="ow">and</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">"typed"</span><span class="p">):</span> -</span><span id="Generator-2589"><a href="#Generator-2589"><span class="linenos">2589</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">l</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</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">FLOAT_TYPES</span><span class="p">)</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">r</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span> -</span><span id="Generator-2590"><a href="#Generator-2590"><span class="linenos">2590</span></a> <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">FLOAT_TYPES</span> -</span><span id="Generator-2591"><a href="#Generator-2591"><span class="linenos">2591</span></a> <span class="p">):</span> -</span><span id="Generator-2592"><a href="#Generator-2592"><span class="linenos">2592</span></a> <span class="n">l</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">l</span><span class="o">.</span><span class="n">copy</span><span class="p">(),</span> <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="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">DOUBLE</span><span class="p">))</span> -</span><span id="Generator-2593"><a href="#Generator-2593"><span class="linenos">2593</span></a> -</span><span id="Generator-2594"><a href="#Generator-2594"><span class="linenos">2594</span></a> <span class="k">elif</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">TYPED_DIVISION</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">"typed"</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="n">l</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</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">INTEGER_TYPES</span><span class="p">)</span> <span class="ow">and</span> <span class="n">r</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</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">INTEGER_TYPES</span><span class="p">):</span> -</span><span id="Generator-2596"><a href="#Generator-2596"><span class="linenos">2596</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-2597"><a href="#Generator-2597"><span class="linenos">2597</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span> -</span><span id="Generator-2598"><a href="#Generator-2598"><span class="linenos">2598</span></a> <span class="n">l</span> <span class="o">/</span> <span class="n">r</span><span class="p">,</span> -</span><span id="Generator-2599"><a href="#Generator-2599"><span class="linenos">2599</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="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">BIGINT</span><span class="p">,</span> -</span><span id="Generator-2600"><a href="#Generator-2600"><span class="linenos">2600</span></a> <span class="p">)</span> -</span><span id="Generator-2601"><a href="#Generator-2601"><span class="linenos">2601</span></a> <span class="p">)</span> +</span><span id="Generator-2585"><a href="#Generator-2585"><span class="linenos">2585</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-2586"><a href="#Generator-2586"><span class="linenos">2586</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-2587"><a href="#Generator-2587"><span class="linenos">2587</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-2588"><a href="#Generator-2588"><span class="linenos">2588</span></a> +</span><span id="Generator-2589"><a href="#Generator-2589"><span class="linenos">2589</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-2590"><a href="#Generator-2590"><span class="linenos">2590</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-2591"><a href="#Generator-2591"><span class="linenos">2591</span></a> +</span><span id="Generator-2592"><a href="#Generator-2592"><span class="linenos">2592</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-2593"><a href="#Generator-2593"><span class="linenos">2593</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-2594"><a href="#Generator-2594"><span class="linenos">2594</span></a> +</span><span id="Generator-2595"><a href="#Generator-2595"><span class="linenos">2595</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-2596"><a href="#Generator-2596"><span class="linenos">2596</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-2597"><a href="#Generator-2597"><span class="linenos">2597</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">(</span> +</span><span id="Generator-2598"><a href="#Generator-2598"><span class="linenos">2598</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="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="p">),</span> +</span><span id="Generator-2599"><a href="#Generator-2599"><span class="linenos">2599</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-2600"><a href="#Generator-2600"><span class="linenos">2600</span></a> <span class="p">)</span> +</span><span id="Generator-2601"><a href="#Generator-2601"><span class="linenos">2601</span></a> <span class="p">)</span> </span><span id="Generator-2602"><a href="#Generator-2602"><span class="linenos">2602</span></a> -</span><span id="Generator-2603"><a href="#Generator-2603"><span class="linenos">2603</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-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">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-2606"><a href="#Generator-2606"><span class="linenos">2606</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-2603"><a href="#Generator-2603"><span class="linenos">2603</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-2604"><a href="#Generator-2604"><span class="linenos">2604</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">STRICT_STRING_CONCAT</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">"safe"</span><span class="p">):</span> +</span><span id="Generator-2605"><a href="#Generator-2605"><span class="linenos">2605</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-2606"><a href="#Generator-2606"><span class="linenos">2606</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-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">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-2609"><a href="#Generator-2609"><span class="linenos">2609</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-2608"><a href="#Generator-2608"><span class="linenos">2608</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-2609"><a href="#Generator-2609"><span class="linenos">2609</span></a> <span class="n">l</span><span class="p">,</span> <span class="n">r</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">left</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">right</span> </span><span id="Generator-2610"><a href="#Generator-2610"><span class="linenos">2610</span></a> -</span><span id="Generator-2611"><a href="#Generator-2611"><span class="linenos">2611</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-2612"><a href="#Generator-2612"><span class="linenos">2612</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-2611"><a href="#Generator-2611"><span class="linenos">2611</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">SAFE_DIVISION</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">"safe"</span><span class="p">):</span> +</span><span id="Generator-2612"><a href="#Generator-2612"><span class="linenos">2612</span></a> <span class="n">r</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Nullif</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">r</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">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">number</span><span class="p">(</span><span class="mi">0</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">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-2615"><a href="#Generator-2615"><span class="linenos">2615</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-2616"><a href="#Generator-2616"><span class="linenos">2616</span></a> -</span><span id="Generator-2617"><a href="#Generator-2617"><span class="linenos">2617</span></a> <span class="k">def</span> <span class="nf">propertyeq_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">PropertyEQ</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2618"><a href="#Generator-2618"><span class="linenos">2618</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-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">dialect</span><span class="o">.</span><span class="n">TYPED_DIVISION</span> <span class="ow">and</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">"typed"</span><span class="p">):</span> +</span><span id="Generator-2615"><a href="#Generator-2615"><span class="linenos">2615</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">l</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</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">FLOAT_TYPES</span><span class="p">)</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">r</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span> +</span><span id="Generator-2616"><a href="#Generator-2616"><span class="linenos">2616</span></a> <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">FLOAT_TYPES</span> +</span><span id="Generator-2617"><a href="#Generator-2617"><span class="linenos">2617</span></a> <span class="p">):</span> +</span><span id="Generator-2618"><a href="#Generator-2618"><span class="linenos">2618</span></a> <span class="n">l</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">l</span><span class="o">.</span><span class="n">copy</span><span class="p">(),</span> <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="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">DOUBLE</span><span class="p">))</span> </span><span id="Generator-2619"><a href="#Generator-2619"><span class="linenos">2619</span></a> -</span><span id="Generator-2620"><a href="#Generator-2620"><span class="linenos">2620</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-2621"><a href="#Generator-2621"><span class="linenos">2621</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-2622"><a href="#Generator-2622"><span class="linenos">2622</span></a> -</span><span id="Generator-2623"><a href="#Generator-2623"><span class="linenos">2623</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-2624"><a href="#Generator-2624"><span class="linenos">2624</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-2625"><a href="#Generator-2625"><span class="linenos">2625</span></a> -</span><span id="Generator-2626"><a href="#Generator-2626"><span class="linenos">2626</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-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">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-2620"><a href="#Generator-2620"><span class="linenos">2620</span></a> <span class="k">elif</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">TYPED_DIVISION</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">"typed"</span><span class="p">):</span> +</span><span id="Generator-2621"><a href="#Generator-2621"><span class="linenos">2621</span></a> <span class="k">if</span> <span class="n">l</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</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">INTEGER_TYPES</span><span class="p">)</span> <span class="ow">and</span> <span class="n">r</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</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">INTEGER_TYPES</span><span class="p">):</span> +</span><span id="Generator-2622"><a href="#Generator-2622"><span class="linenos">2622</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-2623"><a href="#Generator-2623"><span class="linenos">2623</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span> +</span><span id="Generator-2624"><a href="#Generator-2624"><span class="linenos">2624</span></a> <span class="n">l</span> <span class="o">/</span> <span class="n">r</span><span class="p">,</span> +</span><span id="Generator-2625"><a href="#Generator-2625"><span class="linenos">2625</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="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">BIGINT</span><span class="p">,</span> +</span><span id="Generator-2626"><a href="#Generator-2626"><span class="linenos">2626</span></a> <span class="p">)</span> +</span><span id="Generator-2627"><a href="#Generator-2627"><span class="linenos">2627</span></a> <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">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-2630"><a href="#Generator-2630"><span class="linenos">2630</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-2631"><a href="#Generator-2631"><span class="linenos">2631</span></a> -</span><span id="Generator-2632"><a href="#Generator-2632"><span class="linenos">2632</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-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">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-2634"><a href="#Generator-2634"><span class="linenos">2634</span></a> -</span><span id="Generator-2635"><a href="#Generator-2635"><span class="linenos">2635</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-2636"><a href="#Generator-2636"><span class="linenos">2636</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-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">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-2639"><a href="#Generator-2639"><span class="linenos">2639</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-2640"><a href="#Generator-2640"><span class="linenos">2640</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-2641"><a href="#Generator-2641"><span class="linenos">2641</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-2642"><a href="#Generator-2642"><span class="linenos">2642</span></a> <span class="p">)</span> -</span><span id="Generator-2643"><a href="#Generator-2643"><span class="linenos">2643</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-2644"><a href="#Generator-2644"><span class="linenos">2644</span></a> -</span><span id="Generator-2645"><a href="#Generator-2645"><span class="linenos">2645</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-2646"><a href="#Generator-2646"><span class="linenos">2646</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-2647"><a href="#Generator-2647"><span class="linenos">2647</span></a> -</span><span id="Generator-2648"><a href="#Generator-2648"><span class="linenos">2648</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-2649"><a href="#Generator-2649"><span class="linenos">2649</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-2650"><a href="#Generator-2650"><span class="linenos">2650</span></a> -</span><span id="Generator-2651"><a href="#Generator-2651"><span class="linenos">2651</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-2652"><a href="#Generator-2652"><span class="linenos">2652</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-2653"><a href="#Generator-2653"><span class="linenos">2653</span></a> -</span><span id="Generator-2654"><a href="#Generator-2654"><span class="linenos">2654</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-2655"><a href="#Generator-2655"><span class="linenos">2655</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-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">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-2658"><a href="#Generator-2658"><span class="linenos">2658</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-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">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-2661"><a href="#Generator-2661"><span class="linenos">2661</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-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="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-2664"><a href="#Generator-2664"><span class="linenos">2664</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-2665"><a href="#Generator-2665"><span class="linenos">2665</span></a> -</span><span id="Generator-2666"><a href="#Generator-2666"><span class="linenos">2666</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-2667"><a href="#Generator-2667"><span class="linenos">2667</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-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="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-2670"><a href="#Generator-2670"><span class="linenos">2670</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-2671"><a href="#Generator-2671"><span class="linenos">2671</span></a> -</span><span id="Generator-2672"><a href="#Generator-2672"><span class="linenos">2672</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-2673"><a href="#Generator-2673"><span class="linenos">2673</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-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="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-2676"><a href="#Generator-2676"><span class="linenos">2676</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-2677"><a href="#Generator-2677"><span class="linenos">2677</span></a> -</span><span id="Generator-2678"><a href="#Generator-2678"><span class="linenos">2678</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-2679"><a href="#Generator-2679"><span class="linenos">2679</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-2680"><a href="#Generator-2680"><span class="linenos">2680</span></a> -</span><span id="Generator-2681"><a href="#Generator-2681"><span class="linenos">2681</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-2682"><a href="#Generator-2682"><span class="linenos">2682</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-2683"><a href="#Generator-2683"><span class="linenos">2683</span></a> -</span><span id="Generator-2684"><a href="#Generator-2684"><span class="linenos">2684</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-2685"><a href="#Generator-2685"><span class="linenos">2685</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-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="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-2688"><a href="#Generator-2688"><span class="linenos">2688</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><span id="Generator-2689"><a href="#Generator-2689"><span class="linenos">2689</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span> -</span><span id="Generator-2690"><a href="#Generator-2690"><span class="linenos">2690</span></a> -</span><span id="Generator-2691"><a href="#Generator-2691"><span class="linenos">2691</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">LOG_BASE_FIRST</span><span class="p">:</span> -</span><span id="Generator-2692"><a href="#Generator-2692"><span class="linenos">2692</span></a> <span class="n">this</span><span class="p">,</span> <span class="n">expr</span> <span class="o">=</span> <span class="n">expr</span><span class="p">,</span> <span class="n">this</span> -</span><span id="Generator-2693"><a href="#Generator-2693"><span class="linenos">2693</span></a> -</span><span id="Generator-2694"><a href="#Generator-2694"><span class="linenos">2694</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="n">this</span><span class="p">,</span> <span class="n">expr</span><span class="p">)</span> -</span><span id="Generator-2695"><a href="#Generator-2695"><span class="linenos">2695</span></a> -</span><span id="Generator-2696"><a href="#Generator-2696"><span class="linenos">2696</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-2697"><a href="#Generator-2697"><span class="linenos">2697</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-2698"><a href="#Generator-2698"><span class="linenos">2698</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-2699"><a href="#Generator-2699"><span class="linenos">2699</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-2700"><a href="#Generator-2700"><span class="linenos">2700</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-2701"><a href="#Generator-2701"><span class="linenos">2701</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-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">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-2704"><a href="#Generator-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">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-2705"><a href="#Generator-2705"><span class="linenos">2705</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-2629"><a href="#Generator-2629"><span class="linenos">2629</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-2630"><a href="#Generator-2630"><span class="linenos">2630</span></a> +</span><span id="Generator-2631"><a href="#Generator-2631"><span class="linenos">2631</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-2632"><a href="#Generator-2632"><span class="linenos">2632</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-2633"><a href="#Generator-2633"><span class="linenos">2633</span></a> +</span><span id="Generator-2634"><a href="#Generator-2634"><span class="linenos">2634</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-2635"><a href="#Generator-2635"><span class="linenos">2635</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-2636"><a href="#Generator-2636"><span class="linenos">2636</span></a> +</span><span id="Generator-2637"><a href="#Generator-2637"><span class="linenos">2637</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-2638"><a href="#Generator-2638"><span class="linenos">2638</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-2639"><a href="#Generator-2639"><span class="linenos">2639</span></a> +</span><span id="Generator-2640"><a href="#Generator-2640"><span class="linenos">2640</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-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">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-2642"><a href="#Generator-2642"><span class="linenos">2642</span></a> +</span><span id="Generator-2643"><a href="#Generator-2643"><span class="linenos">2643</span></a> <span class="k">def</span> <span class="nf">propertyeq_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">PropertyEQ</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2644"><a href="#Generator-2644"><span class="linenos">2644</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-2645"><a href="#Generator-2645"><span class="linenos">2645</span></a> +</span><span id="Generator-2646"><a href="#Generator-2646"><span class="linenos">2646</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-2647"><a href="#Generator-2647"><span class="linenos">2647</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-2648"><a href="#Generator-2648"><span class="linenos">2648</span></a> +</span><span id="Generator-2649"><a href="#Generator-2649"><span class="linenos">2649</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-2650"><a href="#Generator-2650"><span class="linenos">2650</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-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">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-2653"><a href="#Generator-2653"><span class="linenos">2653</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-2654"><a href="#Generator-2654"><span class="linenos">2654</span></a> +</span><span id="Generator-2655"><a href="#Generator-2655"><span class="linenos">2655</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-2656"><a href="#Generator-2656"><span class="linenos">2656</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-2657"><a href="#Generator-2657"><span class="linenos">2657</span></a> +</span><span id="Generator-2658"><a href="#Generator-2658"><span class="linenos">2658</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-2659"><a href="#Generator-2659"><span class="linenos">2659</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-2660"><a href="#Generator-2660"><span class="linenos">2660</span></a> +</span><span id="Generator-2661"><a href="#Generator-2661"><span class="linenos">2661</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-2662"><a href="#Generator-2662"><span class="linenos">2662</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-2663"><a href="#Generator-2663"><span class="linenos">2663</span></a> +</span><span id="Generator-2664"><a href="#Generator-2664"><span class="linenos">2664</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-2665"><a href="#Generator-2665"><span class="linenos">2665</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-2666"><a href="#Generator-2666"><span class="linenos">2666</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-2667"><a href="#Generator-2667"><span class="linenos">2667</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-2668"><a href="#Generator-2668"><span class="linenos">2668</span></a> <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="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-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="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-2672"><a href="#Generator-2672"><span class="linenos">2672</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-2673"><a href="#Generator-2673"><span class="linenos">2673</span></a> +</span><span id="Generator-2674"><a href="#Generator-2674"><span class="linenos">2674</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-2675"><a href="#Generator-2675"><span class="linenos">2675</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-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">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-2678"><a href="#Generator-2678"><span class="linenos">2678</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-2679"><a href="#Generator-2679"><span class="linenos">2679</span></a> +</span><span id="Generator-2680"><a href="#Generator-2680"><span class="linenos">2680</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-2681"><a href="#Generator-2681"><span class="linenos">2681</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-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="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-2684"><a href="#Generator-2684"><span class="linenos">2684</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-2685"><a href="#Generator-2685"><span class="linenos">2685</span></a> +</span><span id="Generator-2686"><a href="#Generator-2686"><span class="linenos">2686</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-2687"><a href="#Generator-2687"><span class="linenos">2687</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-2688"><a href="#Generator-2688"><span class="linenos">2688</span></a> +</span><span id="Generator-2689"><a href="#Generator-2689"><span class="linenos">2689</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-2690"><a href="#Generator-2690"><span class="linenos">2690</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-2691"><a href="#Generator-2691"><span class="linenos">2691</span></a> +</span><span id="Generator-2692"><a href="#Generator-2692"><span class="linenos">2692</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-2693"><a href="#Generator-2693"><span class="linenos">2693</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-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="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-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">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-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">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-2699"><a href="#Generator-2699"><span class="linenos">2699</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-2700"><a href="#Generator-2700"><span class="linenos">2700</span></a> +</span><span id="Generator-2701"><a href="#Generator-2701"><span class="linenos">2701</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-2702"><a href="#Generator-2702"><span class="linenos">2702</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-2703"><a href="#Generator-2703"><span class="linenos">2703</span></a> +</span><span id="Generator-2704"><a href="#Generator-2704"><span class="linenos">2704</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-2705"><a href="#Generator-2705"><span class="linenos">2705</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-2706"><a href="#Generator-2706"><span class="linenos">2706</span></a> -</span><span id="Generator-2707"><a href="#Generator-2707"><span class="linenos">2707</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-2708"><a href="#Generator-2708"><span class="linenos">2708</span></a> <span class="n">args</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="Generator-2707"><a href="#Generator-2707"><span class="linenos">2707</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-2708"><a href="#Generator-2708"><span class="linenos">2708</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-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">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-2711"><a href="#Generator-2711"><span class="linenos">2711</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-2710"><a href="#Generator-2710"><span class="linenos">2710</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-2711"><a href="#Generator-2711"><span class="linenos">2711</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-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">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-2714"><a href="#Generator-2714"><span class="linenos">2714</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-2715"><a href="#Generator-2715"><span class="linenos">2715</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-2716"><a href="#Generator-2716"><span class="linenos">2716</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-2717"><a href="#Generator-2717"><span class="linenos">2717</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-2718"><a href="#Generator-2718"><span class="linenos">2718</span></a> -</span><span id="Generator-2719"><a href="#Generator-2719"><span class="linenos">2719</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-2720"><a href="#Generator-2720"><span class="linenos">2720</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-2721"><a href="#Generator-2721"><span class="linenos">2721</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator-2722"><a href="#Generator-2722"><span class="linenos">2722</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-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">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-2725"><a href="#Generator-2725"><span class="linenos">2725</span></a> -</span><span id="Generator-2726"><a href="#Generator-2726"><span class="linenos">2726</span></a> <span class="k">def</span> <span class="nf">func</span><span class="p">(</span> -</span><span id="Generator-2727"><a href="#Generator-2727"><span class="linenos">2727</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Generator-2728"><a href="#Generator-2728"><span class="linenos">2728</span></a> <span class="n">name</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> -</span><span id="Generator-2729"><a href="#Generator-2729"><span class="linenos">2729</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-2730"><a href="#Generator-2730"><span class="linenos">2730</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-2731"><a href="#Generator-2731"><span class="linenos">2731</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-2732"><a href="#Generator-2732"><span class="linenos">2732</span></a> <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="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-2734"><a href="#Generator-2734"><span class="linenos">2734</span></a> -</span><span id="Generator-2735"><a href="#Generator-2735"><span class="linenos">2735</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-2736"><a href="#Generator-2736"><span class="linenos">2736</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-2737"><a href="#Generator-2737"><span class="linenos">2737</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-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">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-2739"><a href="#Generator-2739"><span class="linenos">2739</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-2740"><a href="#Generator-2740"><span class="linenos">2740</span></a> -</span><span id="Generator-2741"><a href="#Generator-2741"><span class="linenos">2741</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-2742"><a href="#Generator-2742"><span class="linenos">2742</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-2743"><a href="#Generator-2743"><span class="linenos">2743</span></a> -</span><span id="Generator-2744"><a href="#Generator-2744"><span class="linenos">2744</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-2745"><a href="#Generator-2745"><span class="linenos">2745</span></a> <span class="k">return</span> <span class="n">format_time</span><span class="p">(</span> -</span><span id="Generator-2746"><a href="#Generator-2746"><span class="linenos">2746</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><span id="Generator-2747"><a href="#Generator-2747"><span class="linenos">2747</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">INVERSE_TIME_MAPPING</span><span class="p">,</span> -</span><span id="Generator-2748"><a href="#Generator-2748"><span class="linenos">2748</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">INVERSE_TIME_TRIE</span><span class="p">,</span> -</span><span id="Generator-2749"><a href="#Generator-2749"><span class="linenos">2749</span></a> <span class="p">)</span> -</span><span id="Generator-2750"><a href="#Generator-2750"><span class="linenos">2750</span></a> -</span><span id="Generator-2751"><a href="#Generator-2751"><span class="linenos">2751</span></a> <span class="k">def</span> <span class="nf">expressions</span><span class="p">(</span> -</span><span id="Generator-2752"><a href="#Generator-2752"><span class="linenos">2752</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Generator-2753"><a href="#Generator-2753"><span class="linenos">2753</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-2754"><a href="#Generator-2754"><span class="linenos">2754</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-2755"><a href="#Generator-2755"><span class="linenos">2755</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-2756"><a href="#Generator-2756"><span class="linenos">2756</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-2757"><a href="#Generator-2757"><span class="linenos">2757</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-2758"><a href="#Generator-2758"><span class="linenos">2758</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-2759"><a href="#Generator-2759"><span class="linenos">2759</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-2760"><a href="#Generator-2760"><span class="linenos">2760</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-2761"><a href="#Generator-2761"><span class="linenos">2761</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2762"><a href="#Generator-2762"><span class="linenos">2762</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-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="k">if</span> <span class="ow">not</span> <span class="n">expressions</span><span class="p">:</span> -</span><span id="Generator-2765"><a href="#Generator-2765"><span class="linenos">2765</span></a> <span class="k">return</span> <span class="s2">""</span> +</span><span id="Generator-2713"><a href="#Generator-2713"><span class="linenos">2713</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-2714"><a href="#Generator-2714"><span class="linenos">2714</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><span id="Generator-2715"><a href="#Generator-2715"><span class="linenos">2715</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span> +</span><span id="Generator-2716"><a href="#Generator-2716"><span class="linenos">2716</span></a> +</span><span id="Generator-2717"><a href="#Generator-2717"><span class="linenos">2717</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">LOG_BASE_FIRST</span><span class="p">:</span> +</span><span id="Generator-2718"><a href="#Generator-2718"><span class="linenos">2718</span></a> <span class="n">this</span><span class="p">,</span> <span class="n">expr</span> <span class="o">=</span> <span class="n">expr</span><span class="p">,</span> <span class="n">this</span> +</span><span id="Generator-2719"><a href="#Generator-2719"><span class="linenos">2719</span></a> +</span><span id="Generator-2720"><a href="#Generator-2720"><span class="linenos">2720</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="n">this</span><span class="p">,</span> <span class="n">expr</span><span class="p">)</span> +</span><span id="Generator-2721"><a href="#Generator-2721"><span class="linenos">2721</span></a> +</span><span id="Generator-2722"><a href="#Generator-2722"><span class="linenos">2722</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-2723"><a href="#Generator-2723"><span class="linenos">2723</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-2724"><a href="#Generator-2724"><span class="linenos">2724</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-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">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-2727"><a href="#Generator-2727"><span class="linenos">2727</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-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">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-2730"><a href="#Generator-2730"><span class="linenos">2730</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-2731"><a href="#Generator-2731"><span class="linenos">2731</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-2732"><a href="#Generator-2732"><span class="linenos">2732</span></a> +</span><span id="Generator-2733"><a href="#Generator-2733"><span class="linenos">2733</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-2734"><a href="#Generator-2734"><span class="linenos">2734</span></a> <span class="n">args</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="Generator-2735"><a href="#Generator-2735"><span class="linenos">2735</span></a> +</span><span id="Generator-2736"><a href="#Generator-2736"><span class="linenos">2736</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-2737"><a href="#Generator-2737"><span class="linenos">2737</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-2738"><a href="#Generator-2738"><span class="linenos">2738</span></a> +</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">arg_value</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span> +</span><span id="Generator-2740"><a href="#Generator-2740"><span class="linenos">2740</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-2741"><a href="#Generator-2741"><span class="linenos">2741</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-2742"><a href="#Generator-2742"><span class="linenos">2742</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-2743"><a href="#Generator-2743"><span class="linenos">2743</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-2744"><a href="#Generator-2744"><span class="linenos">2744</span></a> +</span><span id="Generator-2745"><a href="#Generator-2745"><span class="linenos">2745</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-2746"><a href="#Generator-2746"><span class="linenos">2746</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-2747"><a href="#Generator-2747"><span class="linenos">2747</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator-2748"><a href="#Generator-2748"><span class="linenos">2748</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-2749"><a href="#Generator-2749"><span class="linenos">2749</span></a> +</span><span id="Generator-2750"><a href="#Generator-2750"><span class="linenos">2750</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-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">func</span><span class="p">(</span> +</span><span id="Generator-2753"><a href="#Generator-2753"><span class="linenos">2753</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Generator-2754"><a href="#Generator-2754"><span class="linenos">2754</span></a> <span class="n">name</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> +</span><span id="Generator-2755"><a href="#Generator-2755"><span class="linenos">2755</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-2756"><a href="#Generator-2756"><span class="linenos">2756</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-2757"><a href="#Generator-2757"><span class="linenos">2757</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-2758"><a href="#Generator-2758"><span class="linenos">2758</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2759"><a href="#Generator-2759"><span class="linenos">2759</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-2760"><a href="#Generator-2760"><span class="linenos">2760</span></a> +</span><span id="Generator-2761"><a href="#Generator-2761"><span class="linenos">2761</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-2762"><a href="#Generator-2762"><span class="linenos">2762</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-2763"><a href="#Generator-2763"><span class="linenos">2763</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-2764"><a href="#Generator-2764"><span class="linenos">2764</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-2765"><a href="#Generator-2765"><span class="linenos">2765</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-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">if</span> <span class="n">flat</span><span class="p">:</span> -</span><span id="Generator-2768"><a href="#Generator-2768"><span class="linenos">2768</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-2767"><a href="#Generator-2767"><span class="linenos">2767</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-2768"><a href="#Generator-2768"><span class="linenos">2768</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-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">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-2771"><a href="#Generator-2771"><span class="linenos">2771</span></a> -</span><span id="Generator-2772"><a href="#Generator-2772"><span class="linenos">2772</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-2773"><a href="#Generator-2773"><span class="linenos">2773</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-2774"><a href="#Generator-2774"><span class="linenos">2774</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-2775"><a href="#Generator-2775"><span class="linenos">2775</span></a> -</span><span id="Generator-2776"><a href="#Generator-2776"><span class="linenos">2776</span></a> <span class="n">result_sqls</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="Generator-2777"><a href="#Generator-2777"><span class="linenos">2777</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-2778"><a href="#Generator-2778"><span class="linenos">2778</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-2779"><a href="#Generator-2779"><span class="linenos">2779</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-2780"><a href="#Generator-2780"><span class="linenos">2780</span></a> <span class="k">continue</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="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-2783"><a href="#Generator-2783"><span class="linenos">2783</span></a> -</span><span id="Generator-2784"><a href="#Generator-2784"><span class="linenos">2784</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-2785"><a href="#Generator-2785"><span class="linenos">2785</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-2786"><a href="#Generator-2786"><span class="linenos">2786</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-2787"><a href="#Generator-2787"><span class="linenos">2787</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator-2788"><a href="#Generator-2788"><span class="linenos">2788</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-2789"><a href="#Generator-2789"><span class="linenos">2789</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-2790"><a href="#Generator-2790"><span class="linenos">2790</span></a> <span class="p">)</span> -</span><span id="Generator-2791"><a href="#Generator-2791"><span class="linenos">2791</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator-2792"><a href="#Generator-2792"><span class="linenos">2792</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-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="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-2795"><a href="#Generator-2795"><span class="linenos">2795</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-2796"><a href="#Generator-2796"><span class="linenos">2796</span></a> -</span><span id="Generator-2797"><a href="#Generator-2797"><span class="linenos">2797</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-2798"><a href="#Generator-2798"><span class="linenos">2798</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-2799"><a href="#Generator-2799"><span class="linenos">2799</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-2800"><a href="#Generator-2800"><span class="linenos">2800</span></a> <span class="k">if</span> <span class="n">flat</span><span class="p">:</span> -</span><span id="Generator-2801"><a href="#Generator-2801"><span class="linenos">2801</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-2802"><a href="#Generator-2802"><span class="linenos">2802</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-2803"><a href="#Generator-2803"><span class="linenos">2803</span></a> -</span><span id="Generator-2804"><a href="#Generator-2804"><span class="linenos">2804</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-2805"><a href="#Generator-2805"><span class="linenos">2805</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-2806"><a href="#Generator-2806"><span class="linenos">2806</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-2807"><a href="#Generator-2807"><span class="linenos">2807</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-2808"><a href="#Generator-2808"><span class="linenos">2808</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-2770"><a href="#Generator-2770"><span class="linenos">2770</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-2771"><a href="#Generator-2771"><span class="linenos">2771</span></a> <span class="k">return</span> <span class="n">format_time</span><span class="p">(</span> +</span><span id="Generator-2772"><a href="#Generator-2772"><span class="linenos">2772</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><span id="Generator-2773"><a href="#Generator-2773"><span class="linenos">2773</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">INVERSE_TIME_MAPPING</span><span class="p">,</span> +</span><span id="Generator-2774"><a href="#Generator-2774"><span class="linenos">2774</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">INVERSE_TIME_TRIE</span><span class="p">,</span> +</span><span id="Generator-2775"><a href="#Generator-2775"><span class="linenos">2775</span></a> <span class="p">)</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">expressions</span><span class="p">(</span> +</span><span id="Generator-2778"><a href="#Generator-2778"><span class="linenos">2778</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Generator-2779"><a href="#Generator-2779"><span class="linenos">2779</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-2780"><a href="#Generator-2780"><span class="linenos">2780</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-2781"><a href="#Generator-2781"><span class="linenos">2781</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-2782"><a href="#Generator-2782"><span class="linenos">2782</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-2783"><a href="#Generator-2783"><span class="linenos">2783</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-2784"><a href="#Generator-2784"><span class="linenos">2784</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-2785"><a href="#Generator-2785"><span class="linenos">2785</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-2786"><a href="#Generator-2786"><span class="linenos">2786</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-2787"><a href="#Generator-2787"><span class="linenos">2787</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2788"><a href="#Generator-2788"><span class="linenos">2788</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-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">if</span> <span class="ow">not</span> <span class="n">expressions</span><span class="p">:</span> +</span><span id="Generator-2791"><a href="#Generator-2791"><span class="linenos">2791</span></a> <span class="k">return</span> <span class="s2">""</span> +</span><span id="Generator-2792"><a href="#Generator-2792"><span class="linenos">2792</span></a> +</span><span id="Generator-2793"><a href="#Generator-2793"><span class="linenos">2793</span></a> <span class="k">if</span> <span class="n">flat</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="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-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="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-2797"><a href="#Generator-2797"><span class="linenos">2797</span></a> +</span><span id="Generator-2798"><a href="#Generator-2798"><span class="linenos">2798</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-2799"><a href="#Generator-2799"><span class="linenos">2799</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-2800"><a href="#Generator-2800"><span class="linenos">2800</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-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="n">result_sqls</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="Generator-2803"><a href="#Generator-2803"><span class="linenos">2803</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-2804"><a href="#Generator-2804"><span class="linenos">2804</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-2805"><a href="#Generator-2805"><span class="linenos">2805</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-2806"><a href="#Generator-2806"><span class="linenos">2806</span></a> <span class="k">continue</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="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-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">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">Union</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-2811"><a href="#Generator-2811"><span class="linenos">2811</span></a> <span class="n">this</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="bp">self</span><span 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">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-2812"><a href="#Generator-2812"><span class="linenos">2812</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-2813"><a href="#Generator-2813"><span class="linenos">2813</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-2814"><a href="#Generator-2814"><span class="linenos">2814</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-2815"><a href="#Generator-2815"><span class="linenos">2815</span></a> <span class="p">)</span> -</span><span id="Generator-2816"><a href="#Generator-2816"><span class="linenos">2816</span></a> -</span><span id="Generator-2817"><a href="#Generator-2817"><span class="linenos">2817</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-2818"><a href="#Generator-2818"><span class="linenos">2818</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-2810"><a href="#Generator-2810"><span class="linenos">2810</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-2811"><a href="#Generator-2811"><span class="linenos">2811</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-2812"><a href="#Generator-2812"><span class="linenos">2812</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-2813"><a href="#Generator-2813"><span class="linenos">2813</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator-2814"><a href="#Generator-2814"><span class="linenos">2814</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-2815"><a href="#Generator-2815"><span class="linenos">2815</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-2816"><a href="#Generator-2816"><span class="linenos">2816</span></a> <span class="p">)</span> +</span><span id="Generator-2817"><a href="#Generator-2817"><span class="linenos">2817</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator-2818"><a href="#Generator-2818"><span class="linenos">2818</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-2819"><a href="#Generator-2819"><span class="linenos">2819</span></a> -</span><span id="Generator-2820"><a href="#Generator-2820"><span class="linenos">2820</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-2821"><a href="#Generator-2821"><span class="linenos">2821</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-2820"><a href="#Generator-2820"><span class="linenos">2820</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-2821"><a href="#Generator-2821"><span class="linenos">2821</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-2822"><a href="#Generator-2822"><span class="linenos">2822</span></a> -</span><span id="Generator-2823"><a href="#Generator-2823"><span class="linenos">2823</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-2824"><a href="#Generator-2824"><span class="linenos">2824</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-2825"><a href="#Generator-2825"><span class="linenos">2825</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-2826"><a href="#Generator-2826"><span class="linenos">2826</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Generator-2827"><a href="#Generator-2827"><span class="linenos">2827</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-2828"><a href="#Generator-2828"><span class="linenos">2828</span></a> <span class="p">)</span> -</span><span id="Generator-2829"><a href="#Generator-2829"><span class="linenos">2829</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-2830"><a href="#Generator-2830"><span class="linenos">2830</span></a> -</span><span id="Generator-2831"><a href="#Generator-2831"><span class="linenos">2831</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-2832"><a href="#Generator-2832"><span class="linenos">2832</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-2833"><a href="#Generator-2833"><span class="linenos">2833</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-2834"><a href="#Generator-2834"><span class="linenos">2834</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-2823"><a href="#Generator-2823"><span class="linenos">2823</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-2824"><a href="#Generator-2824"><span class="linenos">2824</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-2825"><a href="#Generator-2825"><span class="linenos">2825</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-2826"><a href="#Generator-2826"><span class="linenos">2826</span></a> <span class="k">if</span> <span class="n">flat</span><span class="p">:</span> +</span><span id="Generator-2827"><a href="#Generator-2827"><span class="linenos">2827</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-2828"><a href="#Generator-2828"><span class="linenos">2828</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-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="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-2831"><a href="#Generator-2831"><span class="linenos">2831</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-2832"><a href="#Generator-2832"><span class="linenos">2832</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-2833"><a href="#Generator-2833"><span class="linenos">2833</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-2834"><a href="#Generator-2834"><span class="linenos">2834</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-2835"><a href="#Generator-2835"><span class="linenos">2835</span></a> -</span><span id="Generator-2836"><a href="#Generator-2836"><span class="linenos">2836</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-2837"><a href="#Generator-2837"><span class="linenos">2837</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-2838"><a href="#Generator-2838"><span class="linenos">2838</span></a> -</span><span id="Generator-2839"><a href="#Generator-2839"><span class="linenos">2839</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-2840"><a href="#Generator-2840"><span class="linenos">2840</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-2841"><a href="#Generator-2841"><span class="linenos">2841</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-2842"><a href="#Generator-2842"><span class="linenos">2842</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-2843"><a href="#Generator-2843"><span class="linenos">2843</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-2844"><a href="#Generator-2844"><span class="linenos">2844</span></a> -</span><span id="Generator-2845"><a href="#Generator-2845"><span class="linenos">2845</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-2846"><a href="#Generator-2846"><span class="linenos">2846</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-2847"><a href="#Generator-2847"><span class="linenos">2847</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-2848"><a href="#Generator-2848"><span class="linenos">2848</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-2849"><a href="#Generator-2849"><span class="linenos">2849</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-2850"><a href="#Generator-2850"><span class="linenos">2850</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-2851"><a href="#Generator-2851"><span class="linenos">2851</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-2852"><a href="#Generator-2852"><span class="linenos">2852</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-2853"><a href="#Generator-2853"><span class="linenos">2853</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator-2854"><a href="#Generator-2854"><span class="linenos">2854</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-2855"><a href="#Generator-2855"><span class="linenos">2855</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator-2856"><a href="#Generator-2856"><span class="linenos">2856</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-2857"><a href="#Generator-2857"><span class="linenos">2857</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-2858"><a href="#Generator-2858"><span class="linenos">2858</span></a> -</span><span id="Generator-2859"><a href="#Generator-2859"><span class="linenos">2859</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-2860"><a href="#Generator-2860"><span class="linenos">2860</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-2861"><a href="#Generator-2861"><span class="linenos">2861</span></a> <span class="n">table_alias</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator-2862"><a href="#Generator-2862"><span class="linenos">2862</span></a> -</span><span id="Generator-2863"><a href="#Generator-2863"><span class="linenos">2863</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-2864"><a href="#Generator-2864"><span class="linenos">2864</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-2865"><a href="#Generator-2865"><span class="linenos">2865</span></a> <span class="c1"># T-SQL syntax is MERGE ... <target_table> [WITH (<merge_hint>)] [[AS] table_alias]</span> -</span><span id="Generator-2866"><a href="#Generator-2866"><span class="linenos">2866</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-2867"><a href="#Generator-2867"><span class="linenos">2867</span></a> -</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">table</span><span class="p">)</span> -</span><span id="Generator-2869"><a href="#Generator-2869"><span class="linenos">2869</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-2870"><a href="#Generator-2870"><span class="linenos">2870</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-2871"><a href="#Generator-2871"><span class="linenos">2871</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-2872"><a href="#Generator-2872"><span class="linenos">2872</span></a> -</span><span id="Generator-2873"><a href="#Generator-2873"><span class="linenos">2873</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><span id="Generator-2874"><a href="#Generator-2874"><span class="linenos">2874</span></a> <span class="n">expression</span><span class="p">,</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-2875"><a href="#Generator-2875"><span class="linenos">2875</span></a> <span class="p">)</span> -</span><span id="Generator-2876"><a href="#Generator-2876"><span class="linenos">2876</span></a> -</span><span id="Generator-2877"><a href="#Generator-2877"><span class="linenos">2877</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-2878"><a href="#Generator-2878"><span class="linenos">2878</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-2879"><a href="#Generator-2879"><span class="linenos">2879</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-2880"><a href="#Generator-2880"><span class="linenos">2880</span></a> -</span><span id="Generator-2881"><a href="#Generator-2881"><span class="linenos">2881</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-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">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-2884"><a href="#Generator-2884"><span class="linenos">2884</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-2885"><a href="#Generator-2885"><span class="linenos">2885</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-2886"><a href="#Generator-2886"><span class="linenos">2886</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-2887"><a href="#Generator-2887"><span class="linenos">2887</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-2888"><a href="#Generator-2888"><span class="linenos">2888</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-2889"><a href="#Generator-2889"><span class="linenos">2889</span></a> -</span><span id="Generator-2890"><a href="#Generator-2890"><span class="linenos">2890</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-2891"><a href="#Generator-2891"><span class="linenos">2891</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-2892"><a href="#Generator-2892"><span class="linenos">2892</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-2893"><a href="#Generator-2893"><span class="linenos">2893</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-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="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-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">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-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">'value'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2836"><a href="#Generator-2836"><span class="linenos">2836</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">Union</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-2837"><a href="#Generator-2837"><span class="linenos">2837</span></a> <span class="n">this</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="bp">self</span><span 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">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-2838"><a href="#Generator-2838"><span class="linenos">2838</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-2839"><a href="#Generator-2839"><span class="linenos">2839</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-2840"><a href="#Generator-2840"><span class="linenos">2840</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-2841"><a href="#Generator-2841"><span class="linenos">2841</span></a> <span class="p">)</span> +</span><span id="Generator-2842"><a href="#Generator-2842"><span class="linenos">2842</span></a> +</span><span id="Generator-2843"><a href="#Generator-2843"><span class="linenos">2843</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-2844"><a href="#Generator-2844"><span class="linenos">2844</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-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="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-2847"><a href="#Generator-2847"><span class="linenos">2847</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-2848"><a href="#Generator-2848"><span class="linenos">2848</span></a> +</span><span id="Generator-2849"><a href="#Generator-2849"><span class="linenos">2849</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-2850"><a href="#Generator-2850"><span class="linenos">2850</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-2851"><a href="#Generator-2851"><span class="linenos">2851</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-2852"><a href="#Generator-2852"><span class="linenos">2852</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Generator-2853"><a href="#Generator-2853"><span class="linenos">2853</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-2854"><a href="#Generator-2854"><span class="linenos">2854</span></a> <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="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-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">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-2858"><a href="#Generator-2858"><span class="linenos">2858</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-2859"><a href="#Generator-2859"><span class="linenos">2859</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-2860"><a href="#Generator-2860"><span class="linenos">2860</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-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="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-2863"><a href="#Generator-2863"><span class="linenos">2863</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-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">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-2866"><a href="#Generator-2866"><span class="linenos">2866</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-2867"><a href="#Generator-2867"><span class="linenos">2867</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-2868"><a href="#Generator-2868"><span class="linenos">2868</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-2869"><a href="#Generator-2869"><span class="linenos">2869</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-2870"><a href="#Generator-2870"><span class="linenos">2870</span></a> +</span><span id="Generator-2871"><a href="#Generator-2871"><span class="linenos">2871</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-2872"><a href="#Generator-2872"><span class="linenos">2872</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-2873"><a href="#Generator-2873"><span class="linenos">2873</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-2874"><a href="#Generator-2874"><span class="linenos">2874</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-2875"><a href="#Generator-2875"><span class="linenos">2875</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-2876"><a href="#Generator-2876"><span class="linenos">2876</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-2877"><a href="#Generator-2877"><span class="linenos">2877</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-2878"><a href="#Generator-2878"><span class="linenos">2878</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-2879"><a href="#Generator-2879"><span class="linenos">2879</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator-2880"><a href="#Generator-2880"><span class="linenos">2880</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-2881"><a href="#Generator-2881"><span class="linenos">2881</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator-2882"><a href="#Generator-2882"><span class="linenos">2882</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-2883"><a href="#Generator-2883"><span class="linenos">2883</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-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">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-2886"><a href="#Generator-2886"><span class="linenos">2886</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-2887"><a href="#Generator-2887"><span class="linenos">2887</span></a> <span class="n">table_alias</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator-2888"><a href="#Generator-2888"><span class="linenos">2888</span></a> +</span><span id="Generator-2889"><a href="#Generator-2889"><span class="linenos">2889</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-2890"><a href="#Generator-2890"><span class="linenos">2890</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-2891"><a href="#Generator-2891"><span class="linenos">2891</span></a> <span class="c1"># T-SQL syntax is MERGE ... <target_table> [WITH (<merge_hint>)] [[AS] table_alias]</span> +</span><span id="Generator-2892"><a href="#Generator-2892"><span class="linenos">2892</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-2893"><a href="#Generator-2893"><span class="linenos">2893</span></a> +</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">table</span><span class="p">)</span> +</span><span id="Generator-2895"><a href="#Generator-2895"><span class="linenos">2895</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-2896"><a href="#Generator-2896"><span class="linenos">2896</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-2897"><a href="#Generator-2897"><span class="linenos">2897</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-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">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-2900"><a href="#Generator-2900"><span class="linenos">2900</span></a> <span class="k">return</span> <span class="s2">""</span> -</span><span id="Generator-2901"><a href="#Generator-2901"><span class="linenos">2901</span></a> -</span><span id="Generator-2902"><a href="#Generator-2902"><span class="linenos">2902</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-2903"><a href="#Generator-2903"><span class="linenos">2903</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-2904"><a href="#Generator-2904"><span class="linenos">2904</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-2905"><a href="#Generator-2905"><span class="linenos">2905</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-2906"><a href="#Generator-2906"><span class="linenos">2906</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-2907"><a href="#Generator-2907"><span class="linenos">2907</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-2899"><a href="#Generator-2899"><span class="linenos">2899</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><span id="Generator-2900"><a href="#Generator-2900"><span class="linenos">2900</span></a> <span class="n">expression</span><span class="p">,</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-2901"><a href="#Generator-2901"><span class="linenos">2901</span></a> <span class="p">)</span> +</span><span id="Generator-2902"><a href="#Generator-2902"><span class="linenos">2902</span></a> +</span><span id="Generator-2903"><a href="#Generator-2903"><span class="linenos">2903</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-2904"><a href="#Generator-2904"><span class="linenos">2904</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-2905"><a href="#Generator-2905"><span class="linenos">2905</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-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">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-2908"><a href="#Generator-2908"><span class="linenos">2908</span></a> -</span><span id="Generator-2909"><a href="#Generator-2909"><span class="linenos">2909</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-2909"><a href="#Generator-2909"><span class="linenos">2909</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-2910"><a href="#Generator-2910"><span class="linenos">2910</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-2911"><a href="#Generator-2911"><span class="linenos">2911</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-2912"><a href="#Generator-2912"><span class="linenos">2912</span></a> -</span><span id="Generator-2913"><a href="#Generator-2913"><span class="linenos">2913</span></a> <span class="k">if</span> <span class="n">having</span><span class="p">:</span> -</span><span id="Generator-2914"><a href="#Generator-2914"><span class="linenos">2914</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-2911"><a href="#Generator-2911"><span class="linenos">2911</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-2912"><a href="#Generator-2912"><span class="linenos">2912</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-2913"><a href="#Generator-2913"><span class="linenos">2913</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-2914"><a href="#Generator-2914"><span class="linenos">2914</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-2915"><a href="#Generator-2915"><span class="linenos">2915</span></a> -</span><span id="Generator-2916"><a href="#Generator-2916"><span class="linenos">2916</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-2917"><a href="#Generator-2917"><span class="linenos">2917</span></a> -</span><span id="Generator-2918"><a href="#Generator-2918"><span class="linenos">2918</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-2919"><a href="#Generator-2919"><span class="linenos">2919</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-2920"><a href="#Generator-2920"><span class="linenos">2920</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-2921"><a href="#Generator-2921"><span class="linenos">2921</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-2922"><a href="#Generator-2922"><span class="linenos">2922</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-2923"><a href="#Generator-2923"><span class="linenos">2923</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-2924"><a href="#Generator-2924"><span class="linenos">2924</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-2925"><a href="#Generator-2925"><span class="linenos">2925</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-2926"><a href="#Generator-2926"><span class="linenos">2926</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-2927"><a href="#Generator-2927"><span class="linenos">2927</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-2928"><a href="#Generator-2928"><span class="linenos">2928</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-2929"><a href="#Generator-2929"><span class="linenos">2929</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-2930"><a href="#Generator-2930"><span class="linenos">2930</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-2931"><a href="#Generator-2931"><span class="linenos">2931</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-2932"><a href="#Generator-2932"><span class="linenos">2932</span></a> -</span><span id="Generator-2933"><a href="#Generator-2933"><span class="linenos">2933</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-2934"><a href="#Generator-2934"><span class="linenos">2934</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-2935"><a href="#Generator-2935"><span class="linenos">2935</span></a> <span class="k">if</span> <span class="n">key_block_size</span><span class="p">:</span> -</span><span id="Generator-2936"><a href="#Generator-2936"><span class="linenos">2936</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-2937"><a href="#Generator-2937"><span class="linenos">2937</span></a> -</span><span id="Generator-2938"><a href="#Generator-2938"><span class="linenos">2938</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-2939"><a href="#Generator-2939"><span class="linenos">2939</span></a> <span class="k">if</span> <span class="n">using</span><span class="p">:</span> -</span><span id="Generator-2940"><a href="#Generator-2940"><span class="linenos">2940</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-2916"><a href="#Generator-2916"><span class="linenos">2916</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-2917"><a href="#Generator-2917"><span class="linenos">2917</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-2918"><a href="#Generator-2918"><span class="linenos">2918</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-2919"><a href="#Generator-2919"><span class="linenos">2919</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-2920"><a href="#Generator-2920"><span class="linenos">2920</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-2921"><a href="#Generator-2921"><span class="linenos">2921</span></a> +</span><span id="Generator-2922"><a href="#Generator-2922"><span class="linenos">2922</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-2923"><a href="#Generator-2923"><span class="linenos">2923</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-2924"><a href="#Generator-2924"><span class="linenos">2924</span></a> +</span><span id="Generator-2925"><a href="#Generator-2925"><span class="linenos">2925</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-2926"><a href="#Generator-2926"><span class="linenos">2926</span></a> <span class="k">return</span> <span class="s2">""</span> +</span><span id="Generator-2927"><a href="#Generator-2927"><span class="linenos">2927</span></a> +</span><span id="Generator-2928"><a href="#Generator-2928"><span class="linenos">2928</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-2929"><a href="#Generator-2929"><span class="linenos">2929</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-2930"><a href="#Generator-2930"><span class="linenos">2930</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-2931"><a href="#Generator-2931"><span class="linenos">2931</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-2932"><a href="#Generator-2932"><span class="linenos">2932</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-2933"><a href="#Generator-2933"><span class="linenos">2933</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-2934"><a href="#Generator-2934"><span class="linenos">2934</span></a> +</span><span id="Generator-2935"><a href="#Generator-2935"><span class="linenos">2935</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-2936"><a href="#Generator-2936"><span class="linenos">2936</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-2937"><a href="#Generator-2937"><span class="linenos">2937</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-2938"><a href="#Generator-2938"><span class="linenos">2938</span></a> +</span><span id="Generator-2939"><a href="#Generator-2939"><span class="linenos">2939</span></a> <span class="k">if</span> <span class="n">having</span><span class="p">:</span> +</span><span id="Generator-2940"><a href="#Generator-2940"><span class="linenos">2940</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-2941"><a href="#Generator-2941"><span class="linenos">2941</span></a> -</span><span id="Generator-2942"><a href="#Generator-2942"><span class="linenos">2942</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-2943"><a href="#Generator-2943"><span class="linenos">2943</span></a> <span class="k">if</span> <span class="n">parser</span><span class="p">:</span> -</span><span id="Generator-2944"><a href="#Generator-2944"><span class="linenos">2944</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-2945"><a href="#Generator-2945"><span class="linenos">2945</span></a> -</span><span id="Generator-2946"><a href="#Generator-2946"><span class="linenos">2946</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-2947"><a href="#Generator-2947"><span class="linenos">2947</span></a> <span class="k">if</span> <span class="n">comment</span><span class="p">:</span> -</span><span id="Generator-2948"><a href="#Generator-2948"><span class="linenos">2948</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-2949"><a href="#Generator-2949"><span class="linenos">2949</span></a> -</span><span id="Generator-2950"><a href="#Generator-2950"><span class="linenos">2950</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-2951"><a href="#Generator-2951"><span class="linenos">2951</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-2952"><a href="#Generator-2952"><span class="linenos">2952</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-2953"><a href="#Generator-2953"><span class="linenos">2953</span></a> -</span><span id="Generator-2954"><a href="#Generator-2954"><span class="linenos">2954</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-2955"><a href="#Generator-2955"><span class="linenos">2955</span></a> <span class="k">if</span> <span class="n">engine_attr</span><span class="p">:</span> -</span><span id="Generator-2956"><a href="#Generator-2956"><span class="linenos">2956</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-2957"><a href="#Generator-2957"><span class="linenos">2957</span></a> -</span><span id="Generator-2958"><a href="#Generator-2958"><span class="linenos">2958</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-2959"><a href="#Generator-2959"><span class="linenos">2959</span></a> <span class="k">if</span> <span class="n">secondary_engine_attr</span><span class="p">:</span> -</span><span id="Generator-2960"><a href="#Generator-2960"><span class="linenos">2960</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-2961"><a href="#Generator-2961"><span class="linenos">2961</span></a> -</span><span id="Generator-2962"><a href="#Generator-2962"><span class="linenos">2962</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-2963"><a href="#Generator-2963"><span class="linenos">2963</span></a> <span class="k">return</span> <span class="s2">""</span> -</span><span id="Generator-2964"><a href="#Generator-2964"><span class="linenos">2964</span></a> -</span><span id="Generator-2965"><a href="#Generator-2965"><span class="linenos">2965</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-2966"><a href="#Generator-2966"><span class="linenos">2966</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-2967"><a href="#Generator-2967"><span class="linenos">2967</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-2968"><a href="#Generator-2968"><span class="linenos">2968</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-2969"><a href="#Generator-2969"><span class="linenos">2969</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-2970"><a href="#Generator-2970"><span class="linenos">2970</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-2971"><a href="#Generator-2971"><span class="linenos">2971</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-2972"><a href="#Generator-2972"><span class="linenos">2972</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-2973"><a href="#Generator-2973"><span class="linenos">2973</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-2974"><a href="#Generator-2974"><span class="linenos">2974</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-2975"><a href="#Generator-2975"><span class="linenos">2975</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-2976"><a href="#Generator-2976"><span class="linenos">2976</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-2977"><a href="#Generator-2977"><span class="linenos">2977</span></a> -</span><span id="Generator-2978"><a href="#Generator-2978"><span class="linenos">2978</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-2979"><a href="#Generator-2979"><span class="linenos">2979</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-2980"><a href="#Generator-2980"><span class="linenos">2980</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-2981"><a href="#Generator-2981"><span class="linenos">2981</span></a> -</span><span id="Generator-2982"><a href="#Generator-2982"><span class="linenos">2982</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-2983"><a href="#Generator-2983"><span class="linenos">2983</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-2984"><a href="#Generator-2984"><span class="linenos">2984</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><span id="Generator-2985"><a href="#Generator-2985"><span class="linenos">2985</span></a> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> -</span><span id="Generator-2986"><a href="#Generator-2986"><span class="linenos">2986</span></a> <span class="p">)</span> -</span><span id="Generator-2987"><a href="#Generator-2987"><span class="linenos">2987</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-2988"><a href="#Generator-2988"><span class="linenos">2988</span></a> <span class="k">if</span> <span class="n">else_cond</span><span class="p">:</span> -</span><span id="Generator-2989"><a href="#Generator-2989"><span class="linenos">2989</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="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</span><span id="Generator-2942"><a href="#Generator-2942"><span class="linenos">2942</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-2943"><a href="#Generator-2943"><span class="linenos">2943</span></a> +</span><span id="Generator-2944"><a href="#Generator-2944"><span class="linenos">2944</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-2945"><a href="#Generator-2945"><span class="linenos">2945</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-2946"><a href="#Generator-2946"><span class="linenos">2946</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-2947"><a href="#Generator-2947"><span class="linenos">2947</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-2948"><a href="#Generator-2948"><span class="linenos">2948</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-2949"><a href="#Generator-2949"><span class="linenos">2949</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-2950"><a href="#Generator-2950"><span class="linenos">2950</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-2951"><a href="#Generator-2951"><span class="linenos">2951</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-2952"><a href="#Generator-2952"><span class="linenos">2952</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-2953"><a href="#Generator-2953"><span class="linenos">2953</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-2954"><a href="#Generator-2954"><span class="linenos">2954</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-2955"><a href="#Generator-2955"><span class="linenos">2955</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-2956"><a href="#Generator-2956"><span class="linenos">2956</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-2957"><a href="#Generator-2957"><span class="linenos">2957</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-2958"><a href="#Generator-2958"><span class="linenos">2958</span></a> +</span><span id="Generator-2959"><a href="#Generator-2959"><span class="linenos">2959</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-2960"><a href="#Generator-2960"><span class="linenos">2960</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-2961"><a href="#Generator-2961"><span class="linenos">2961</span></a> <span class="k">if</span> <span class="n">key_block_size</span><span class="p">:</span> +</span><span id="Generator-2962"><a href="#Generator-2962"><span class="linenos">2962</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-2963"><a href="#Generator-2963"><span class="linenos">2963</span></a> +</span><span id="Generator-2964"><a href="#Generator-2964"><span class="linenos">2964</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-2965"><a href="#Generator-2965"><span class="linenos">2965</span></a> <span class="k">if</span> <span class="n">using</span><span class="p">:</span> +</span><span id="Generator-2966"><a href="#Generator-2966"><span class="linenos">2966</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-2967"><a href="#Generator-2967"><span class="linenos">2967</span></a> +</span><span id="Generator-2968"><a href="#Generator-2968"><span class="linenos">2968</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-2969"><a href="#Generator-2969"><span class="linenos">2969</span></a> <span class="k">if</span> <span class="n">parser</span><span class="p">:</span> +</span><span id="Generator-2970"><a href="#Generator-2970"><span class="linenos">2970</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-2971"><a href="#Generator-2971"><span class="linenos">2971</span></a> +</span><span id="Generator-2972"><a href="#Generator-2972"><span class="linenos">2972</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-2973"><a href="#Generator-2973"><span class="linenos">2973</span></a> <span class="k">if</span> <span class="n">comment</span><span class="p">:</span> +</span><span id="Generator-2974"><a href="#Generator-2974"><span class="linenos">2974</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-2975"><a href="#Generator-2975"><span class="linenos">2975</span></a> +</span><span id="Generator-2976"><a href="#Generator-2976"><span class="linenos">2976</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-2977"><a href="#Generator-2977"><span class="linenos">2977</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-2978"><a href="#Generator-2978"><span class="linenos">2978</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-2979"><a href="#Generator-2979"><span class="linenos">2979</span></a> +</span><span id="Generator-2980"><a href="#Generator-2980"><span class="linenos">2980</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-2981"><a href="#Generator-2981"><span class="linenos">2981</span></a> <span class="k">if</span> <span class="n">engine_attr</span><span class="p">:</span> +</span><span id="Generator-2982"><a href="#Generator-2982"><span class="linenos">2982</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-2983"><a href="#Generator-2983"><span class="linenos">2983</span></a> +</span><span id="Generator-2984"><a href="#Generator-2984"><span class="linenos">2984</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-2985"><a href="#Generator-2985"><span class="linenos">2985</span></a> <span class="k">if</span> <span class="n">secondary_engine_attr</span><span class="p">:</span> +</span><span id="Generator-2986"><a href="#Generator-2986"><span class="linenos">2986</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-2987"><a href="#Generator-2987"><span class="linenos">2987</span></a> +</span><span id="Generator-2988"><a href="#Generator-2988"><span class="linenos">2988</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-2989"><a href="#Generator-2989"><span class="linenos">2989</span></a> <span class="k">return</span> <span class="s2">""</span> </span><span id="Generator-2990"><a href="#Generator-2990"><span class="linenos">2990</span></a> -</span><span id="Generator-2991"><a href="#Generator-2991"><span class="linenos">2991</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-2992"><a href="#Generator-2992"><span class="linenos">2992</span></a> -</span><span id="Generator-2993"><a href="#Generator-2993"><span class="linenos">2993</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-2991"><a href="#Generator-2991"><span class="linenos">2991</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-2992"><a href="#Generator-2992"><span class="linenos">2992</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-2993"><a href="#Generator-2993"><span class="linenos">2993</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-2994"><a href="#Generator-2994"><span class="linenos">2994</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-2995"><a href="#Generator-2995"><span class="linenos">2995</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-2996"><a href="#Generator-2996"><span class="linenos">2996</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-2997"><a href="#Generator-2997"><span class="linenos">2997</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-2998"><a href="#Generator-2998"><span class="linenos">2998</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-2999"><a href="#Generator-2999"><span class="linenos">2999</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-3000"><a href="#Generator-3000"><span class="linenos">3000</span></a> -</span><span id="Generator-3001"><a href="#Generator-3001"><span class="linenos">3001</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-3002"><a href="#Generator-3002"><span class="linenos">3002</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-2995"><a href="#Generator-2995"><span class="linenos">2995</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-2996"><a href="#Generator-2996"><span class="linenos">2996</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-2997"><a href="#Generator-2997"><span class="linenos">2997</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-2998"><a href="#Generator-2998"><span class="linenos">2998</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-2999"><a href="#Generator-2999"><span class="linenos">2999</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-3000"><a href="#Generator-3000"><span class="linenos">3000</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-3001"><a href="#Generator-3001"><span class="linenos">3001</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-3002"><a href="#Generator-3002"><span class="linenos">3002</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-3003"><a href="#Generator-3003"><span class="linenos">3003</span></a> -</span><span id="Generator-3004"><a href="#Generator-3004"><span class="linenos">3004</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-3005"><a href="#Generator-3005"><span class="linenos">3005</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-3006"><a href="#Generator-3006"><span class="linenos">3006</span></a> -</span><span id="Generator-3007"><a href="#Generator-3007"><span class="linenos">3007</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-3008"><a href="#Generator-3008"><span class="linenos">3008</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-3009"><a href="#Generator-3009"><span class="linenos">3009</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-3010"><a href="#Generator-3010"><span class="linenos">3010</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-3011"><a href="#Generator-3011"><span class="linenos">3011</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-3012"><a href="#Generator-3012"><span class="linenos">3012</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-3013"><a href="#Generator-3013"><span class="linenos">3013</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-3014"><a href="#Generator-3014"><span class="linenos">3014</span></a> -</span><span id="Generator-3015"><a href="#Generator-3015"><span class="linenos">3015</span></a> <span class="k">def</span> <span class="nf">forin_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ForIn</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-3016"><a href="#Generator-3016"><span class="linenos">3016</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-3017"><a href="#Generator-3017"><span class="linenos">3017</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-3018"><a href="#Generator-3018"><span class="linenos">3018</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"FOR </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> DO </span><span class="si">{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-3019"><a href="#Generator-3019"><span class="linenos">3019</span></a> -</span><span id="Generator-3020"><a href="#Generator-3020"><span class="linenos">3020</span></a> <span class="k">def</span> <span class="nf">refresh_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Refresh</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-3021"><a href="#Generator-3021"><span class="linenos">3021</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-3022"><a href="#Generator-3022"><span class="linenos">3022</span></a> <span class="n">table</span> <span class="o">=</span> <span class="s2">""</span> <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">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="p">)</span> <span class="k">else</span> <span class="s2">"TABLE "</span> -</span><span id="Generator-3023"><a href="#Generator-3023"><span class="linenos">3023</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"REFRESH </span><span class="si">{</span><span class="n">table</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-3024"><a href="#Generator-3024"><span class="linenos">3024</span></a> -</span><span id="Generator-3025"><a href="#Generator-3025"><span class="linenos">3025</span></a> <span class="k">def</span> <span class="nf">operator_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Operator</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-3026"><a href="#Generator-3026"><span class="linenos">3026</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="sa">f</span><span class="s2">"OPERATOR(</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">'operator'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">)</span> -</span><span id="Generator-3027"><a href="#Generator-3027"><span class="linenos">3027</span></a> -</span><span id="Generator-3028"><a href="#Generator-3028"><span class="linenos">3028</span></a> <span class="k">def</span> <span class="nf">_simplify_unless_literal</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">E</span><span class="p">)</span> <span class="o">-></span> <span class="n">E</span><span class="p">:</span> -</span><span id="Generator-3029"><a href="#Generator-3029"><span class="linenos">3029</span></a> <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="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="p">):</span> -</span><span id="Generator-3030"><a href="#Generator-3030"><span class="linenos">3030</span></a> <span class="kn">from</span> <span class="nn">sqlglot.optimizer.simplify</span> <span class="kn">import</span> <span class="n">simplify</span> -</span><span id="Generator-3031"><a href="#Generator-3031"><span class="linenos">3031</span></a> -</span><span id="Generator-3032"><a href="#Generator-3032"><span class="linenos">3032</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">simplify</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Generator-3033"><a href="#Generator-3033"><span class="linenos">3033</span></a> -</span><span id="Generator-3034"><a href="#Generator-3034"><span class="linenos">3034</span></a> <span class="k">return</span> <span class="n">expression</span> +</span><span id="Generator-3004"><a href="#Generator-3004"><span class="linenos">3004</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-3005"><a href="#Generator-3005"><span class="linenos">3005</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-3006"><a href="#Generator-3006"><span class="linenos">3006</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-3007"><a href="#Generator-3007"><span class="linenos">3007</span></a> +</span><span id="Generator-3008"><a href="#Generator-3008"><span class="linenos">3008</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-3009"><a href="#Generator-3009"><span class="linenos">3009</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-3010"><a href="#Generator-3010"><span class="linenos">3010</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><span id="Generator-3011"><a href="#Generator-3011"><span class="linenos">3011</span></a> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> +</span><span id="Generator-3012"><a href="#Generator-3012"><span class="linenos">3012</span></a> <span class="p">)</span> +</span><span id="Generator-3013"><a href="#Generator-3013"><span class="linenos">3013</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-3014"><a href="#Generator-3014"><span class="linenos">3014</span></a> <span class="k">if</span> <span class="n">else_cond</span><span class="p">:</span> +</span><span id="Generator-3015"><a href="#Generator-3015"><span class="linenos">3015</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="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</span><span id="Generator-3016"><a href="#Generator-3016"><span class="linenos">3016</span></a> +</span><span id="Generator-3017"><a href="#Generator-3017"><span class="linenos">3017</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-3018"><a href="#Generator-3018"><span class="linenos">3018</span></a> +</span><span id="Generator-3019"><a href="#Generator-3019"><span class="linenos">3019</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-3020"><a href="#Generator-3020"><span class="linenos">3020</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-3021"><a href="#Generator-3021"><span class="linenos">3021</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-3022"><a href="#Generator-3022"><span class="linenos">3022</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-3023"><a href="#Generator-3023"><span class="linenos">3023</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-3024"><a href="#Generator-3024"><span class="linenos">3024</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-3025"><a href="#Generator-3025"><span class="linenos">3025</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-3026"><a href="#Generator-3026"><span class="linenos">3026</span></a> +</span><span id="Generator-3027"><a href="#Generator-3027"><span class="linenos">3027</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-3028"><a href="#Generator-3028"><span class="linenos">3028</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-3029"><a href="#Generator-3029"><span class="linenos">3029</span></a> +</span><span id="Generator-3030"><a href="#Generator-3030"><span class="linenos">3030</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-3031"><a href="#Generator-3031"><span class="linenos">3031</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-3032"><a href="#Generator-3032"><span class="linenos">3032</span></a> +</span><span id="Generator-3033"><a href="#Generator-3033"><span class="linenos">3033</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-3034"><a href="#Generator-3034"><span class="linenos">3034</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-3035"><a href="#Generator-3035"><span class="linenos">3035</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-3036"><a href="#Generator-3036"><span class="linenos">3036</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-3037"><a href="#Generator-3037"><span class="linenos">3037</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-3038"><a href="#Generator-3038"><span class="linenos">3038</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-3039"><a href="#Generator-3039"><span class="linenos">3039</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-3040"><a href="#Generator-3040"><span class="linenos">3040</span></a> +</span><span id="Generator-3041"><a href="#Generator-3041"><span class="linenos">3041</span></a> <span class="k">def</span> <span class="nf">forin_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ForIn</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-3042"><a href="#Generator-3042"><span class="linenos">3042</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-3043"><a href="#Generator-3043"><span class="linenos">3043</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-3044"><a href="#Generator-3044"><span class="linenos">3044</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"FOR </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> DO </span><span class="si">{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-3045"><a href="#Generator-3045"><span class="linenos">3045</span></a> +</span><span id="Generator-3046"><a href="#Generator-3046"><span class="linenos">3046</span></a> <span class="k">def</span> <span class="nf">refresh_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Refresh</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-3047"><a href="#Generator-3047"><span class="linenos">3047</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-3048"><a href="#Generator-3048"><span class="linenos">3048</span></a> <span class="n">table</span> <span class="o">=</span> <span class="s2">""</span> <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">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="p">)</span> <span class="k">else</span> <span class="s2">"TABLE "</span> +</span><span id="Generator-3049"><a href="#Generator-3049"><span class="linenos">3049</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"REFRESH </span><span class="si">{</span><span class="n">table</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-3050"><a href="#Generator-3050"><span class="linenos">3050</span></a> +</span><span id="Generator-3051"><a href="#Generator-3051"><span class="linenos">3051</span></a> <span class="k">def</span> <span class="nf">operator_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Operator</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-3052"><a href="#Generator-3052"><span class="linenos">3052</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="sa">f</span><span class="s2">"OPERATOR(</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">'operator'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">)</span> +</span><span id="Generator-3053"><a href="#Generator-3053"><span class="linenos">3053</span></a> +</span><span id="Generator-3054"><a href="#Generator-3054"><span class="linenos">3054</span></a> <span class="k">def</span> <span class="nf">_simplify_unless_literal</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">E</span><span class="p">)</span> <span class="o">-></span> <span class="n">E</span><span class="p">:</span> +</span><span id="Generator-3055"><a href="#Generator-3055"><span class="linenos">3055</span></a> <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="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="p">):</span> +</span><span id="Generator-3056"><a href="#Generator-3056"><span class="linenos">3056</span></a> <span class="kn">from</span> <span class="nn">sqlglot.optimizer.simplify</span> <span class="kn">import</span> <span class="n">simplify</span> +</span><span id="Generator-3057"><a href="#Generator-3057"><span class="linenos">3057</span></a> +</span><span id="Generator-3058"><a href="#Generator-3058"><span class="linenos">3058</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">simplify</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Generator-3059"><a href="#Generator-3059"><span class="linenos">3059</span></a> +</span><span id="Generator-3060"><a href="#Generator-3060"><span class="linenos">3060</span></a> <span class="k">return</span> <span class="n">expression</span> +</span><span id="Generator-3061"><a href="#Generator-3061"><span class="linenos">3061</span></a> +</span><span id="Generator-3062"><a href="#Generator-3062"><span class="linenos">3062</span></a> <span class="k">def</span> <span class="nf">_ensure_string_if_null</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">values</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">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">List</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]:</span> +</span><span id="Generator-3063"><a href="#Generator-3063"><span class="linenos">3063</span></a> <span class="k">return</span> <span class="p">[</span> +</span><span id="Generator-3064"><a href="#Generator-3064"><span class="linenos">3064</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"COALESCE"</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">value</span><span class="p">,</span> <span class="s2">"text"</span><span class="p">),</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="s2">""</span><span class="p">))</span> +</span><span id="Generator-3065"><a href="#Generator-3065"><span class="linenos">3065</span></a> <span class="k">for</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">values</span> +</span><span id="Generator-3066"><a href="#Generator-3066"><span class="linenos">3066</span></a> <span class="k">if</span> <span class="n">value</span> +</span><span id="Generator-3067"><a href="#Generator-3067"><span class="linenos">3067</span></a> <span class="p">]</span> </span></pre></div> @@ -7222,48 +7300,48 @@ Default: True</li> </div> <a class="headerlink" href="#Generator.__init__"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.__init__-390"><a href="#Generator.__init__-390"><span class="linenos">390</span></a> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span> -</span><span id="Generator.__init__-391"><a href="#Generator.__init__-391"><span class="linenos">391</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Generator.__init__-392"><a href="#Generator.__init__-392"><span class="linenos">392</span></a> <span class="n">pretty</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">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Generator.__init__-393"><a href="#Generator.__init__-393"><span class="linenos">393</span></a> <span class="n">identify</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="Generator.__init__-394"><a href="#Generator.__init__-394"><span class="linenos">394</span></a> <span class="n">normalize</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.__init__-395"><a href="#Generator.__init__-395"><span class="linenos">395</span></a> <span class="n">pad</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">2</span><span class="p">,</span> -</span><span id="Generator.__init__-396"><a href="#Generator.__init__-396"><span class="linenos">396</span></a> <span class="n">indent</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">2</span><span class="p">,</span> -</span><span id="Generator.__init__-397"><a href="#Generator.__init__-397"><span class="linenos">397</span></a> <span class="n">normalize_functions</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="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Generator.__init__-398"><a href="#Generator.__init__-398"><span class="linenos">398</span></a> <span class="n">unsupported_level</span><span class="p">:</span> <span class="n">ErrorLevel</span> <span class="o">=</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">WARN</span><span class="p">,</span> -</span><span id="Generator.__init__-399"><a href="#Generator.__init__-399"><span class="linenos">399</span></a> <span class="n">max_unsupported</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">3</span><span class="p">,</span> -</span><span id="Generator.__init__-400"><a href="#Generator.__init__-400"><span class="linenos">400</span></a> <span class="n">leading_comma</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.__init__-401"><a href="#Generator.__init__-401"><span class="linenos">401</span></a> <span class="n">max_text_width</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">80</span><span class="p">,</span> -</span><span id="Generator.__init__-402"><a href="#Generator.__init__-402"><span class="linenos">402</span></a> <span class="n">comments</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.__init__-403"><a href="#Generator.__init__-403"><span class="linenos">403</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Generator.__init__-404"><a href="#Generator.__init__-404"><span class="linenos">404</span></a> <span class="p">):</span> -</span><span id="Generator.__init__-405"><a href="#Generator.__init__-405"><span class="linenos">405</span></a> <span class="kn">import</span> <span class="nn">sqlglot</span> -</span><span id="Generator.__init__-406"><a href="#Generator.__init__-406"><span class="linenos">406</span></a> <span class="kn">from</span> <span class="nn">sqlglot.dialects</span> <span class="kn">import</span> <span class="n">Dialect</span> -</span><span id="Generator.__init__-407"><a href="#Generator.__init__-407"><span class="linenos">407</span></a> -</span><span id="Generator.__init__-408"><a href="#Generator.__init__-408"><span class="linenos">408</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span> <span class="o">=</span> <span class="n">pretty</span> <span class="k">if</span> <span class="n">pretty</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">sqlglot</span><span class="o">.</span><span class="n">pretty</span> -</span><span id="Generator.__init__-409"><a href="#Generator.__init__-409"><span class="linenos">409</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">identify</span> <span class="o">=</span> <span class="n">identify</span> -</span><span id="Generator.__init__-410"><a href="#Generator.__init__-410"><span class="linenos">410</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">normalize</span> <span class="o">=</span> <span class="n">normalize</span> -</span><span id="Generator.__init__-411"><a href="#Generator.__init__-411"><span class="linenos">411</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">pad</span> <span class="o">=</span> <span class="n">pad</span> -</span><span id="Generator.__init__-412"><a href="#Generator.__init__-412"><span class="linenos">412</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_indent</span> <span class="o">=</span> <span class="n">indent</span> -</span><span id="Generator.__init__-413"><a href="#Generator.__init__-413"><span class="linenos">413</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_level</span> <span class="o">=</span> <span class="n">unsupported_level</span> -</span><span id="Generator.__init__-414"><a href="#Generator.__init__-414"><span class="linenos">414</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">max_unsupported</span> <span class="o">=</span> <span class="n">max_unsupported</span> -</span><span id="Generator.__init__-415"><a href="#Generator.__init__-415"><span class="linenos">415</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">leading_comma</span> <span class="o">=</span> <span class="n">leading_comma</span> -</span><span id="Generator.__init__-416"><a href="#Generator.__init__-416"><span class="linenos">416</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">max_text_width</span> <span class="o">=</span> <span class="n">max_text_width</span> -</span><span id="Generator.__init__-417"><a href="#Generator.__init__-417"><span class="linenos">417</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">comments</span> <span class="o">=</span> <span class="n">comments</span> -</span><span id="Generator.__init__-418"><a href="#Generator.__init__-418"><span class="linenos">418</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span> <span class="o">=</span> <span class="n">Dialect</span><span class="o">.</span><span class="n">get_or_raise</span><span class="p">(</span><span class="n">dialect</span><span class="p">)</span> -</span><span id="Generator.__init__-419"><a href="#Generator.__init__-419"><span class="linenos">419</span></a> -</span><span id="Generator.__init__-420"><a href="#Generator.__init__-420"><span class="linenos">420</span></a> <span class="c1"># This is both a Dialect property and a Generator argument, so we prioritize the latter</span> -</span><span id="Generator.__init__-421"><a href="#Generator.__init__-421"><span class="linenos">421</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">normalize_functions</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Generator.__init__-422"><a href="#Generator.__init__-422"><span class="linenos">422</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">NORMALIZE_FUNCTIONS</span> <span class="k">if</span> <span class="n">normalize_functions</span> <span class="ow">is</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">normalize_functions</span> -</span><span id="Generator.__init__-423"><a href="#Generator.__init__-423"><span class="linenos">423</span></a> <span class="p">)</span> -</span><span id="Generator.__init__-424"><a href="#Generator.__init__-424"><span class="linenos">424</span></a> -</span><span id="Generator.__init__-425"><a href="#Generator.__init__-425"><span class="linenos">425</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_messages</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="Generator.__init__-426"><a href="#Generator.__init__-426"><span class="linenos">426</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_escaped_quote_end</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Generator.__init__-427"><a href="#Generator.__init__-427"><span class="linenos">427</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">tokenizer_class</span><span class="o">.</span><span class="n">STRING_ESCAPES</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">QUOTE_END</span> -</span><span id="Generator.__init__-428"><a href="#Generator.__init__-428"><span class="linenos">428</span></a> <span class="p">)</span> -</span><span id="Generator.__init__-429"><a href="#Generator.__init__-429"><span class="linenos">429</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_escaped_identifier_end</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Generator.__init__-430"><a href="#Generator.__init__-430"><span class="linenos">430</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">tokenizer_class</span><span class="o">.</span><span class="n">IDENTIFIER_ESCAPES</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">IDENTIFIER_END</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.__init__-393"><a href="#Generator.__init__-393"><span class="linenos">393</span></a> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span> +</span><span id="Generator.__init__-394"><a href="#Generator.__init__-394"><span class="linenos">394</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Generator.__init__-395"><a href="#Generator.__init__-395"><span class="linenos">395</span></a> <span class="n">pretty</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">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Generator.__init__-396"><a href="#Generator.__init__-396"><span class="linenos">396</span></a> <span class="n">identify</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="Generator.__init__-397"><a href="#Generator.__init__-397"><span class="linenos">397</span></a> <span class="n">normalize</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.__init__-398"><a href="#Generator.__init__-398"><span class="linenos">398</span></a> <span class="n">pad</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">2</span><span class="p">,</span> +</span><span id="Generator.__init__-399"><a href="#Generator.__init__-399"><span class="linenos">399</span></a> <span class="n">indent</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">2</span><span class="p">,</span> +</span><span id="Generator.__init__-400"><a href="#Generator.__init__-400"><span class="linenos">400</span></a> <span class="n">normalize_functions</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="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Generator.__init__-401"><a href="#Generator.__init__-401"><span class="linenos">401</span></a> <span class="n">unsupported_level</span><span class="p">:</span> <span class="n">ErrorLevel</span> <span class="o">=</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">WARN</span><span class="p">,</span> +</span><span id="Generator.__init__-402"><a href="#Generator.__init__-402"><span class="linenos">402</span></a> <span class="n">max_unsupported</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">3</span><span class="p">,</span> +</span><span id="Generator.__init__-403"><a href="#Generator.__init__-403"><span class="linenos">403</span></a> <span class="n">leading_comma</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.__init__-404"><a href="#Generator.__init__-404"><span class="linenos">404</span></a> <span class="n">max_text_width</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">80</span><span class="p">,</span> +</span><span id="Generator.__init__-405"><a href="#Generator.__init__-405"><span class="linenos">405</span></a> <span class="n">comments</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.__init__-406"><a href="#Generator.__init__-406"><span class="linenos">406</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Generator.__init__-407"><a href="#Generator.__init__-407"><span class="linenos">407</span></a> <span class="p">):</span> +</span><span id="Generator.__init__-408"><a href="#Generator.__init__-408"><span class="linenos">408</span></a> <span class="kn">import</span> <span class="nn">sqlglot</span> +</span><span id="Generator.__init__-409"><a href="#Generator.__init__-409"><span class="linenos">409</span></a> <span class="kn">from</span> <span class="nn">sqlglot.dialects</span> <span class="kn">import</span> <span class="n">Dialect</span> +</span><span id="Generator.__init__-410"><a href="#Generator.__init__-410"><span class="linenos">410</span></a> +</span><span id="Generator.__init__-411"><a href="#Generator.__init__-411"><span class="linenos">411</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span> <span class="o">=</span> <span class="n">pretty</span> <span class="k">if</span> <span class="n">pretty</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">sqlglot</span><span class="o">.</span><span class="n">pretty</span> +</span><span id="Generator.__init__-412"><a href="#Generator.__init__-412"><span class="linenos">412</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">identify</span> <span class="o">=</span> <span class="n">identify</span> +</span><span id="Generator.__init__-413"><a href="#Generator.__init__-413"><span class="linenos">413</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">normalize</span> <span class="o">=</span> <span class="n">normalize</span> +</span><span id="Generator.__init__-414"><a href="#Generator.__init__-414"><span class="linenos">414</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">pad</span> <span class="o">=</span> <span class="n">pad</span> +</span><span id="Generator.__init__-415"><a href="#Generator.__init__-415"><span class="linenos">415</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_indent</span> <span class="o">=</span> <span class="n">indent</span> +</span><span id="Generator.__init__-416"><a href="#Generator.__init__-416"><span class="linenos">416</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_level</span> <span class="o">=</span> <span class="n">unsupported_level</span> +</span><span id="Generator.__init__-417"><a href="#Generator.__init__-417"><span class="linenos">417</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">max_unsupported</span> <span class="o">=</span> <span class="n">max_unsupported</span> +</span><span id="Generator.__init__-418"><a href="#Generator.__init__-418"><span class="linenos">418</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">leading_comma</span> <span class="o">=</span> <span class="n">leading_comma</span> +</span><span id="Generator.__init__-419"><a href="#Generator.__init__-419"><span class="linenos">419</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">max_text_width</span> <span class="o">=</span> <span class="n">max_text_width</span> +</span><span id="Generator.__init__-420"><a href="#Generator.__init__-420"><span class="linenos">420</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">comments</span> <span class="o">=</span> <span class="n">comments</span> +</span><span id="Generator.__init__-421"><a href="#Generator.__init__-421"><span class="linenos">421</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span> <span class="o">=</span> <span class="n">Dialect</span><span class="o">.</span><span class="n">get_or_raise</span><span class="p">(</span><span class="n">dialect</span><span class="p">)</span> +</span><span id="Generator.__init__-422"><a href="#Generator.__init__-422"><span class="linenos">422</span></a> +</span><span id="Generator.__init__-423"><a href="#Generator.__init__-423"><span class="linenos">423</span></a> <span class="c1"># This is both a Dialect property and a Generator argument, so we prioritize the latter</span> +</span><span id="Generator.__init__-424"><a href="#Generator.__init__-424"><span class="linenos">424</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">normalize_functions</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Generator.__init__-425"><a href="#Generator.__init__-425"><span class="linenos">425</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">NORMALIZE_FUNCTIONS</span> <span class="k">if</span> <span class="n">normalize_functions</span> <span class="ow">is</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">normalize_functions</span> +</span><span id="Generator.__init__-426"><a href="#Generator.__init__-426"><span class="linenos">426</span></a> <span class="p">)</span> +</span><span id="Generator.__init__-427"><a href="#Generator.__init__-427"><span class="linenos">427</span></a> +</span><span id="Generator.__init__-428"><a href="#Generator.__init__-428"><span class="linenos">428</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_messages</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="Generator.__init__-429"><a href="#Generator.__init__-429"><span class="linenos">429</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_escaped_quote_end</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Generator.__init__-430"><a href="#Generator.__init__-430"><span class="linenos">430</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">tokenizer_class</span><span class="o">.</span><span class="n">STRING_ESCAPES</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">QUOTE_END</span> </span><span id="Generator.__init__-431"><a href="#Generator.__init__-431"><span class="linenos">431</span></a> <span class="p">)</span> +</span><span id="Generator.__init__-432"><a href="#Generator.__init__-432"><span class="linenos">432</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_escaped_identifier_end</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Generator.__init__-433"><a href="#Generator.__init__-433"><span class="linenos">433</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">tokenizer_class</span><span class="o">.</span><span class="n">IDENTIFIER_ESCAPES</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">IDENTIFIER_END</span> +</span><span id="Generator.__init__-434"><a href="#Generator.__init__-434"><span class="linenos">434</span></a> <span class="p">)</span> </span></pre></div> @@ -7763,6 +7841,18 @@ Default: True</li> </div> + <div id="Generator.SUPPORTS_SINGLE_ARG_CONCAT" class="classattr"> + <div class="attr variable"> + <span class="name">SUPPORTS_SINGLE_ARG_CONCAT</span> = +<span class="default_value">True</span> + + + </div> + <a class="headerlink" href="#Generator.SUPPORTS_SINGLE_ARG_CONCAT"></a> + + + + </div> <div id="Generator.TYPE_MAPPING" class="classattr"> <div class="attr variable"> <span class="name">TYPE_MAPPING</span> = @@ -7803,7 +7893,7 @@ Default: True</li> </div> <div id="Generator.TOKEN_MAPPING" class="classattr"> <div class="attr variable"> - <span class="name">TOKEN_MAPPING</span><span class="annotation">: Dict[<a href="tokens.html#TokenType">sqlglot.tokens.TokenType</a>, str]</span> = + <span class="name">TOKEN_MAPPING</span><span class="annotation">: Dict[<a href="token_type.html#TokenType">sqlglot.token_type.TokenType</a>, str]</span> = <span class="default_value">{}</span> @@ -8080,39 +8170,39 @@ Default: True</li> </div> <a class="headerlink" href="#Generator.generate"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.generate-433"><a href="#Generator.generate-433"><span class="linenos">433</span></a> <span class="k">def</span> <span class="nf">generate</span><span class="p">(</span><span class="bp">self</span><span 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">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.generate-434"><a href="#Generator.generate-434"><span class="linenos">434</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Generator.generate-435"><a href="#Generator.generate-435"><span class="linenos">435</span></a><span class="sd"> Generates the SQL string corresponding to the given syntax tree.</span> -</span><span id="Generator.generate-436"><a href="#Generator.generate-436"><span class="linenos">436</span></a> -</span><span id="Generator.generate-437"><a href="#Generator.generate-437"><span class="linenos">437</span></a><span class="sd"> Args:</span> -</span><span id="Generator.generate-438"><a href="#Generator.generate-438"><span class="linenos">438</span></a><span class="sd"> expression: The syntax tree.</span> -</span><span id="Generator.generate-439"><a href="#Generator.generate-439"><span class="linenos">439</span></a><span class="sd"> copy: Whether or not to copy the expression. The generator performs mutations so</span> -</span><span id="Generator.generate-440"><a href="#Generator.generate-440"><span class="linenos">440</span></a><span class="sd"> it is safer to copy.</span> -</span><span id="Generator.generate-441"><a href="#Generator.generate-441"><span class="linenos">441</span></a> -</span><span id="Generator.generate-442"><a href="#Generator.generate-442"><span class="linenos">442</span></a><span class="sd"> Returns:</span> -</span><span id="Generator.generate-443"><a href="#Generator.generate-443"><span class="linenos">443</span></a><span class="sd"> The SQL string corresponding to `expression`.</span> -</span><span id="Generator.generate-444"><a href="#Generator.generate-444"><span class="linenos">444</span></a><span class="sd"> """</span> -</span><span id="Generator.generate-445"><a href="#Generator.generate-445"><span class="linenos">445</span></a> <span class="k">if</span> <span class="n">copy</span><span class="p">:</span> -</span><span id="Generator.generate-446"><a href="#Generator.generate-446"><span class="linenos">446</span></a> <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.generate-447"><a href="#Generator.generate-447"><span class="linenos">447</span></a> -</span><span id="Generator.generate-448"><a href="#Generator.generate-448"><span class="linenos">448</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">preprocess</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Generator.generate-449"><a href="#Generator.generate-449"><span class="linenos">449</span></a> -</span><span id="Generator.generate-450"><a href="#Generator.generate-450"><span class="linenos">450</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_messages</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="Generator.generate-451"><a href="#Generator.generate-451"><span class="linenos">451</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">expression</span><span class="p">)</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.generate-436"><a href="#Generator.generate-436"><span class="linenos">436</span></a> <span class="k">def</span> <span class="nf">generate</span><span class="p">(</span><span class="bp">self</span><span 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">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.generate-437"><a href="#Generator.generate-437"><span class="linenos">437</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Generator.generate-438"><a href="#Generator.generate-438"><span class="linenos">438</span></a><span class="sd"> Generates the SQL string corresponding to the given syntax tree.</span> +</span><span id="Generator.generate-439"><a href="#Generator.generate-439"><span class="linenos">439</span></a> +</span><span id="Generator.generate-440"><a href="#Generator.generate-440"><span class="linenos">440</span></a><span class="sd"> Args:</span> +</span><span id="Generator.generate-441"><a href="#Generator.generate-441"><span class="linenos">441</span></a><span class="sd"> expression: The syntax tree.</span> +</span><span id="Generator.generate-442"><a href="#Generator.generate-442"><span class="linenos">442</span></a><span class="sd"> copy: Whether or not to copy the expression. The generator performs mutations so</span> +</span><span id="Generator.generate-443"><a href="#Generator.generate-443"><span class="linenos">443</span></a><span class="sd"> it is safer to copy.</span> +</span><span id="Generator.generate-444"><a href="#Generator.generate-444"><span class="linenos">444</span></a> +</span><span id="Generator.generate-445"><a href="#Generator.generate-445"><span class="linenos">445</span></a><span class="sd"> Returns:</span> +</span><span id="Generator.generate-446"><a href="#Generator.generate-446"><span class="linenos">446</span></a><span class="sd"> The SQL string corresponding to `expression`.</span> +</span><span id="Generator.generate-447"><a href="#Generator.generate-447"><span class="linenos">447</span></a><span class="sd"> """</span> +</span><span id="Generator.generate-448"><a href="#Generator.generate-448"><span class="linenos">448</span></a> <span class="k">if</span> <span class="n">copy</span><span class="p">:</span> +</span><span id="Generator.generate-449"><a href="#Generator.generate-449"><span class="linenos">449</span></a> <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.generate-450"><a href="#Generator.generate-450"><span class="linenos">450</span></a> +</span><span id="Generator.generate-451"><a href="#Generator.generate-451"><span class="linenos">451</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">preprocess</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> </span><span id="Generator.generate-452"><a href="#Generator.generate-452"><span class="linenos">452</span></a> -</span><span id="Generator.generate-453"><a href="#Generator.generate-453"><span class="linenos">453</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.generate-454"><a href="#Generator.generate-454"><span class="linenos">454</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="n">sql</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">SENTINEL_LINE_BREAK</span><span class="p">,</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">)</span> +</span><span id="Generator.generate-453"><a href="#Generator.generate-453"><span class="linenos">453</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_messages</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="Generator.generate-454"><a href="#Generator.generate-454"><span class="linenos">454</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">expression</span><span class="p">)</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> </span><span id="Generator.generate-455"><a href="#Generator.generate-455"><span class="linenos">455</span></a> -</span><span id="Generator.generate-456"><a href="#Generator.generate-456"><span class="linenos">456</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_level</span> <span class="o">==</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">IGNORE</span><span class="p">:</span> -</span><span id="Generator.generate-457"><a href="#Generator.generate-457"><span class="linenos">457</span></a> <span class="k">return</span> <span class="n">sql</span> +</span><span id="Generator.generate-456"><a href="#Generator.generate-456"><span class="linenos">456</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.generate-457"><a href="#Generator.generate-457"><span class="linenos">457</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="n">sql</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">SENTINEL_LINE_BREAK</span><span class="p">,</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">)</span> </span><span id="Generator.generate-458"><a href="#Generator.generate-458"><span class="linenos">458</span></a> -</span><span id="Generator.generate-459"><a href="#Generator.generate-459"><span class="linenos">459</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_level</span> <span class="o">==</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">WARN</span><span class="p">:</span> -</span><span id="Generator.generate-460"><a href="#Generator.generate-460"><span class="linenos">460</span></a> <span class="k">for</span> <span class="n">msg</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_messages</span><span class="p">:</span> -</span><span id="Generator.generate-461"><a href="#Generator.generate-461"><span class="linenos">461</span></a> <span class="n">logger</span><span class="o">.</span><span class="n">warning</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span> -</span><span id="Generator.generate-462"><a href="#Generator.generate-462"><span class="linenos">462</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_level</span> <span class="o">==</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">RAISE</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_messages</span><span class="p">:</span> -</span><span id="Generator.generate-463"><a href="#Generator.generate-463"><span class="linenos">463</span></a> <span class="k">raise</span> <span class="n">UnsupportedError</span><span class="p">(</span><span class="n">concat_messages</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">unsupported_messages</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">max_unsupported</span><span class="p">))</span> -</span><span id="Generator.generate-464"><a href="#Generator.generate-464"><span class="linenos">464</span></a> -</span><span id="Generator.generate-465"><a href="#Generator.generate-465"><span class="linenos">465</span></a> <span class="k">return</span> <span class="n">sql</span> +</span><span id="Generator.generate-459"><a href="#Generator.generate-459"><span class="linenos">459</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_level</span> <span class="o">==</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">IGNORE</span><span class="p">:</span> +</span><span id="Generator.generate-460"><a href="#Generator.generate-460"><span class="linenos">460</span></a> <span class="k">return</span> <span class="n">sql</span> +</span><span id="Generator.generate-461"><a href="#Generator.generate-461"><span class="linenos">461</span></a> +</span><span id="Generator.generate-462"><a href="#Generator.generate-462"><span class="linenos">462</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_level</span> <span class="o">==</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">WARN</span><span class="p">:</span> +</span><span id="Generator.generate-463"><a href="#Generator.generate-463"><span class="linenos">463</span></a> <span class="k">for</span> <span class="n">msg</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_messages</span><span class="p">:</span> +</span><span id="Generator.generate-464"><a href="#Generator.generate-464"><span class="linenos">464</span></a> <span class="n">logger</span><span class="o">.</span><span class="n">warning</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span> +</span><span id="Generator.generate-465"><a href="#Generator.generate-465"><span class="linenos">465</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_level</span> <span class="o">==</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">RAISE</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_messages</span><span class="p">:</span> +</span><span id="Generator.generate-466"><a href="#Generator.generate-466"><span class="linenos">466</span></a> <span class="k">raise</span> <span class="n">UnsupportedError</span><span class="p">(</span><span class="n">concat_messages</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">unsupported_messages</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">max_unsupported</span><span class="p">))</span> +</span><span id="Generator.generate-467"><a href="#Generator.generate-467"><span class="linenos">467</span></a> +</span><span id="Generator.generate-468"><a href="#Generator.generate-468"><span class="linenos">468</span></a> <span class="k">return</span> <span class="n">sql</span> </span></pre></div> @@ -8146,23 +8236,23 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.preprocess"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.preprocess-467"><a href="#Generator.preprocess-467"><span class="linenos">467</span></a> <span class="k">def</span> <span class="nf">preprocess</span><span class="p">(</span><span class="bp">self</span><span 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">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">:</span> -</span><span id="Generator.preprocess-468"><a href="#Generator.preprocess-468"><span class="linenos">468</span></a><span class="w"> </span><span class="sd">"""Apply generic preprocessing transformations to a given expression."""</span> -</span><span id="Generator.preprocess-469"><a href="#Generator.preprocess-469"><span class="linenos">469</span></a> <span class="k">if</span> <span class="p">(</span> -</span><span id="Generator.preprocess-470"><a href="#Generator.preprocess-470"><span class="linenos">470</span></a> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">parent</span> -</span><span id="Generator.preprocess-471"><a href="#Generator.preprocess-471"><span class="linenos">471</span></a> <span class="ow">and</span> <span class="nb">type</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">EXPRESSIONS_WITHOUT_NESTED_CTES</span> -</span><span id="Generator.preprocess-472"><a href="#Generator.preprocess-472"><span class="linenos">472</span></a> <span class="ow">and</span> <span class="nb">any</span><span class="p">(</span><span class="n">node</span><span class="o">.</span><span class="n">parent</span> <span class="ow">is</span> <span class="ow">not</span> <span class="n">expression</span> <span class="k">for</span> <span class="n">node</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">find_all</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">With</span><span class="p">))</span> -</span><span id="Generator.preprocess-473"><a href="#Generator.preprocess-473"><span class="linenos">473</span></a> <span class="p">):</span> -</span><span id="Generator.preprocess-474"><a href="#Generator.preprocess-474"><span class="linenos">474</span></a> <span class="kn">from</span> <span class="nn">sqlglot.transforms</span> <span class="kn">import</span> <span class="n">move_ctes_to_top_level</span> -</span><span id="Generator.preprocess-475"><a href="#Generator.preprocess-475"><span class="linenos">475</span></a> -</span><span id="Generator.preprocess-476"><a href="#Generator.preprocess-476"><span class="linenos">476</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">move_ctes_to_top_level</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Generator.preprocess-477"><a href="#Generator.preprocess-477"><span class="linenos">477</span></a> -</span><span id="Generator.preprocess-478"><a href="#Generator.preprocess-478"><span class="linenos">478</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">ENSURE_BOOLS</span><span class="p">:</span> -</span><span id="Generator.preprocess-479"><a href="#Generator.preprocess-479"><span class="linenos">479</span></a> <span class="kn">from</span> <span class="nn">sqlglot.transforms</span> <span class="kn">import</span> <span class="n">ensure_bools</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.preprocess-470"><a href="#Generator.preprocess-470"><span class="linenos">470</span></a> <span class="k">def</span> <span class="nf">preprocess</span><span class="p">(</span><span class="bp">self</span><span 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">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">:</span> +</span><span id="Generator.preprocess-471"><a href="#Generator.preprocess-471"><span class="linenos">471</span></a><span class="w"> </span><span class="sd">"""Apply generic preprocessing transformations to a given expression."""</span> +</span><span id="Generator.preprocess-472"><a href="#Generator.preprocess-472"><span class="linenos">472</span></a> <span class="k">if</span> <span class="p">(</span> +</span><span id="Generator.preprocess-473"><a href="#Generator.preprocess-473"><span class="linenos">473</span></a> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">parent</span> +</span><span id="Generator.preprocess-474"><a href="#Generator.preprocess-474"><span class="linenos">474</span></a> <span class="ow">and</span> <span class="nb">type</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">EXPRESSIONS_WITHOUT_NESTED_CTES</span> +</span><span id="Generator.preprocess-475"><a href="#Generator.preprocess-475"><span class="linenos">475</span></a> <span class="ow">and</span> <span class="nb">any</span><span class="p">(</span><span class="n">node</span><span class="o">.</span><span class="n">parent</span> <span class="ow">is</span> <span class="ow">not</span> <span class="n">expression</span> <span class="k">for</span> <span class="n">node</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">find_all</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">With</span><span class="p">))</span> +</span><span id="Generator.preprocess-476"><a href="#Generator.preprocess-476"><span class="linenos">476</span></a> <span class="p">):</span> +</span><span id="Generator.preprocess-477"><a href="#Generator.preprocess-477"><span class="linenos">477</span></a> <span class="kn">from</span> <span class="nn">sqlglot.transforms</span> <span class="kn">import</span> <span class="n">move_ctes_to_top_level</span> +</span><span id="Generator.preprocess-478"><a href="#Generator.preprocess-478"><span class="linenos">478</span></a> +</span><span id="Generator.preprocess-479"><a href="#Generator.preprocess-479"><span class="linenos">479</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">move_ctes_to_top_level</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> </span><span id="Generator.preprocess-480"><a href="#Generator.preprocess-480"><span class="linenos">480</span></a> -</span><span id="Generator.preprocess-481"><a href="#Generator.preprocess-481"><span class="linenos">481</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">ensure_bools</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Generator.preprocess-482"><a href="#Generator.preprocess-482"><span class="linenos">482</span></a> -</span><span id="Generator.preprocess-483"><a href="#Generator.preprocess-483"><span class="linenos">483</span></a> <span class="k">return</span> <span class="n">expression</span> +</span><span id="Generator.preprocess-481"><a href="#Generator.preprocess-481"><span class="linenos">481</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">ENSURE_BOOLS</span><span class="p">:</span> +</span><span id="Generator.preprocess-482"><a href="#Generator.preprocess-482"><span class="linenos">482</span></a> <span class="kn">from</span> <span class="nn">sqlglot.transforms</span> <span class="kn">import</span> <span class="n">ensure_bools</span> +</span><span id="Generator.preprocess-483"><a href="#Generator.preprocess-483"><span class="linenos">483</span></a> +</span><span id="Generator.preprocess-484"><a href="#Generator.preprocess-484"><span class="linenos">484</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">ensure_bools</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Generator.preprocess-485"><a href="#Generator.preprocess-485"><span class="linenos">485</span></a> +</span><span id="Generator.preprocess-486"><a href="#Generator.preprocess-486"><span class="linenos">486</span></a> <span class="k">return</span> <span class="n">expression</span> </span></pre></div> @@ -8182,10 +8272,10 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.unsupported"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.unsupported-485"><a href="#Generator.unsupported-485"><span class="linenos">485</span></a> <span class="k">def</span> <span class="nf">unsupported</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">message</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.unsupported-486"><a href="#Generator.unsupported-486"><span class="linenos">486</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_level</span> <span class="o">==</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">IMMEDIATE</span><span class="p">:</span> -</span><span id="Generator.unsupported-487"><a href="#Generator.unsupported-487"><span class="linenos">487</span></a> <span class="k">raise</span> <span class="n">UnsupportedError</span><span class="p">(</span><span class="n">message</span><span class="p">)</span> -</span><span id="Generator.unsupported-488"><a href="#Generator.unsupported-488"><span class="linenos">488</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_messages</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">message</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.unsupported-488"><a href="#Generator.unsupported-488"><span class="linenos">488</span></a> <span class="k">def</span> <span class="nf">unsupported</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">message</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.unsupported-489"><a href="#Generator.unsupported-489"><span class="linenos">489</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_level</span> <span class="o">==</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">IMMEDIATE</span><span class="p">:</span> +</span><span id="Generator.unsupported-490"><a href="#Generator.unsupported-490"><span class="linenos">490</span></a> <span class="k">raise</span> <span class="n">UnsupportedError</span><span class="p">(</span><span class="n">message</span><span class="p">)</span> +</span><span id="Generator.unsupported-491"><a href="#Generator.unsupported-491"><span class="linenos">491</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_messages</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">message</span><span class="p">)</span> </span></pre></div> @@ -8203,8 +8293,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.sep"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.sep-490"><a href="#Generator.sep-490"><span class="linenos">490</span></a> <span class="k">def</span> <span class="nf">sep</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <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 class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.sep-491"><a href="#Generator.sep-491"><span class="linenos">491</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="o">.</span><span class="n">strip</span><span class="p">()</span><span class="si">}</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">pretty</span> <span class="k">else</span> <span class="n">sep</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.sep-493"><a href="#Generator.sep-493"><span class="linenos">493</span></a> <span class="k">def</span> <span class="nf">sep</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <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 class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.sep-494"><a href="#Generator.sep-494"><span class="linenos">494</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="o">.</span><span class="n">strip</span><span class="p">()</span><span class="si">}</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">pretty</span> <span class="k">else</span> <span class="n">sep</span> </span></pre></div> @@ -8222,8 +8312,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.seg"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.seg-493"><a href="#Generator.seg-493"><span class="linenos">493</span></a> <span class="k">def</span> <span class="nf">seg</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sql</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <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 class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.seg-494"><a href="#Generator.seg-494"><span class="linenos">494</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">sep</span><span class="p">(</span><span class="n">sep</span><span class="p">)</span><span class="si">}{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.seg-496"><a href="#Generator.seg-496"><span class="linenos">496</span></a> <span class="k">def</span> <span class="nf">seg</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sql</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <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 class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.seg-497"><a href="#Generator.seg-497"><span class="linenos">497</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">sep</span><span class="p">(</span><span class="n">sep</span><span class="p">)</span><span class="si">}{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -8241,10 +8331,10 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.pad_comment"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.pad_comment-496"><a href="#Generator.pad_comment-496"><span class="linenos">496</span></a> <span class="k">def</span> <span class="nf">pad_comment</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">comment</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.pad_comment-497"><a href="#Generator.pad_comment-497"><span class="linenos">497</span></a> <span class="n">comment</span> <span class="o">=</span> <span class="s2">" "</span> <span class="o">+</span> <span class="n">comment</span> <span class="k">if</span> <span class="n">comment</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> <span class="k">else</span> <span class="n">comment</span> -</span><span id="Generator.pad_comment-498"><a href="#Generator.pad_comment-498"><span class="linenos">498</span></a> <span class="n">comment</span> <span class="o">=</span> <span class="n">comment</span> <span class="o">+</span> <span class="s2">" "</span> <span class="k">if</span> <span class="n">comment</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> <span class="k">else</span> <span class="n">comment</span> -</span><span id="Generator.pad_comment-499"><a href="#Generator.pad_comment-499"><span class="linenos">499</span></a> <span class="k">return</span> <span class="n">comment</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.pad_comment-499"><a href="#Generator.pad_comment-499"><span class="linenos">499</span></a> <span class="k">def</span> <span class="nf">pad_comment</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">comment</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.pad_comment-500"><a href="#Generator.pad_comment-500"><span class="linenos">500</span></a> <span class="n">comment</span> <span class="o">=</span> <span class="s2">" "</span> <span class="o">+</span> <span class="n">comment</span> <span class="k">if</span> <span class="n">comment</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> <span class="k">else</span> <span class="n">comment</span> +</span><span id="Generator.pad_comment-501"><a href="#Generator.pad_comment-501"><span class="linenos">501</span></a> <span class="n">comment</span> <span class="o">=</span> <span class="n">comment</span> <span class="o">+</span> <span class="s2">" "</span> <span class="k">if</span> <span class="n">comment</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> <span class="k">else</span> <span class="n">comment</span> +</span><span id="Generator.pad_comment-502"><a href="#Generator.pad_comment-502"><span class="linenos">502</span></a> <span class="k">return</span> <span class="n">comment</span> </span></pre></div> @@ -8262,36 +8352,36 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.maybe_comment"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.maybe_comment-501"><a href="#Generator.maybe_comment-501"><span class="linenos">501</span></a> <span class="k">def</span> <span class="nf">maybe_comment</span><span class="p">(</span> -</span><span id="Generator.maybe_comment-502"><a href="#Generator.maybe_comment-502"><span class="linenos">502</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Generator.maybe_comment-503"><a href="#Generator.maybe_comment-503"><span class="linenos">503</span></a> <span class="n">sql</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> -</span><span id="Generator.maybe_comment-504"><a href="#Generator.maybe_comment-504"><span class="linenos">504</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.maybe_comment-505"><a href="#Generator.maybe_comment-505"><span class="linenos">505</span></a> <span class="n">comments</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">List</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.maybe_comment-506"><a href="#Generator.maybe_comment-506"><span class="linenos">506</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.maybe_comment-507"><a href="#Generator.maybe_comment-507"><span class="linenos">507</span></a> <span class="n">comments</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Generator.maybe_comment-508"><a href="#Generator.maybe_comment-508"><span class="linenos">508</span></a> <span class="p">((</span><span class="n">expression</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">comments</span><span class="p">)</span> <span class="k">if</span> <span class="n">comments</span> <span class="ow">is</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">comments</span><span class="p">)</span> <span class="c1"># type: ignore</span> -</span><span id="Generator.maybe_comment-509"><a href="#Generator.maybe_comment-509"><span class="linenos">509</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">comments</span> -</span><span id="Generator.maybe_comment-510"><a href="#Generator.maybe_comment-510"><span class="linenos">510</span></a> <span class="k">else</span> <span class="kc">None</span> -</span><span id="Generator.maybe_comment-511"><a href="#Generator.maybe_comment-511"><span class="linenos">511</span></a> <span class="p">)</span> -</span><span id="Generator.maybe_comment-512"><a href="#Generator.maybe_comment-512"><span class="linenos">512</span></a> -</span><span id="Generator.maybe_comment-513"><a href="#Generator.maybe_comment-513"><span class="linenos">513</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">comments</span> <span class="ow">or</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">EXCLUDE_COMMENTS</span><span class="p">):</span> -</span><span id="Generator.maybe_comment-514"><a href="#Generator.maybe_comment-514"><span class="linenos">514</span></a> <span class="k">return</span> <span class="n">sql</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.maybe_comment-504"><a href="#Generator.maybe_comment-504"><span class="linenos">504</span></a> <span class="k">def</span> <span class="nf">maybe_comment</span><span class="p">(</span> +</span><span id="Generator.maybe_comment-505"><a href="#Generator.maybe_comment-505"><span class="linenos">505</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Generator.maybe_comment-506"><a href="#Generator.maybe_comment-506"><span class="linenos">506</span></a> <span class="n">sql</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> +</span><span id="Generator.maybe_comment-507"><a href="#Generator.maybe_comment-507"><span class="linenos">507</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.maybe_comment-508"><a href="#Generator.maybe_comment-508"><span class="linenos">508</span></a> <span class="n">comments</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">List</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.maybe_comment-509"><a href="#Generator.maybe_comment-509"><span class="linenos">509</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.maybe_comment-510"><a href="#Generator.maybe_comment-510"><span class="linenos">510</span></a> <span class="n">comments</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Generator.maybe_comment-511"><a href="#Generator.maybe_comment-511"><span class="linenos">511</span></a> <span class="p">((</span><span class="n">expression</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">comments</span><span class="p">)</span> <span class="k">if</span> <span class="n">comments</span> <span class="ow">is</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">comments</span><span class="p">)</span> <span class="c1"># type: ignore</span> +</span><span id="Generator.maybe_comment-512"><a href="#Generator.maybe_comment-512"><span class="linenos">512</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">comments</span> +</span><span id="Generator.maybe_comment-513"><a href="#Generator.maybe_comment-513"><span class="linenos">513</span></a> <span class="k">else</span> <span class="kc">None</span> +</span><span id="Generator.maybe_comment-514"><a href="#Generator.maybe_comment-514"><span class="linenos">514</span></a> <span class="p">)</span> </span><span id="Generator.maybe_comment-515"><a href="#Generator.maybe_comment-515"><span class="linenos">515</span></a> -</span><span id="Generator.maybe_comment-516"><a href="#Generator.maybe_comment-516"><span class="linenos">516</span></a> <span class="n">comments_sql</span> <span class="o">=</span> <span class="s2">" "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> -</span><span id="Generator.maybe_comment-517"><a href="#Generator.maybe_comment-517"><span class="linenos">517</span></a> <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">pad_comment</span><span class="p">(</span><span class="n">comment</span><span class="p">)</span><span class="si">}</span><span class="s2">*/"</span> <span class="k">for</span> <span class="n">comment</span> <span class="ow">in</span> <span class="n">comments</span> <span class="k">if</span> <span class="n">comment</span> -</span><span id="Generator.maybe_comment-518"><a href="#Generator.maybe_comment-518"><span class="linenos">518</span></a> <span class="p">)</span> -</span><span id="Generator.maybe_comment-519"><a href="#Generator.maybe_comment-519"><span class="linenos">519</span></a> -</span><span id="Generator.maybe_comment-520"><a href="#Generator.maybe_comment-520"><span class="linenos">520</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">comments_sql</span><span class="p">:</span> -</span><span id="Generator.maybe_comment-521"><a href="#Generator.maybe_comment-521"><span class="linenos">521</span></a> <span class="k">return</span> <span class="n">sql</span> +</span><span id="Generator.maybe_comment-516"><a href="#Generator.maybe_comment-516"><span class="linenos">516</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">comments</span> <span class="ow">or</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">EXCLUDE_COMMENTS</span><span class="p">):</span> +</span><span id="Generator.maybe_comment-517"><a href="#Generator.maybe_comment-517"><span class="linenos">517</span></a> <span class="k">return</span> <span class="n">sql</span> +</span><span id="Generator.maybe_comment-518"><a href="#Generator.maybe_comment-518"><span class="linenos">518</span></a> +</span><span id="Generator.maybe_comment-519"><a href="#Generator.maybe_comment-519"><span class="linenos">519</span></a> <span class="n">comments_sql</span> <span class="o">=</span> <span class="s2">" "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> +</span><span id="Generator.maybe_comment-520"><a href="#Generator.maybe_comment-520"><span class="linenos">520</span></a> <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">pad_comment</span><span class="p">(</span><span class="n">comment</span><span class="p">)</span><span class="si">}</span><span class="s2">*/"</span> <span class="k">for</span> <span class="n">comment</span> <span class="ow">in</span> <span class="n">comments</span> <span class="k">if</span> <span class="n">comment</span> +</span><span id="Generator.maybe_comment-521"><a href="#Generator.maybe_comment-521"><span class="linenos">521</span></a> <span class="p">)</span> </span><span id="Generator.maybe_comment-522"><a href="#Generator.maybe_comment-522"><span class="linenos">522</span></a> -</span><span id="Generator.maybe_comment-523"><a href="#Generator.maybe_comment-523"><span class="linenos">523</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">WITH_SEPARATED_COMMENTS</span><span class="p">):</span> -</span><span id="Generator.maybe_comment-524"><a href="#Generator.maybe_comment-524"><span class="linenos">524</span></a> <span class="k">return</span> <span class="p">(</span> -</span><span id="Generator.maybe_comment-525"><a href="#Generator.maybe_comment-525"><span class="linenos">525</span></a> <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="si">}{</span><span class="n">comments_sql</span><span class="si">}{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.maybe_comment-526"><a href="#Generator.maybe_comment-526"><span class="linenos">526</span></a> <span class="k">if</span> <span class="n">sql</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">isspace</span><span class="p">()</span> -</span><span id="Generator.maybe_comment-527"><a href="#Generator.maybe_comment-527"><span class="linenos">527</span></a> <span class="k">else</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">comments_sql</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="n">sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.maybe_comment-528"><a href="#Generator.maybe_comment-528"><span class="linenos">528</span></a> <span class="p">)</span> -</span><span id="Generator.maybe_comment-529"><a href="#Generator.maybe_comment-529"><span class="linenos">529</span></a> -</span><span id="Generator.maybe_comment-530"><a href="#Generator.maybe_comment-530"><span class="linenos">530</span></a> <span class="k">return</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="s2"> </span><span class="si">{</span><span class="n">comments_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.maybe_comment-523"><a href="#Generator.maybe_comment-523"><span class="linenos">523</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">comments_sql</span><span class="p">:</span> +</span><span id="Generator.maybe_comment-524"><a href="#Generator.maybe_comment-524"><span class="linenos">524</span></a> <span class="k">return</span> <span class="n">sql</span> +</span><span id="Generator.maybe_comment-525"><a href="#Generator.maybe_comment-525"><span class="linenos">525</span></a> +</span><span id="Generator.maybe_comment-526"><a href="#Generator.maybe_comment-526"><span class="linenos">526</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">WITH_SEPARATED_COMMENTS</span><span class="p">):</span> +</span><span id="Generator.maybe_comment-527"><a href="#Generator.maybe_comment-527"><span class="linenos">527</span></a> <span class="k">return</span> <span class="p">(</span> +</span><span id="Generator.maybe_comment-528"><a href="#Generator.maybe_comment-528"><span class="linenos">528</span></a> <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="si">}{</span><span class="n">comments_sql</span><span class="si">}{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.maybe_comment-529"><a href="#Generator.maybe_comment-529"><span class="linenos">529</span></a> <span class="k">if</span> <span class="n">sql</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">isspace</span><span class="p">()</span> +</span><span id="Generator.maybe_comment-530"><a href="#Generator.maybe_comment-530"><span class="linenos">530</span></a> <span class="k">else</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">comments_sql</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="n">sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.maybe_comment-531"><a href="#Generator.maybe_comment-531"><span class="linenos">531</span></a> <span class="p">)</span> +</span><span id="Generator.maybe_comment-532"><a href="#Generator.maybe_comment-532"><span class="linenos">532</span></a> +</span><span id="Generator.maybe_comment-533"><a href="#Generator.maybe_comment-533"><span class="linenos">533</span></a> <span class="k">return</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="s2"> </span><span class="si">{</span><span class="n">comments_sql</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -8309,15 +8399,15 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.wrap"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.wrap-532"><a href="#Generator.wrap-532"><span class="linenos">532</span></a> <span class="k">def</span> <span class="nf">wrap</span><span class="p">(</span><span class="bp">self</span><span 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="o">|</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.wrap-533"><a href="#Generator.wrap-533"><span class="linenos">533</span></a> <span class="n">this_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span> -</span><span id="Generator.wrap-534"><a href="#Generator.wrap-534"><span class="linenos">534</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><span id="Generator.wrap-535"><a href="#Generator.wrap-535"><span class="linenos">535</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Union</span><span class="p">))</span> -</span><span id="Generator.wrap-536"><a href="#Generator.wrap-536"><span class="linenos">536</span></a> <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">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">),</span> -</span><span id="Generator.wrap-537"><a href="#Generator.wrap-537"><span class="linenos">537</span></a> <span class="n">level</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> -</span><span id="Generator.wrap-538"><a href="#Generator.wrap-538"><span class="linenos">538</span></a> <span class="n">pad</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> -</span><span id="Generator.wrap-539"><a href="#Generator.wrap-539"><span class="linenos">539</span></a> <span class="p">)</span> -</span><span id="Generator.wrap-540"><a href="#Generator.wrap-540"><span class="linenos">540</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">sep</span><span class="p">(</span><span class="s1">''</span><span class="p">)</span><span class="si">}{</span><span class="n">this_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> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.wrap-535"><a href="#Generator.wrap-535"><span class="linenos">535</span></a> <span class="k">def</span> <span class="nf">wrap</span><span class="p">(</span><span class="bp">self</span><span 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="o">|</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.wrap-536"><a href="#Generator.wrap-536"><span class="linenos">536</span></a> <span class="n">this_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span> +</span><span id="Generator.wrap-537"><a href="#Generator.wrap-537"><span class="linenos">537</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><span id="Generator.wrap-538"><a href="#Generator.wrap-538"><span class="linenos">538</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Union</span><span class="p">))</span> +</span><span id="Generator.wrap-539"><a href="#Generator.wrap-539"><span class="linenos">539</span></a> <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">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">),</span> +</span><span id="Generator.wrap-540"><a href="#Generator.wrap-540"><span class="linenos">540</span></a> <span class="n">level</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> +</span><span id="Generator.wrap-541"><a href="#Generator.wrap-541"><span class="linenos">541</span></a> <span class="n">pad</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> +</span><span id="Generator.wrap-542"><a href="#Generator.wrap-542"><span class="linenos">542</span></a> <span class="p">)</span> +</span><span id="Generator.wrap-543"><a href="#Generator.wrap-543"><span class="linenos">543</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">sep</span><span class="p">(</span><span class="s1">''</span><span class="p">)</span><span class="si">}{</span><span class="n">this_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></pre></div> @@ -8335,12 +8425,12 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.no_identify"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.no_identify-542"><a href="#Generator.no_identify-542"><span class="linenos">542</span></a> <span class="k">def</span> <span class="nf">no_identify</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">func</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">[</span><span class="o">...</span><span class="p">,</span> <span class="nb">str</span><span class="p">],</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.no_identify-543"><a href="#Generator.no_identify-543"><span class="linenos">543</span></a> <span class="n">original</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">identify</span> -</span><span id="Generator.no_identify-544"><a href="#Generator.no_identify-544"><span class="linenos">544</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">identify</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Generator.no_identify-545"><a href="#Generator.no_identify-545"><span class="linenos">545</span></a> <span class="n">result</span> <span class="o">=</span> <span class="n">func</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> -</span><span id="Generator.no_identify-546"><a href="#Generator.no_identify-546"><span class="linenos">546</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">identify</span> <span class="o">=</span> <span class="n">original</span> -</span><span id="Generator.no_identify-547"><a href="#Generator.no_identify-547"><span class="linenos">547</span></a> <span class="k">return</span> <span class="n">result</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.no_identify-545"><a href="#Generator.no_identify-545"><span class="linenos">545</span></a> <span class="k">def</span> <span class="nf">no_identify</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">func</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">[</span><span class="o">...</span><span class="p">,</span> <span class="nb">str</span><span class="p">],</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.no_identify-546"><a href="#Generator.no_identify-546"><span class="linenos">546</span></a> <span class="n">original</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">identify</span> +</span><span id="Generator.no_identify-547"><a href="#Generator.no_identify-547"><span class="linenos">547</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">identify</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Generator.no_identify-548"><a href="#Generator.no_identify-548"><span class="linenos">548</span></a> <span class="n">result</span> <span class="o">=</span> <span class="n">func</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> +</span><span id="Generator.no_identify-549"><a href="#Generator.no_identify-549"><span class="linenos">549</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">identify</span> <span class="o">=</span> <span class="n">original</span> +</span><span id="Generator.no_identify-550"><a href="#Generator.no_identify-550"><span class="linenos">550</span></a> <span class="k">return</span> <span class="n">result</span> </span></pre></div> @@ -8358,12 +8448,12 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.normalize_func"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.normalize_func-549"><a href="#Generator.normalize_func-549"><span class="linenos">549</span></a> <span class="k">def</span> <span class="nf">normalize_func</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</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.normalize_func-550"><a href="#Generator.normalize_func-550"><span class="linenos">550</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">normalize_functions</span> <span class="o">==</span> <span class="s2">"upper"</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">normalize_functions</span> <span class="ow">is</span> <span class="kc">True</span><span class="p">:</span> -</span><span id="Generator.normalize_func-551"><a href="#Generator.normalize_func-551"><span class="linenos">551</span></a> <span class="k">return</span> <span class="n">name</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> -</span><span id="Generator.normalize_func-552"><a href="#Generator.normalize_func-552"><span class="linenos">552</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">normalize_functions</span> <span class="o">==</span> <span class="s2">"lower"</span><span class="p">:</span> -</span><span id="Generator.normalize_func-553"><a href="#Generator.normalize_func-553"><span class="linenos">553</span></a> <span class="k">return</span> <span class="n">name</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> -</span><span id="Generator.normalize_func-554"><a href="#Generator.normalize_func-554"><span class="linenos">554</span></a> <span class="k">return</span> <span class="n">name</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.normalize_func-552"><a href="#Generator.normalize_func-552"><span class="linenos">552</span></a> <span class="k">def</span> <span class="nf">normalize_func</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</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.normalize_func-553"><a href="#Generator.normalize_func-553"><span class="linenos">553</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">normalize_functions</span> <span class="o">==</span> <span class="s2">"upper"</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">normalize_functions</span> <span class="ow">is</span> <span class="kc">True</span><span class="p">:</span> +</span><span id="Generator.normalize_func-554"><a href="#Generator.normalize_func-554"><span class="linenos">554</span></a> <span class="k">return</span> <span class="n">name</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> +</span><span id="Generator.normalize_func-555"><a href="#Generator.normalize_func-555"><span class="linenos">555</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">normalize_functions</span> <span class="o">==</span> <span class="s2">"lower"</span><span class="p">:</span> +</span><span id="Generator.normalize_func-556"><a href="#Generator.normalize_func-556"><span class="linenos">556</span></a> <span class="k">return</span> <span class="n">name</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> +</span><span id="Generator.normalize_func-557"><a href="#Generator.normalize_func-557"><span class="linenos">557</span></a> <span class="k">return</span> <span class="n">name</span> </span></pre></div> @@ -8381,26 +8471,26 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.indent"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.indent-556"><a href="#Generator.indent-556"><span class="linenos">556</span></a> <span class="k">def</span> <span class="nf">indent</span><span class="p">(</span> -</span><span id="Generator.indent-557"><a href="#Generator.indent-557"><span class="linenos">557</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Generator.indent-558"><a href="#Generator.indent-558"><span class="linenos">558</span></a> <span class="n">sql</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> -</span><span id="Generator.indent-559"><a href="#Generator.indent-559"><span class="linenos">559</span></a> <span class="n">level</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span> -</span><span id="Generator.indent-560"><a href="#Generator.indent-560"><span class="linenos">560</span></a> <span class="n">pad</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">int</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Generator.indent-561"><a href="#Generator.indent-561"><span class="linenos">561</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.indent-562"><a href="#Generator.indent-562"><span class="linenos">562</span></a> <span class="n">skip_last</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.indent-563"><a href="#Generator.indent-563"><span class="linenos">563</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.indent-564"><a href="#Generator.indent-564"><span class="linenos">564</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.indent-565"><a href="#Generator.indent-565"><span class="linenos">565</span></a> <span class="k">return</span> <span class="n">sql</span> -</span><span id="Generator.indent-566"><a href="#Generator.indent-566"><span class="linenos">566</span></a> -</span><span id="Generator.indent-567"><a href="#Generator.indent-567"><span class="linenos">567</span></a> <span class="n">pad</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">pad</span> <span class="k">if</span> <span class="n">pad</span> <span class="ow">is</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">pad</span> -</span><span id="Generator.indent-568"><a href="#Generator.indent-568"><span class="linenos">568</span></a> <span class="n">lines</span> <span class="o">=</span> <span class="n">sql</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.indent-559"><a href="#Generator.indent-559"><span class="linenos">559</span></a> <span class="k">def</span> <span class="nf">indent</span><span class="p">(</span> +</span><span id="Generator.indent-560"><a href="#Generator.indent-560"><span class="linenos">560</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Generator.indent-561"><a href="#Generator.indent-561"><span class="linenos">561</span></a> <span class="n">sql</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> +</span><span id="Generator.indent-562"><a href="#Generator.indent-562"><span class="linenos">562</span></a> <span class="n">level</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span> +</span><span id="Generator.indent-563"><a href="#Generator.indent-563"><span class="linenos">563</span></a> <span class="n">pad</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">int</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Generator.indent-564"><a href="#Generator.indent-564"><span class="linenos">564</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.indent-565"><a href="#Generator.indent-565"><span class="linenos">565</span></a> <span class="n">skip_last</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.indent-566"><a href="#Generator.indent-566"><span class="linenos">566</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.indent-567"><a href="#Generator.indent-567"><span class="linenos">567</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.indent-568"><a href="#Generator.indent-568"><span class="linenos">568</span></a> <span class="k">return</span> <span class="n">sql</span> </span><span id="Generator.indent-569"><a href="#Generator.indent-569"><span class="linenos">569</span></a> -</span><span id="Generator.indent-570"><a href="#Generator.indent-570"><span class="linenos">570</span></a> <span class="k">return</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><span id="Generator.indent-571"><a href="#Generator.indent-571"><span class="linenos">571</span></a> <span class="n">line</span> -</span><span id="Generator.indent-572"><a href="#Generator.indent-572"><span class="linenos">572</span></a> <span class="k">if</span> <span class="p">(</span><span class="n">skip_first</span> <span class="ow">and</span> <span class="n">i</span> <span class="o">==</span> <span class="mi">0</span><span class="p">)</span> <span class="ow">or</span> <span class="p">(</span><span class="n">skip_last</span> <span class="ow">and</span> <span class="n">i</span> <span class="o">==</span> <span class="nb">len</span><span class="p">(</span><span class="n">lines</span><span class="p">)</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> -</span><span id="Generator.indent-573"><a href="#Generator.indent-573"><span class="linenos">573</span></a> <span class="k">else</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="s1">' '</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="p">(</span><span class="n">level</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="bp">self</span><span class="o">.</span><span class="n">_indent</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">pad</span><span class="p">)</span><span class="si">}{</span><span class="n">line</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.indent-574"><a href="#Generator.indent-574"><span class="linenos">574</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">line</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">lines</span><span class="p">)</span> -</span><span id="Generator.indent-575"><a href="#Generator.indent-575"><span class="linenos">575</span></a> <span class="p">)</span> +</span><span id="Generator.indent-570"><a href="#Generator.indent-570"><span class="linenos">570</span></a> <span class="n">pad</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">pad</span> <span class="k">if</span> <span class="n">pad</span> <span class="ow">is</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">pad</span> +</span><span id="Generator.indent-571"><a href="#Generator.indent-571"><span class="linenos">571</span></a> <span class="n">lines</span> <span class="o">=</span> <span class="n">sql</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">)</span> +</span><span id="Generator.indent-572"><a href="#Generator.indent-572"><span class="linenos">572</span></a> +</span><span id="Generator.indent-573"><a href="#Generator.indent-573"><span class="linenos">573</span></a> <span class="k">return</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><span id="Generator.indent-574"><a href="#Generator.indent-574"><span class="linenos">574</span></a> <span class="n">line</span> +</span><span id="Generator.indent-575"><a href="#Generator.indent-575"><span class="linenos">575</span></a> <span class="k">if</span> <span class="p">(</span><span class="n">skip_first</span> <span class="ow">and</span> <span class="n">i</span> <span class="o">==</span> <span class="mi">0</span><span class="p">)</span> <span class="ow">or</span> <span class="p">(</span><span class="n">skip_last</span> <span class="ow">and</span> <span class="n">i</span> <span class="o">==</span> <span class="nb">len</span><span class="p">(</span><span class="n">lines</span><span class="p">)</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> +</span><span id="Generator.indent-576"><a href="#Generator.indent-576"><span class="linenos">576</span></a> <span class="k">else</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="s1">' '</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="p">(</span><span class="n">level</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="bp">self</span><span class="o">.</span><span class="n">_indent</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">pad</span><span class="p">)</span><span class="si">}{</span><span class="n">line</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.indent-577"><a href="#Generator.indent-577"><span class="linenos">577</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">line</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">lines</span><span class="p">)</span> +</span><span id="Generator.indent-578"><a href="#Generator.indent-578"><span class="linenos">578</span></a> <span class="p">)</span> </span></pre></div> @@ -8418,45 +8508,45 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.sql-577"><a href="#Generator.sql-577"><span class="linenos">577</span></a> <span class="k">def</span> <span class="nf">sql</span><span class="p">(</span> -</span><span id="Generator.sql-578"><a href="#Generator.sql-578"><span class="linenos">578</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Generator.sql-579"><a href="#Generator.sql-579"><span class="linenos">579</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="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><span id="Generator.sql-580"><a href="#Generator.sql-580"><span class="linenos">580</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.sql-581"><a href="#Generator.sql-581"><span class="linenos">581</span></a> <span class="n">comment</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.sql-582"><a href="#Generator.sql-582"><span class="linenos">582</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.sql-583"><a href="#Generator.sql-583"><span class="linenos">583</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expression</span><span class="p">:</span> -</span><span id="Generator.sql-584"><a href="#Generator.sql-584"><span class="linenos">584</span></a> <span class="k">return</span> <span class="s2">""</span> -</span><span id="Generator.sql-585"><a href="#Generator.sql-585"><span class="linenos">585</span></a> -</span><span id="Generator.sql-586"><a href="#Generator.sql-586"><span class="linenos">586</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span> -</span><span id="Generator.sql-587"><a href="#Generator.sql-587"><span class="linenos">587</span></a> <span class="k">return</span> <span class="n">expression</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.sql-580"><a href="#Generator.sql-580"><span class="linenos">580</span></a> <span class="k">def</span> <span class="nf">sql</span><span class="p">(</span> +</span><span id="Generator.sql-581"><a href="#Generator.sql-581"><span class="linenos">581</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Generator.sql-582"><a href="#Generator.sql-582"><span class="linenos">582</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="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><span id="Generator.sql-583"><a href="#Generator.sql-583"><span class="linenos">583</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.sql-584"><a href="#Generator.sql-584"><span class="linenos">584</span></a> <span class="n">comment</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.sql-585"><a href="#Generator.sql-585"><span class="linenos">585</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.sql-586"><a href="#Generator.sql-586"><span class="linenos">586</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expression</span><span class="p">:</span> +</span><span id="Generator.sql-587"><a href="#Generator.sql-587"><span class="linenos">587</span></a> <span class="k">return</span> <span class="s2">""</span> </span><span id="Generator.sql-588"><a href="#Generator.sql-588"><span class="linenos">588</span></a> -</span><span id="Generator.sql-589"><a href="#Generator.sql-589"><span class="linenos">589</span></a> <span class="k">if</span> <span class="n">key</span><span class="p">:</span> -</span><span id="Generator.sql-590"><a href="#Generator.sql-590"><span class="linenos">590</span></a> <span class="n">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.sql-591"><a href="#Generator.sql-591"><span class="linenos">591</span></a> <span class="k">if</span> <span class="n">value</span><span class="p">:</span> -</span><span id="Generator.sql-592"><a href="#Generator.sql-592"><span class="linenos">592</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">value</span><span class="p">)</span> -</span><span id="Generator.sql-593"><a href="#Generator.sql-593"><span class="linenos">593</span></a> <span class="k">return</span> <span class="s2">""</span> -</span><span id="Generator.sql-594"><a href="#Generator.sql-594"><span class="linenos">594</span></a> -</span><span id="Generator.sql-595"><a href="#Generator.sql-595"><span class="linenos">595</span></a> <span class="n">transform</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">TRANSFORMS</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.sql-596"><a href="#Generator.sql-596"><span class="linenos">596</span></a> -</span><span id="Generator.sql-597"><a href="#Generator.sql-597"><span class="linenos">597</span></a> <span class="k">if</span> <span class="nb">callable</span><span class="p">(</span><span class="n">transform</span><span class="p">):</span> -</span><span id="Generator.sql-598"><a href="#Generator.sql-598"><span class="linenos">598</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="n">transform</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> -</span><span id="Generator.sql-599"><a href="#Generator.sql-599"><span class="linenos">599</span></a> <span class="k">elif</span> <span class="n">transform</span><span class="p">:</span> -</span><span id="Generator.sql-600"><a href="#Generator.sql-600"><span class="linenos">600</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="n">transform</span> -</span><span id="Generator.sql-601"><a href="#Generator.sql-601"><span class="linenos">601</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="Generator.sql-602"><a href="#Generator.sql-602"><span class="linenos">602</span></a> <span class="n">exp_handler_name</span> <span class="o">=</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">key</span><span class="si">}</span><span class="s2">_sql"</span> -</span><span id="Generator.sql-603"><a href="#Generator.sql-603"><span class="linenos">603</span></a> -</span><span id="Generator.sql-604"><a href="#Generator.sql-604"><span class="linenos">604</span></a> <span class="k">if</span> <span class="nb">hasattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">exp_handler_name</span><span class="p">):</span> -</span><span id="Generator.sql-605"><a href="#Generator.sql-605"><span class="linenos">605</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">exp_handler_name</span><span class="p">)(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Generator.sql-606"><a href="#Generator.sql-606"><span class="linenos">606</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Func</span><span class="p">):</span> -</span><span id="Generator.sql-607"><a href="#Generator.sql-607"><span class="linenos">607</span></a> <span class="n">sql</span> <span class="o">=</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.sql-608"><a href="#Generator.sql-608"><span class="linenos">608</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Property</span><span class="p">):</span> -</span><span id="Generator.sql-609"><a href="#Generator.sql-609"><span class="linenos">609</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">property_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Generator.sql-610"><a href="#Generator.sql-610"><span class="linenos">610</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator.sql-611"><a href="#Generator.sql-611"><span class="linenos">611</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unsupported expression type </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.sql-612"><a href="#Generator.sql-612"><span class="linenos">612</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator.sql-613"><a href="#Generator.sql-613"><span class="linenos">613</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Expected an Expression. Received </span><span class="si">{</span><span class="nb">type</span><span class="p">(</span><span class="n">expression</span><span class="p">)</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 class="p">)</span> -</span><span id="Generator.sql-614"><a href="#Generator.sql-614"><span class="linenos">614</span></a> -</span><span id="Generator.sql-615"><a href="#Generator.sql-615"><span class="linenos">615</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">maybe_comment</span><span class="p">(</span><span class="n">sql</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">comments</span> <span class="ow">and</span> <span class="n">comment</span> <span class="k">else</span> <span class="n">sql</span> +</span><span id="Generator.sql-589"><a href="#Generator.sql-589"><span class="linenos">589</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span> +</span><span id="Generator.sql-590"><a href="#Generator.sql-590"><span class="linenos">590</span></a> <span class="k">return</span> <span class="n">expression</span> +</span><span id="Generator.sql-591"><a href="#Generator.sql-591"><span class="linenos">591</span></a> +</span><span id="Generator.sql-592"><a href="#Generator.sql-592"><span class="linenos">592</span></a> <span class="k">if</span> <span class="n">key</span><span class="p">:</span> +</span><span id="Generator.sql-593"><a href="#Generator.sql-593"><span class="linenos">593</span></a> <span class="n">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.sql-594"><a href="#Generator.sql-594"><span class="linenos">594</span></a> <span class="k">if</span> <span class="n">value</span><span class="p">:</span> +</span><span id="Generator.sql-595"><a href="#Generator.sql-595"><span class="linenos">595</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">value</span><span class="p">)</span> +</span><span id="Generator.sql-596"><a href="#Generator.sql-596"><span class="linenos">596</span></a> <span class="k">return</span> <span class="s2">""</span> +</span><span id="Generator.sql-597"><a href="#Generator.sql-597"><span class="linenos">597</span></a> +</span><span id="Generator.sql-598"><a href="#Generator.sql-598"><span class="linenos">598</span></a> <span class="n">transform</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">TRANSFORMS</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.sql-599"><a href="#Generator.sql-599"><span class="linenos">599</span></a> +</span><span id="Generator.sql-600"><a href="#Generator.sql-600"><span class="linenos">600</span></a> <span class="k">if</span> <span class="nb">callable</span><span class="p">(</span><span class="n">transform</span><span class="p">):</span> +</span><span id="Generator.sql-601"><a href="#Generator.sql-601"><span class="linenos">601</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="n">transform</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> +</span><span id="Generator.sql-602"><a href="#Generator.sql-602"><span class="linenos">602</span></a> <span class="k">elif</span> <span class="n">transform</span><span class="p">:</span> +</span><span id="Generator.sql-603"><a href="#Generator.sql-603"><span class="linenos">603</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="n">transform</span> +</span><span id="Generator.sql-604"><a href="#Generator.sql-604"><span class="linenos">604</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="Generator.sql-605"><a href="#Generator.sql-605"><span class="linenos">605</span></a> <span class="n">exp_handler_name</span> <span class="o">=</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">key</span><span class="si">}</span><span class="s2">_sql"</span> +</span><span id="Generator.sql-606"><a href="#Generator.sql-606"><span class="linenos">606</span></a> +</span><span id="Generator.sql-607"><a href="#Generator.sql-607"><span class="linenos">607</span></a> <span class="k">if</span> <span class="nb">hasattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">exp_handler_name</span><span class="p">):</span> +</span><span id="Generator.sql-608"><a href="#Generator.sql-608"><span class="linenos">608</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">exp_handler_name</span><span class="p">)(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Generator.sql-609"><a href="#Generator.sql-609"><span class="linenos">609</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Func</span><span class="p">):</span> +</span><span id="Generator.sql-610"><a href="#Generator.sql-610"><span class="linenos">610</span></a> <span class="n">sql</span> <span class="o">=</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.sql-611"><a href="#Generator.sql-611"><span class="linenos">611</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Property</span><span class="p">):</span> +</span><span id="Generator.sql-612"><a href="#Generator.sql-612"><span class="linenos">612</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">property_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Generator.sql-613"><a href="#Generator.sql-613"><span class="linenos">613</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator.sql-614"><a href="#Generator.sql-614"><span class="linenos">614</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unsupported expression type </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.sql-615"><a href="#Generator.sql-615"><span class="linenos">615</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator.sql-616"><a href="#Generator.sql-616"><span class="linenos">616</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Expected an Expression. Received </span><span class="si">{</span><span class="nb">type</span><span class="p">(</span><span class="n">expression</span><span class="p">)</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 class="p">)</span> +</span><span id="Generator.sql-617"><a href="#Generator.sql-617"><span class="linenos">617</span></a> +</span><span id="Generator.sql-618"><a href="#Generator.sql-618"><span class="linenos">618</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">maybe_comment</span><span class="p">(</span><span class="n">sql</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">comments</span> <span class="ow">and</span> <span class="n">comment</span> <span class="k">else</span> <span class="n">sql</span> </span></pre></div> @@ -8474,10 +8564,10 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.uncache_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.uncache_sql-617"><a href="#Generator.uncache_sql-617"><span class="linenos">617</span></a> <span class="k">def</span> <span class="nf">uncache_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Uncache</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.uncache_sql-618"><a href="#Generator.uncache_sql-618"><span class="linenos">618</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">"this"</span><span class="p">)</span> -</span><span id="Generator.uncache_sql-619"><a href="#Generator.uncache_sql-619"><span class="linenos">619</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.uncache_sql-620"><a href="#Generator.uncache_sql-620"><span class="linenos">620</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"UNCACHE TABLE</span><span class="si">{</span><span class="n">exists_sql</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">table</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.uncache_sql-620"><a href="#Generator.uncache_sql-620"><span class="linenos">620</span></a> <span class="k">def</span> <span class="nf">uncache_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Uncache</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.uncache_sql-621"><a href="#Generator.uncache_sql-621"><span class="linenos">621</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">"this"</span><span class="p">)</span> +</span><span id="Generator.uncache_sql-622"><a href="#Generator.uncache_sql-622"><span class="linenos">622</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.uncache_sql-623"><a href="#Generator.uncache_sql-623"><span class="linenos">623</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"UNCACHE TABLE</span><span class="si">{</span><span class="n">exists_sql</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">table</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -8495,15 +8585,15 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.cache_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.cache_sql-622"><a href="#Generator.cache_sql-622"><span class="linenos">622</span></a> <span class="k">def</span> <span class="nf">cache_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cache</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.cache_sql-623"><a href="#Generator.cache_sql-623"><span class="linenos">623</span></a> <span class="n">lazy</span> <span class="o">=</span> <span class="s2">" LAZY"</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">"lazy"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.cache_sql-624"><a href="#Generator.cache_sql-624"><span class="linenos">624</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">"this"</span><span class="p">)</span> -</span><span id="Generator.cache_sql-625"><a href="#Generator.cache_sql-625"><span class="linenos">625</span></a> <span class="n">options</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">"options"</span><span class="p">)</span> -</span><span id="Generator.cache_sql-626"><a href="#Generator.cache_sql-626"><span class="linenos">626</span></a> <span class="n">options</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" OPTIONS(</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">options</span><span class="p">[</span><span class="mi">0</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">options</span><span class="p">[</span><span class="mi">1</span><span class="p">])</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.cache_sql-627"><a href="#Generator.cache_sql-627"><span class="linenos">627</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">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> -</span><span id="Generator.cache_sql-628"><a href="#Generator.cache_sql-628"><span class="linenos">628</span></a> <span class="n">sql</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">sep</span><span class="p">()</span><span class="si">}{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">sql</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.cache_sql-629"><a href="#Generator.cache_sql-629"><span class="linenos">629</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"CACHE</span><span class="si">{</span><span class="n">lazy</span><span class="si">}</span><span class="s2"> TABLE </span><span class="si">{</span><span class="n">table</span><span class="si">}{</span><span class="n">options</span><span class="si">}{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.cache_sql-630"><a href="#Generator.cache_sql-630"><span class="linenos">630</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.cache_sql-625"><a href="#Generator.cache_sql-625"><span class="linenos">625</span></a> <span class="k">def</span> <span class="nf">cache_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cache</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.cache_sql-626"><a href="#Generator.cache_sql-626"><span class="linenos">626</span></a> <span class="n">lazy</span> <span class="o">=</span> <span class="s2">" LAZY"</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">"lazy"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.cache_sql-627"><a href="#Generator.cache_sql-627"><span class="linenos">627</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">"this"</span><span class="p">)</span> +</span><span id="Generator.cache_sql-628"><a href="#Generator.cache_sql-628"><span class="linenos">628</span></a> <span class="n">options</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">"options"</span><span class="p">)</span> +</span><span id="Generator.cache_sql-629"><a href="#Generator.cache_sql-629"><span class="linenos">629</span></a> <span class="n">options</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" OPTIONS(</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">options</span><span class="p">[</span><span class="mi">0</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">options</span><span class="p">[</span><span class="mi">1</span><span class="p">])</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.cache_sql-630"><a href="#Generator.cache_sql-630"><span class="linenos">630</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">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> +</span><span id="Generator.cache_sql-631"><a href="#Generator.cache_sql-631"><span class="linenos">631</span></a> <span class="n">sql</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">sep</span><span class="p">()</span><span class="si">}{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">sql</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.cache_sql-632"><a href="#Generator.cache_sql-632"><span class="linenos">632</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"CACHE</span><span class="si">{</span><span class="n">lazy</span><span class="si">}</span><span class="s2"> TABLE </span><span class="si">{</span><span class="n">table</span><span class="si">}{</span><span class="n">options</span><span class="si">}{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.cache_sql-633"><a href="#Generator.cache_sql-633"><span class="linenos">633</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> @@ -8521,11 +8611,11 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.characterset_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.characterset_sql-632"><a href="#Generator.characterset_sql-632"><span class="linenos">632</span></a> <span class="k">def</span> <span class="nf">characterset_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">CharacterSet</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.characterset_sql-633"><a href="#Generator.characterset_sql-633"><span class="linenos">633</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">parent</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">):</span> -</span><span id="Generator.characterset_sql-634"><a href="#Generator.characterset_sql-634"><span class="linenos">634</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CHAR CHARACTER SET </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.characterset_sql-635"><a href="#Generator.characterset_sql-635"><span class="linenos">635</span></a> <span class="n">default</span> <span class="o">=</span> <span class="s2">"DEFAULT "</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">"default"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.characterset_sql-636"><a href="#Generator.characterset_sql-636"><span class="linenos">636</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">default</span><span class="si">}</span><span class="s2">CHARACTER SET=</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.characterset_sql-635"><a href="#Generator.characterset_sql-635"><span class="linenos">635</span></a> <span class="k">def</span> <span class="nf">characterset_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">CharacterSet</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.characterset_sql-636"><a href="#Generator.characterset_sql-636"><span class="linenos">636</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">parent</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">):</span> +</span><span id="Generator.characterset_sql-637"><a href="#Generator.characterset_sql-637"><span class="linenos">637</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CHAR CHARACTER SET </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.characterset_sql-638"><a href="#Generator.characterset_sql-638"><span class="linenos">638</span></a> <span class="n">default</span> <span class="o">=</span> <span class="s2">"DEFAULT "</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">"default"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.characterset_sql-639"><a href="#Generator.characterset_sql-639"><span class="linenos">639</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">default</span><span class="si">}</span><span class="s2">CHARACTER SET=</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> @@ -8543,25 +8633,25 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.column_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.column_sql-638"><a href="#Generator.column_sql-638"><span class="linenos">638</span></a> <span class="k">def</span> <span class="nf">column_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.column_sql-639"><a href="#Generator.column_sql-639"><span class="linenos">639</span></a> <span class="n">join_mark</span> <span class="o">=</span> <span class="s2">" (+)"</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">"join_mark"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.column_sql-640"><a href="#Generator.column_sql-640"><span class="linenos">640</span></a> -</span><span id="Generator.column_sql-641"><a href="#Generator.column_sql-641"><span class="linenos">641</span></a> <span class="k">if</span> <span class="n">join_mark</span> <span class="ow">and</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">COLUMN_JOIN_MARKS_SUPPORTED</span><span class="p">:</span> -</span><span id="Generator.column_sql-642"><a href="#Generator.column_sql-642"><span class="linenos">642</span></a> <span class="n">join_mark</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator.column_sql-643"><a href="#Generator.column_sql-643"><span class="linenos">643</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Outer join syntax using the (+) operator is not supported."</span><span class="p">)</span> -</span><span id="Generator.column_sql-644"><a href="#Generator.column_sql-644"><span class="linenos">644</span></a> -</span><span id="Generator.column_sql-645"><a href="#Generator.column_sql-645"><span class="linenos">645</span></a> <span class="n">column</span> <span class="o">=</span> <span class="s2">"."</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> -</span><span id="Generator.column_sql-646"><a href="#Generator.column_sql-646"><span class="linenos">646</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">part</span><span class="p">)</span> -</span><span id="Generator.column_sql-647"><a href="#Generator.column_sql-647"><span class="linenos">647</span></a> <span class="k">for</span> <span class="n">part</span> <span class="ow">in</span> <span class="p">(</span> -</span><span id="Generator.column_sql-648"><a href="#Generator.column_sql-648"><span class="linenos">648</span></a> <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">"catalog"</span><span class="p">),</span> -</span><span id="Generator.column_sql-649"><a href="#Generator.column_sql-649"><span class="linenos">649</span></a> <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">"db"</span><span class="p">),</span> -</span><span id="Generator.column_sql-650"><a href="#Generator.column_sql-650"><span class="linenos">650</span></a> <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">"table"</span><span class="p">),</span> -</span><span id="Generator.column_sql-651"><a href="#Generator.column_sql-651"><span class="linenos">651</span></a> <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">"this"</span><span class="p">),</span> -</span><span id="Generator.column_sql-652"><a href="#Generator.column_sql-652"><span class="linenos">652</span></a> <span class="p">)</span> -</span><span id="Generator.column_sql-653"><a href="#Generator.column_sql-653"><span class="linenos">653</span></a> <span class="k">if</span> <span class="n">part</span> -</span><span id="Generator.column_sql-654"><a href="#Generator.column_sql-654"><span class="linenos">654</span></a> <span class="p">)</span> -</span><span id="Generator.column_sql-655"><a href="#Generator.column_sql-655"><span class="linenos">655</span></a> -</span><span id="Generator.column_sql-656"><a href="#Generator.column_sql-656"><span class="linenos">656</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">column</span><span class="si">}{</span><span class="n">join_mark</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.column_sql-641"><a href="#Generator.column_sql-641"><span class="linenos">641</span></a> <span class="k">def</span> <span class="nf">column_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.column_sql-642"><a href="#Generator.column_sql-642"><span class="linenos">642</span></a> <span class="n">join_mark</span> <span class="o">=</span> <span class="s2">" (+)"</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">"join_mark"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.column_sql-643"><a href="#Generator.column_sql-643"><span class="linenos">643</span></a> +</span><span id="Generator.column_sql-644"><a href="#Generator.column_sql-644"><span class="linenos">644</span></a> <span class="k">if</span> <span class="n">join_mark</span> <span class="ow">and</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">COLUMN_JOIN_MARKS_SUPPORTED</span><span class="p">:</span> +</span><span id="Generator.column_sql-645"><a href="#Generator.column_sql-645"><span class="linenos">645</span></a> <span class="n">join_mark</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator.column_sql-646"><a href="#Generator.column_sql-646"><span class="linenos">646</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Outer join syntax using the (+) operator is not supported."</span><span class="p">)</span> +</span><span id="Generator.column_sql-647"><a href="#Generator.column_sql-647"><span class="linenos">647</span></a> +</span><span id="Generator.column_sql-648"><a href="#Generator.column_sql-648"><span class="linenos">648</span></a> <span class="n">column</span> <span class="o">=</span> <span class="s2">"."</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> +</span><span id="Generator.column_sql-649"><a href="#Generator.column_sql-649"><span class="linenos">649</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">part</span><span class="p">)</span> +</span><span id="Generator.column_sql-650"><a href="#Generator.column_sql-650"><span class="linenos">650</span></a> <span class="k">for</span> <span class="n">part</span> <span class="ow">in</span> <span class="p">(</span> +</span><span id="Generator.column_sql-651"><a href="#Generator.column_sql-651"><span class="linenos">651</span></a> <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">"catalog"</span><span class="p">),</span> +</span><span id="Generator.column_sql-652"><a href="#Generator.column_sql-652"><span class="linenos">652</span></a> <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">"db"</span><span class="p">),</span> +</span><span id="Generator.column_sql-653"><a href="#Generator.column_sql-653"><span class="linenos">653</span></a> <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">"table"</span><span class="p">),</span> +</span><span id="Generator.column_sql-654"><a href="#Generator.column_sql-654"><span class="linenos">654</span></a> <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">"this"</span><span class="p">),</span> +</span><span id="Generator.column_sql-655"><a href="#Generator.column_sql-655"><span class="linenos">655</span></a> <span class="p">)</span> +</span><span id="Generator.column_sql-656"><a href="#Generator.column_sql-656"><span class="linenos">656</span></a> <span class="k">if</span> <span class="n">part</span> +</span><span id="Generator.column_sql-657"><a href="#Generator.column_sql-657"><span class="linenos">657</span></a> <span class="p">)</span> +</span><span id="Generator.column_sql-658"><a href="#Generator.column_sql-658"><span class="linenos">658</span></a> +</span><span id="Generator.column_sql-659"><a href="#Generator.column_sql-659"><span class="linenos">659</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">column</span><span class="si">}{</span><span class="n">join_mark</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -8579,11 +8669,11 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.columnposition_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.columnposition_sql-658"><a href="#Generator.columnposition_sql-658"><span class="linenos">658</span></a> <span class="k">def</span> <span class="nf">columnposition_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ColumnPosition</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.columnposition_sql-659"><a href="#Generator.columnposition_sql-659"><span class="linenos">659</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.columnposition_sql-660"><a href="#Generator.columnposition_sql-660"><span class="linenos">660</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.columnposition_sql-661"><a href="#Generator.columnposition_sql-661"><span class="linenos">661</span></a> <span class="n">position</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"position"</span><span class="p">)</span> -</span><span id="Generator.columnposition_sql-662"><a href="#Generator.columnposition_sql-662"><span class="linenos">662</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">position</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.columnposition_sql-661"><a href="#Generator.columnposition_sql-661"><span class="linenos">661</span></a> <span class="k">def</span> <span class="nf">columnposition_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ColumnPosition</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.columnposition_sql-662"><a href="#Generator.columnposition_sql-662"><span class="linenos">662</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.columnposition_sql-663"><a href="#Generator.columnposition_sql-663"><span class="linenos">663</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.columnposition_sql-664"><a href="#Generator.columnposition_sql-664"><span class="linenos">664</span></a> <span class="n">position</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"position"</span><span class="p">)</span> +</span><span id="Generator.columnposition_sql-665"><a href="#Generator.columnposition_sql-665"><span class="linenos">665</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">position</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -8601,20 +8691,20 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.columndef_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.columndef_sql-664"><a href="#Generator.columndef_sql-664"><span class="linenos">664</span></a> <span class="k">def</span> <span class="nf">columndef_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ColumnDef</span><span class="p">,</span> <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 class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.columndef_sql-665"><a href="#Generator.columndef_sql-665"><span class="linenos">665</span></a> <span class="n">column</span> <span class="o">=</span> <span class="bp">self</span><span 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.columndef_sql-666"><a href="#Generator.columndef_sql-666"><span class="linenos">666</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.columndef_sql-667"><a href="#Generator.columndef_sql-667"><span class="linenos">667</span></a> <span class="n">constraints</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">"constraints"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</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.columndef_sql-668"><a href="#Generator.columndef_sql-668"><span class="linenos">668</span></a> <span class="n">exists</span> <span class="o">=</span> <span class="s2">"IF NOT 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.columndef_sql-669"><a href="#Generator.columndef_sql-669"><span class="linenos">669</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">sep</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.columndef_sql-670"><a href="#Generator.columndef_sql-670"><span class="linenos">670</span></a> <span class="n">constraints</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">constraints</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">constraints</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.columndef_sql-671"><a href="#Generator.columndef_sql-671"><span class="linenos">671</span></a> <span class="n">position</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"position"</span><span class="p">)</span> -</span><span id="Generator.columndef_sql-672"><a href="#Generator.columndef_sql-672"><span class="linenos">672</span></a> <span class="n">position</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">position</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">position</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.columndef_sql-673"><a href="#Generator.columndef_sql-673"><span class="linenos">673</span></a> -</span><span id="Generator.columndef_sql-674"><a href="#Generator.columndef_sql-674"><span class="linenos">674</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">find</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">ComputedColumnConstraint</span><span class="p">)</span> <span class="ow">and</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">COMPUTED_COLUMN_WITH_TYPE</span><span class="p">:</span> -</span><span id="Generator.columndef_sql-675"><a href="#Generator.columndef_sql-675"><span class="linenos">675</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="s2">""</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.columndef_sql-667"><a href="#Generator.columndef_sql-667"><span class="linenos">667</span></a> <span class="k">def</span> <span class="nf">columndef_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ColumnDef</span><span class="p">,</span> <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 class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.columndef_sql-668"><a href="#Generator.columndef_sql-668"><span class="linenos">668</span></a> <span class="n">column</span> <span class="o">=</span> <span class="bp">self</span><span 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.columndef_sql-669"><a href="#Generator.columndef_sql-669"><span class="linenos">669</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.columndef_sql-670"><a href="#Generator.columndef_sql-670"><span class="linenos">670</span></a> <span class="n">constraints</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">"constraints"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</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.columndef_sql-671"><a href="#Generator.columndef_sql-671"><span class="linenos">671</span></a> <span class="n">exists</span> <span class="o">=</span> <span class="s2">"IF NOT 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.columndef_sql-672"><a href="#Generator.columndef_sql-672"><span class="linenos">672</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">sep</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.columndef_sql-673"><a href="#Generator.columndef_sql-673"><span class="linenos">673</span></a> <span class="n">constraints</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">constraints</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">constraints</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.columndef_sql-674"><a href="#Generator.columndef_sql-674"><span class="linenos">674</span></a> <span class="n">position</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"position"</span><span class="p">)</span> +</span><span id="Generator.columndef_sql-675"><a href="#Generator.columndef_sql-675"><span class="linenos">675</span></a> <span class="n">position</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">position</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">position</span> <span class="k">else</span> <span class="s2">""</span> </span><span id="Generator.columndef_sql-676"><a href="#Generator.columndef_sql-676"><span class="linenos">676</span></a> -</span><span id="Generator.columndef_sql-677"><a href="#Generator.columndef_sql-677"><span class="linenos">677</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">exists</span><span class="si">}{</span><span class="n">column</span><span class="si">}{</span><span class="n">kind</span><span class="si">}{</span><span class="n">constraints</span><span class="si">}{</span><span class="n">position</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.columndef_sql-677"><a href="#Generator.columndef_sql-677"><span class="linenos">677</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">find</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">ComputedColumnConstraint</span><span class="p">)</span> <span class="ow">and</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">COMPUTED_COLUMN_WITH_TYPE</span><span class="p">:</span> +</span><span id="Generator.columndef_sql-678"><a href="#Generator.columndef_sql-678"><span class="linenos">678</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator.columndef_sql-679"><a href="#Generator.columndef_sql-679"><span class="linenos">679</span></a> +</span><span id="Generator.columndef_sql-680"><a href="#Generator.columndef_sql-680"><span class="linenos">680</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">exists</span><span class="si">}{</span><span class="n">column</span><span class="si">}{</span><span class="n">kind</span><span class="si">}{</span><span class="n">constraints</span><span class="si">}{</span><span class="n">position</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -8632,10 +8722,10 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.columnconstraint_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.columnconstraint_sql-679"><a href="#Generator.columnconstraint_sql-679"><span class="linenos">679</span></a> <span class="k">def</span> <span class="nf">columnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.columnconstraint_sql-680"><a href="#Generator.columnconstraint_sql-680"><span class="linenos">680</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.columnconstraint_sql-681"><a href="#Generator.columnconstraint_sql-681"><span class="linenos">681</span></a> <span class="n">kind_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">"kind"</span><span class="p">)</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> -</span><span id="Generator.columnconstraint_sql-682"><a href="#Generator.columnconstraint_sql-682"><span class="linenos">682</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CONSTRAINT </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_sql</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="n">kind_sql</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.columnconstraint_sql-682"><a href="#Generator.columnconstraint_sql-682"><span class="linenos">682</span></a> <span class="k">def</span> <span class="nf">columnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.columnconstraint_sql-683"><a href="#Generator.columnconstraint_sql-683"><span class="linenos">683</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.columnconstraint_sql-684"><a href="#Generator.columnconstraint_sql-684"><span class="linenos">684</span></a> <span class="n">kind_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">"kind"</span><span class="p">)</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> +</span><span id="Generator.columnconstraint_sql-685"><a href="#Generator.columnconstraint_sql-685"><span class="linenos">685</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CONSTRAINT </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_sql</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="n">kind_sql</span> </span></pre></div> @@ -8653,15 +8743,15 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.computedcolumnconstraint_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.computedcolumnconstraint_sql-684"><a href="#Generator.computedcolumnconstraint_sql-684"><span class="linenos">684</span></a> <span class="k">def</span> <span class="nf">computedcolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ComputedColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.computedcolumnconstraint_sql-685"><a href="#Generator.computedcolumnconstraint_sql-685"><span class="linenos">685</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.computedcolumnconstraint_sql-686"><a href="#Generator.computedcolumnconstraint_sql-686"><span class="linenos">686</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">"not_null"</span><span class="p">):</span> -</span><span id="Generator.computedcolumnconstraint_sql-687"><a href="#Generator.computedcolumnconstraint_sql-687"><span class="linenos">687</span></a> <span class="n">persisted</span> <span class="o">=</span> <span class="s2">" PERSISTED NOT NULL"</span> -</span><span id="Generator.computedcolumnconstraint_sql-688"><a href="#Generator.computedcolumnconstraint_sql-688"><span class="linenos">688</span></a> <span class="k">elif</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">"persisted"</span><span class="p">):</span> -</span><span id="Generator.computedcolumnconstraint_sql-689"><a href="#Generator.computedcolumnconstraint_sql-689"><span class="linenos">689</span></a> <span class="n">persisted</span> <span class="o">=</span> <span class="s2">" PERSISTED"</span> -</span><span id="Generator.computedcolumnconstraint_sql-690"><a href="#Generator.computedcolumnconstraint_sql-690"><span class="linenos">690</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator.computedcolumnconstraint_sql-691"><a href="#Generator.computedcolumnconstraint_sql-691"><span class="linenos">691</span></a> <span class="n">persisted</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator.computedcolumnconstraint_sql-692"><a href="#Generator.computedcolumnconstraint_sql-692"><span class="linenos">692</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"AS </span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">persisted</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.computedcolumnconstraint_sql-687"><a href="#Generator.computedcolumnconstraint_sql-687"><span class="linenos">687</span></a> <span class="k">def</span> <span class="nf">computedcolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ComputedColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.computedcolumnconstraint_sql-688"><a href="#Generator.computedcolumnconstraint_sql-688"><span class="linenos">688</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.computedcolumnconstraint_sql-689"><a href="#Generator.computedcolumnconstraint_sql-689"><span class="linenos">689</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">"not_null"</span><span class="p">):</span> +</span><span id="Generator.computedcolumnconstraint_sql-690"><a href="#Generator.computedcolumnconstraint_sql-690"><span class="linenos">690</span></a> <span class="n">persisted</span> <span class="o">=</span> <span class="s2">" PERSISTED NOT NULL"</span> +</span><span id="Generator.computedcolumnconstraint_sql-691"><a href="#Generator.computedcolumnconstraint_sql-691"><span class="linenos">691</span></a> <span class="k">elif</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">"persisted"</span><span class="p">):</span> +</span><span id="Generator.computedcolumnconstraint_sql-692"><a href="#Generator.computedcolumnconstraint_sql-692"><span class="linenos">692</span></a> <span class="n">persisted</span> <span class="o">=</span> <span class="s2">" PERSISTED"</span> +</span><span id="Generator.computedcolumnconstraint_sql-693"><a href="#Generator.computedcolumnconstraint_sql-693"><span class="linenos">693</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator.computedcolumnconstraint_sql-694"><a href="#Generator.computedcolumnconstraint_sql-694"><span class="linenos">694</span></a> <span class="n">persisted</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator.computedcolumnconstraint_sql-695"><a href="#Generator.computedcolumnconstraint_sql-695"><span class="linenos">695</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"AS </span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">persisted</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -8679,8 +8769,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.autoincrementcolumnconstraint_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.autoincrementcolumnconstraint_sql-694"><a href="#Generator.autoincrementcolumnconstraint_sql-694"><span class="linenos">694</span></a> <span class="k">def</span> <span class="nf">autoincrementcolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">_</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.autoincrementcolumnconstraint_sql-695"><a href="#Generator.autoincrementcolumnconstraint_sql-695"><span class="linenos">695</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">token_sql</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">AUTO_INCREMENT</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.autoincrementcolumnconstraint_sql-697"><a href="#Generator.autoincrementcolumnconstraint_sql-697"><span class="linenos">697</span></a> <span class="k">def</span> <span class="nf">autoincrementcolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">_</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.autoincrementcolumnconstraint_sql-698"><a href="#Generator.autoincrementcolumnconstraint_sql-698"><span class="linenos">698</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">token_sql</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">AUTO_INCREMENT</span><span class="p">)</span> </span></pre></div> @@ -8698,13 +8788,13 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.compresscolumnconstraint_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.compresscolumnconstraint_sql-697"><a href="#Generator.compresscolumnconstraint_sql-697"><span class="linenos">697</span></a> <span class="k">def</span> <span class="nf">compresscolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">CompressColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.compresscolumnconstraint_sql-698"><a href="#Generator.compresscolumnconstraint_sql-698"><span class="linenos">698</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">this</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span> -</span><span id="Generator.compresscolumnconstraint_sql-699"><a href="#Generator.compresscolumnconstraint_sql-699"><span class="linenos">699</span></a> <span class="n">this</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="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">"this"</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.compresscolumnconstraint_sql-700"><a href="#Generator.compresscolumnconstraint_sql-700"><span class="linenos">700</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator.compresscolumnconstraint_sql-701"><a href="#Generator.compresscolumnconstraint_sql-701"><span class="linenos">701</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.compresscolumnconstraint_sql-702"><a href="#Generator.compresscolumnconstraint_sql-702"><span class="linenos">702</span></a> -</span><span id="Generator.compresscolumnconstraint_sql-703"><a href="#Generator.compresscolumnconstraint_sql-703"><span class="linenos">703</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"COMPRESS </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.compresscolumnconstraint_sql-700"><a href="#Generator.compresscolumnconstraint_sql-700"><span class="linenos">700</span></a> <span class="k">def</span> <span class="nf">compresscolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">CompressColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.compresscolumnconstraint_sql-701"><a href="#Generator.compresscolumnconstraint_sql-701"><span class="linenos">701</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">this</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span> +</span><span id="Generator.compresscolumnconstraint_sql-702"><a href="#Generator.compresscolumnconstraint_sql-702"><span class="linenos">702</span></a> <span class="n">this</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="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">"this"</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.compresscolumnconstraint_sql-703"><a href="#Generator.compresscolumnconstraint_sql-703"><span class="linenos">703</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator.compresscolumnconstraint_sql-704"><a href="#Generator.compresscolumnconstraint_sql-704"><span class="linenos">704</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.compresscolumnconstraint_sql-705"><a href="#Generator.compresscolumnconstraint_sql-705"><span class="linenos">705</span></a> +</span><span id="Generator.compresscolumnconstraint_sql-706"><a href="#Generator.compresscolumnconstraint_sql-706"><span class="linenos">706</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"COMPRESS </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -8722,38 +8812,38 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.generatedasidentitycolumnconstraint_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.generatedasidentitycolumnconstraint_sql-705"><a href="#Generator.generatedasidentitycolumnconstraint_sql-705"><span class="linenos">705</span></a> <span class="k">def</span> <span class="nf">generatedasidentitycolumnconstraint_sql</span><span class="p">(</span> -</span><span id="Generator.generatedasidentitycolumnconstraint_sql-706"><a href="#Generator.generatedasidentitycolumnconstraint_sql-706"><span class="linenos">706</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GeneratedAsIdentityColumnConstraint</span> -</span><span id="Generator.generatedasidentitycolumnconstraint_sql-707"><a href="#Generator.generatedasidentitycolumnconstraint_sql-707"><span class="linenos">707</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.generatedasidentitycolumnconstraint_sql-708"><a href="#Generator.generatedasidentitycolumnconstraint_sql-708"><span class="linenos">708</span></a> <span class="n">this</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator.generatedasidentitycolumnconstraint_sql-709"><a href="#Generator.generatedasidentitycolumnconstraint_sql-709"><span class="linenos">709</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Generator.generatedasidentitycolumnconstraint_sql-710"><a href="#Generator.generatedasidentitycolumnconstraint_sql-710"><span class="linenos">710</span></a> <span class="n">on_null</span> <span class="o">=</span> <span class="s2">" ON NULL"</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">"on_null"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.generatedasidentitycolumnconstraint_sql-711"><a href="#Generator.generatedasidentitycolumnconstraint_sql-711"><span class="linenos">711</span></a> <span class="n">this</span> <span class="o">=</span> <span class="s2">" ALWAYS"</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="sa">f</span><span class="s2">" BY DEFAULT</span><span class="si">{</span><span class="n">on_null</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.generatedasidentitycolumnconstraint_sql-712"><a href="#Generator.generatedasidentitycolumnconstraint_sql-712"><span class="linenos">712</span></a> -</span><span id="Generator.generatedasidentitycolumnconstraint_sql-713"><a href="#Generator.generatedasidentitycolumnconstraint_sql-713"><span class="linenos">713</span></a> <span class="n">start</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">"start"</span><span class="p">)</span> -</span><span id="Generator.generatedasidentitycolumnconstraint_sql-714"><a href="#Generator.generatedasidentitycolumnconstraint_sql-714"><span class="linenos">714</span></a> <span class="n">start</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"START WITH </span><span class="si">{</span><span class="n">start</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">start</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.generatedasidentitycolumnconstraint_sql-715"><a href="#Generator.generatedasidentitycolumnconstraint_sql-715"><span class="linenos">715</span></a> <span class="n">increment</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">"increment"</span><span class="p">)</span> -</span><span id="Generator.generatedasidentitycolumnconstraint_sql-716"><a href="#Generator.generatedasidentitycolumnconstraint_sql-716"><span class="linenos">716</span></a> <span class="n">increment</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" INCREMENT BY </span><span class="si">{</span><span class="n">increment</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">increment</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.generatedasidentitycolumnconstraint_sql-717"><a href="#Generator.generatedasidentitycolumnconstraint_sql-717"><span class="linenos">717</span></a> <span class="n">minvalue</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">"minvalue"</span><span class="p">)</span> -</span><span id="Generator.generatedasidentitycolumnconstraint_sql-718"><a href="#Generator.generatedasidentitycolumnconstraint_sql-718"><span class="linenos">718</span></a> <span class="n">minvalue</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" MINVALUE </span><span class="si">{</span><span class="n">minvalue</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">minvalue</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.generatedasidentitycolumnconstraint_sql-719"><a href="#Generator.generatedasidentitycolumnconstraint_sql-719"><span class="linenos">719</span></a> <span class="n">maxvalue</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">"maxvalue"</span><span class="p">)</span> -</span><span id="Generator.generatedasidentitycolumnconstraint_sql-720"><a href="#Generator.generatedasidentitycolumnconstraint_sql-720"><span class="linenos">720</span></a> <span class="n">maxvalue</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" MAXVALUE </span><span class="si">{</span><span class="n">maxvalue</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">maxvalue</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.generatedasidentitycolumnconstraint_sql-721"><a href="#Generator.generatedasidentitycolumnconstraint_sql-721"><span class="linenos">721</span></a> <span class="n">cycle</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">"cycle"</span><span class="p">)</span> -</span><span id="Generator.generatedasidentitycolumnconstraint_sql-722"><a href="#Generator.generatedasidentitycolumnconstraint_sql-722"><span class="linenos">722</span></a> <span class="n">cycle_sql</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator.generatedasidentitycolumnconstraint_sql-723"><a href="#Generator.generatedasidentitycolumnconstraint_sql-723"><span class="linenos">723</span></a> -</span><span id="Generator.generatedasidentitycolumnconstraint_sql-724"><a href="#Generator.generatedasidentitycolumnconstraint_sql-724"><span class="linenos">724</span></a> <span class="k">if</span> <span class="n">cycle</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Generator.generatedasidentitycolumnconstraint_sql-725"><a href="#Generator.generatedasidentitycolumnconstraint_sql-725"><span class="linenos">725</span></a> <span class="n">cycle_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="s1">' NO'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="ow">not</span><span class="w"> </span><span class="n">cycle</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"> CYCLE"</span> -</span><span id="Generator.generatedasidentitycolumnconstraint_sql-726"><a href="#Generator.generatedasidentitycolumnconstraint_sql-726"><span class="linenos">726</span></a> <span class="n">cycle_sql</span> <span class="o">=</span> <span class="n">cycle_sql</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> <span class="k">if</span> <span class="ow">not</span> <span class="n">start</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">increment</span> <span class="k">else</span> <span class="n">cycle_sql</span> -</span><span id="Generator.generatedasidentitycolumnconstraint_sql-727"><a href="#Generator.generatedasidentitycolumnconstraint_sql-727"><span class="linenos">727</span></a> -</span><span id="Generator.generatedasidentitycolumnconstraint_sql-728"><a href="#Generator.generatedasidentitycolumnconstraint_sql-728"><span class="linenos">728</span></a> <span class="n">sequence_opts</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator.generatedasidentitycolumnconstraint_sql-729"><a href="#Generator.generatedasidentitycolumnconstraint_sql-729"><span class="linenos">729</span></a> <span class="k">if</span> <span class="n">start</span> <span class="ow">or</span> <span class="n">increment</span> <span class="ow">or</span> <span class="n">cycle_sql</span><span class="p">:</span> -</span><span id="Generator.generatedasidentitycolumnconstraint_sql-730"><a href="#Generator.generatedasidentitycolumnconstraint_sql-730"><span class="linenos">730</span></a> <span class="n">sequence_opts</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">start</span><span class="si">}{</span><span class="n">increment</span><span class="si">}{</span><span class="n">minvalue</span><span class="si">}{</span><span class="n">maxvalue</span><span class="si">}{</span><span class="n">cycle_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.generatedasidentitycolumnconstraint_sql-731"><a href="#Generator.generatedasidentitycolumnconstraint_sql-731"><span class="linenos">731</span></a> <span class="n">sequence_opts</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" (</span><span class="si">{</span><span class="n">sequence_opts</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.generatedasidentitycolumnconstraint_sql-732"><a href="#Generator.generatedasidentitycolumnconstraint_sql-732"><span class="linenos">732</span></a> -</span><span id="Generator.generatedasidentitycolumnconstraint_sql-733"><a href="#Generator.generatedasidentitycolumnconstraint_sql-733"><span class="linenos">733</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.generatedasidentitycolumnconstraint_sql-734"><a href="#Generator.generatedasidentitycolumnconstraint_sql-734"><span class="linenos">734</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">expr</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">expr</span> <span class="k">else</span> <span class="s2">"IDENTITY"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.generatedasidentitycolumnconstraint_sql-708"><a href="#Generator.generatedasidentitycolumnconstraint_sql-708"><span class="linenos">708</span></a> <span class="k">def</span> <span class="nf">generatedasidentitycolumnconstraint_sql</span><span class="p">(</span> +</span><span id="Generator.generatedasidentitycolumnconstraint_sql-709"><a href="#Generator.generatedasidentitycolumnconstraint_sql-709"><span class="linenos">709</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GeneratedAsIdentityColumnConstraint</span> +</span><span id="Generator.generatedasidentitycolumnconstraint_sql-710"><a href="#Generator.generatedasidentitycolumnconstraint_sql-710"><span class="linenos">710</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.generatedasidentitycolumnconstraint_sql-711"><a href="#Generator.generatedasidentitycolumnconstraint_sql-711"><span class="linenos">711</span></a> <span class="n">this</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator.generatedasidentitycolumnconstraint_sql-712"><a href="#Generator.generatedasidentitycolumnconstraint_sql-712"><span class="linenos">712</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Generator.generatedasidentitycolumnconstraint_sql-713"><a href="#Generator.generatedasidentitycolumnconstraint_sql-713"><span class="linenos">713</span></a> <span class="n">on_null</span> <span class="o">=</span> <span class="s2">" ON NULL"</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">"on_null"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.generatedasidentitycolumnconstraint_sql-714"><a href="#Generator.generatedasidentitycolumnconstraint_sql-714"><span class="linenos">714</span></a> <span class="n">this</span> <span class="o">=</span> <span class="s2">" ALWAYS"</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="sa">f</span><span class="s2">" BY DEFAULT</span><span class="si">{</span><span class="n">on_null</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.generatedasidentitycolumnconstraint_sql-715"><a href="#Generator.generatedasidentitycolumnconstraint_sql-715"><span class="linenos">715</span></a> +</span><span id="Generator.generatedasidentitycolumnconstraint_sql-716"><a href="#Generator.generatedasidentitycolumnconstraint_sql-716"><span class="linenos">716</span></a> <span class="n">start</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">"start"</span><span class="p">)</span> +</span><span id="Generator.generatedasidentitycolumnconstraint_sql-717"><a href="#Generator.generatedasidentitycolumnconstraint_sql-717"><span class="linenos">717</span></a> <span class="n">start</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"START WITH </span><span class="si">{</span><span class="n">start</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">start</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.generatedasidentitycolumnconstraint_sql-718"><a href="#Generator.generatedasidentitycolumnconstraint_sql-718"><span class="linenos">718</span></a> <span class="n">increment</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">"increment"</span><span class="p">)</span> +</span><span id="Generator.generatedasidentitycolumnconstraint_sql-719"><a href="#Generator.generatedasidentitycolumnconstraint_sql-719"><span class="linenos">719</span></a> <span class="n">increment</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" INCREMENT BY </span><span class="si">{</span><span class="n">increment</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">increment</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.generatedasidentitycolumnconstraint_sql-720"><a href="#Generator.generatedasidentitycolumnconstraint_sql-720"><span class="linenos">720</span></a> <span class="n">minvalue</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">"minvalue"</span><span class="p">)</span> +</span><span id="Generator.generatedasidentitycolumnconstraint_sql-721"><a href="#Generator.generatedasidentitycolumnconstraint_sql-721"><span class="linenos">721</span></a> <span class="n">minvalue</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" MINVALUE </span><span class="si">{</span><span class="n">minvalue</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">minvalue</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.generatedasidentitycolumnconstraint_sql-722"><a href="#Generator.generatedasidentitycolumnconstraint_sql-722"><span class="linenos">722</span></a> <span class="n">maxvalue</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">"maxvalue"</span><span class="p">)</span> +</span><span id="Generator.generatedasidentitycolumnconstraint_sql-723"><a href="#Generator.generatedasidentitycolumnconstraint_sql-723"><span class="linenos">723</span></a> <span class="n">maxvalue</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" MAXVALUE </span><span class="si">{</span><span class="n">maxvalue</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">maxvalue</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.generatedasidentitycolumnconstraint_sql-724"><a href="#Generator.generatedasidentitycolumnconstraint_sql-724"><span class="linenos">724</span></a> <span class="n">cycle</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">"cycle"</span><span class="p">)</span> +</span><span id="Generator.generatedasidentitycolumnconstraint_sql-725"><a href="#Generator.generatedasidentitycolumnconstraint_sql-725"><span class="linenos">725</span></a> <span class="n">cycle_sql</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator.generatedasidentitycolumnconstraint_sql-726"><a href="#Generator.generatedasidentitycolumnconstraint_sql-726"><span class="linenos">726</span></a> +</span><span id="Generator.generatedasidentitycolumnconstraint_sql-727"><a href="#Generator.generatedasidentitycolumnconstraint_sql-727"><span class="linenos">727</span></a> <span class="k">if</span> <span class="n">cycle</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Generator.generatedasidentitycolumnconstraint_sql-728"><a href="#Generator.generatedasidentitycolumnconstraint_sql-728"><span class="linenos">728</span></a> <span class="n">cycle_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="s1">' NO'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="ow">not</span><span class="w"> </span><span class="n">cycle</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"> CYCLE"</span> +</span><span id="Generator.generatedasidentitycolumnconstraint_sql-729"><a href="#Generator.generatedasidentitycolumnconstraint_sql-729"><span class="linenos">729</span></a> <span class="n">cycle_sql</span> <span class="o">=</span> <span class="n">cycle_sql</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> <span class="k">if</span> <span class="ow">not</span> <span class="n">start</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">increment</span> <span class="k">else</span> <span class="n">cycle_sql</span> +</span><span id="Generator.generatedasidentitycolumnconstraint_sql-730"><a href="#Generator.generatedasidentitycolumnconstraint_sql-730"><span class="linenos">730</span></a> +</span><span id="Generator.generatedasidentitycolumnconstraint_sql-731"><a href="#Generator.generatedasidentitycolumnconstraint_sql-731"><span class="linenos">731</span></a> <span class="n">sequence_opts</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator.generatedasidentitycolumnconstraint_sql-732"><a href="#Generator.generatedasidentitycolumnconstraint_sql-732"><span class="linenos">732</span></a> <span class="k">if</span> <span class="n">start</span> <span class="ow">or</span> <span class="n">increment</span> <span class="ow">or</span> <span class="n">cycle_sql</span><span class="p">:</span> +</span><span id="Generator.generatedasidentitycolumnconstraint_sql-733"><a href="#Generator.generatedasidentitycolumnconstraint_sql-733"><span class="linenos">733</span></a> <span class="n">sequence_opts</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">start</span><span class="si">}{</span><span class="n">increment</span><span class="si">}{</span><span class="n">minvalue</span><span class="si">}{</span><span class="n">maxvalue</span><span class="si">}{</span><span class="n">cycle_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.generatedasidentitycolumnconstraint_sql-734"><a href="#Generator.generatedasidentitycolumnconstraint_sql-734"><span class="linenos">734</span></a> <span class="n">sequence_opts</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" (</span><span class="si">{</span><span class="n">sequence_opts</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.generatedasidentitycolumnconstraint_sql-735"><a href="#Generator.generatedasidentitycolumnconstraint_sql-735"><span class="linenos">735</span></a> -</span><span id="Generator.generatedasidentitycolumnconstraint_sql-736"><a href="#Generator.generatedasidentitycolumnconstraint_sql-736"><span class="linenos">736</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"GENERATED</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> AS </span><span class="si">{</span><span class="n">expr</span><span class="si">}{</span><span class="n">sequence_opts</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.generatedasidentitycolumnconstraint_sql-736"><a href="#Generator.generatedasidentitycolumnconstraint_sql-736"><span class="linenos">736</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.generatedasidentitycolumnconstraint_sql-737"><a href="#Generator.generatedasidentitycolumnconstraint_sql-737"><span class="linenos">737</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">expr</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">expr</span> <span class="k">else</span> <span class="s2">"IDENTITY"</span> +</span><span id="Generator.generatedasidentitycolumnconstraint_sql-738"><a href="#Generator.generatedasidentitycolumnconstraint_sql-738"><span class="linenos">738</span></a> +</span><span id="Generator.generatedasidentitycolumnconstraint_sql-739"><a href="#Generator.generatedasidentitycolumnconstraint_sql-739"><span class="linenos">739</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"GENERATED</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> AS </span><span class="si">{</span><span class="n">expr</span><span class="si">}{</span><span class="n">sequence_opts</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -8771,12 +8861,12 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.generatedasrowcolumnconstraint_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.generatedasrowcolumnconstraint_sql-738"><a href="#Generator.generatedasrowcolumnconstraint_sql-738"><span class="linenos">738</span></a> <span class="k">def</span> <span class="nf">generatedasrowcolumnconstraint_sql</span><span class="p">(</span> -</span><span id="Generator.generatedasrowcolumnconstraint_sql-739"><a href="#Generator.generatedasrowcolumnconstraint_sql-739"><span class="linenos">739</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GeneratedAsRowColumnConstraint</span> -</span><span id="Generator.generatedasrowcolumnconstraint_sql-740"><a href="#Generator.generatedasrowcolumnconstraint_sql-740"><span class="linenos">740</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.generatedasrowcolumnconstraint_sql-741"><a href="#Generator.generatedasrowcolumnconstraint_sql-741"><span class="linenos">741</span></a> <span class="n">start</span> <span class="o">=</span> <span class="s2">"START"</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">"start"</span><span class="p">]</span> <span class="k">else</span> <span class="s2">"END"</span> -</span><span id="Generator.generatedasrowcolumnconstraint_sql-742"><a href="#Generator.generatedasrowcolumnconstraint_sql-742"><span class="linenos">742</span></a> <span class="n">hidden</span> <span class="o">=</span> <span class="s2">" HIDDEN"</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">"hidden"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.generatedasrowcolumnconstraint_sql-743"><a href="#Generator.generatedasrowcolumnconstraint_sql-743"><span class="linenos">743</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"GENERATED ALWAYS AS ROW </span><span class="si">{</span><span class="n">start</span><span class="si">}{</span><span class="n">hidden</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.generatedasrowcolumnconstraint_sql-741"><a href="#Generator.generatedasrowcolumnconstraint_sql-741"><span class="linenos">741</span></a> <span class="k">def</span> <span class="nf">generatedasrowcolumnconstraint_sql</span><span class="p">(</span> +</span><span id="Generator.generatedasrowcolumnconstraint_sql-742"><a href="#Generator.generatedasrowcolumnconstraint_sql-742"><span class="linenos">742</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GeneratedAsRowColumnConstraint</span> +</span><span id="Generator.generatedasrowcolumnconstraint_sql-743"><a href="#Generator.generatedasrowcolumnconstraint_sql-743"><span class="linenos">743</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.generatedasrowcolumnconstraint_sql-744"><a href="#Generator.generatedasrowcolumnconstraint_sql-744"><span class="linenos">744</span></a> <span class="n">start</span> <span class="o">=</span> <span class="s2">"START"</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">"start"</span><span class="p">]</span> <span class="k">else</span> <span class="s2">"END"</span> +</span><span id="Generator.generatedasrowcolumnconstraint_sql-745"><a href="#Generator.generatedasrowcolumnconstraint_sql-745"><span class="linenos">745</span></a> <span class="n">hidden</span> <span class="o">=</span> <span class="s2">" HIDDEN"</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">"hidden"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.generatedasrowcolumnconstraint_sql-746"><a href="#Generator.generatedasrowcolumnconstraint_sql-746"><span class="linenos">746</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"GENERATED ALWAYS AS ROW </span><span class="si">{</span><span class="n">start</span><span class="si">}{</span><span class="n">hidden</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -8794,10 +8884,10 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.periodforsystemtimeconstraint_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.periodforsystemtimeconstraint_sql-745"><a href="#Generator.periodforsystemtimeconstraint_sql-745"><span class="linenos">745</span></a> <span class="k">def</span> <span class="nf">periodforsystemtimeconstraint_sql</span><span class="p">(</span> -</span><span id="Generator.periodforsystemtimeconstraint_sql-746"><a href="#Generator.periodforsystemtimeconstraint_sql-746"><span class="linenos">746</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">PeriodForSystemTimeConstraint</span> -</span><span id="Generator.periodforsystemtimeconstraint_sql-747"><a href="#Generator.periodforsystemtimeconstraint_sql-747"><span class="linenos">747</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.periodforsystemtimeconstraint_sql-748"><a href="#Generator.periodforsystemtimeconstraint_sql-748"><span class="linenos">748</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PERIOD FOR SYSTEM_TIME (</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.periodforsystemtimeconstraint_sql-748"><a href="#Generator.periodforsystemtimeconstraint_sql-748"><span class="linenos">748</span></a> <span class="k">def</span> <span class="nf">periodforsystemtimeconstraint_sql</span><span class="p">(</span> +</span><span id="Generator.periodforsystemtimeconstraint_sql-749"><a href="#Generator.periodforsystemtimeconstraint_sql-749"><span class="linenos">749</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">PeriodForSystemTimeConstraint</span> +</span><span id="Generator.periodforsystemtimeconstraint_sql-750"><a href="#Generator.periodforsystemtimeconstraint_sql-750"><span class="linenos">750</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.periodforsystemtimeconstraint_sql-751"><a href="#Generator.periodforsystemtimeconstraint_sql-751"><span class="linenos">751</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PERIOD FOR SYSTEM_TIME (</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> @@ -8815,8 +8905,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.notnullcolumnconstraint_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.notnullcolumnconstraint_sql-750"><a href="#Generator.notnullcolumnconstraint_sql-750"><span class="linenos">750</span></a> <span class="k">def</span> <span class="nf">notnullcolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">NotNullColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.notnullcolumnconstraint_sql-751"><a href="#Generator.notnullcolumnconstraint_sql-751"><span class="linenos">751</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="s1">''</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">'allow_null'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">'NOT '</span><span class="si">}</span><span class="s2">NULL"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.notnullcolumnconstraint_sql-753"><a href="#Generator.notnullcolumnconstraint_sql-753"><span class="linenos">753</span></a> <span class="k">def</span> <span class="nf">notnullcolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">NotNullColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.notnullcolumnconstraint_sql-754"><a href="#Generator.notnullcolumnconstraint_sql-754"><span class="linenos">754</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="s1">''</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">'allow_null'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">'NOT '</span><span class="si">}</span><span class="s2">NULL"</span> </span></pre></div> @@ -8834,8 +8924,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.transformcolumnconstraint_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.transformcolumnconstraint_sql-753"><a href="#Generator.transformcolumnconstraint_sql-753"><span class="linenos">753</span></a> <span class="k">def</span> <span class="nf">transformcolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TransformColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.transformcolumnconstraint_sql-754"><a href="#Generator.transformcolumnconstraint_sql-754"><span class="linenos">754</span></a> <span class="k">return</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">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.transformcolumnconstraint_sql-756"><a href="#Generator.transformcolumnconstraint_sql-756"><span class="linenos">756</span></a> <span class="k">def</span> <span class="nf">transformcolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TransformColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.transformcolumnconstraint_sql-757"><a href="#Generator.transformcolumnconstraint_sql-757"><span class="linenos">757</span></a> <span class="k">return</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">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> @@ -8853,11 +8943,11 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.primarykeycolumnconstraint_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.primarykeycolumnconstraint_sql-756"><a href="#Generator.primarykeycolumnconstraint_sql-756"><span class="linenos">756</span></a> <span class="k">def</span> <span class="nf">primarykeycolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">PrimaryKeyColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.primarykeycolumnconstraint_sql-757"><a href="#Generator.primarykeycolumnconstraint_sql-757"><span class="linenos">757</span></a> <span class="n">desc</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">"desc"</span><span class="p">)</span> -</span><span id="Generator.primarykeycolumnconstraint_sql-758"><a href="#Generator.primarykeycolumnconstraint_sql-758"><span class="linenos">758</span></a> <span class="k">if</span> <span class="n">desc</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Generator.primarykeycolumnconstraint_sql-759"><a href="#Generator.primarykeycolumnconstraint_sql-759"><span class="linenos">759</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PRIMARY KEY</span><span class="si">{</span><span class="s1">' DESC'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">desc</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">' ASC'</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.primarykeycolumnconstraint_sql-760"><a href="#Generator.primarykeycolumnconstraint_sql-760"><span class="linenos">760</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PRIMARY KEY"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.primarykeycolumnconstraint_sql-759"><a href="#Generator.primarykeycolumnconstraint_sql-759"><span class="linenos">759</span></a> <span class="k">def</span> <span class="nf">primarykeycolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">PrimaryKeyColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.primarykeycolumnconstraint_sql-760"><a href="#Generator.primarykeycolumnconstraint_sql-760"><span class="linenos">760</span></a> <span class="n">desc</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">"desc"</span><span class="p">)</span> +</span><span id="Generator.primarykeycolumnconstraint_sql-761"><a href="#Generator.primarykeycolumnconstraint_sql-761"><span class="linenos">761</span></a> <span class="k">if</span> <span class="n">desc</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Generator.primarykeycolumnconstraint_sql-762"><a href="#Generator.primarykeycolumnconstraint_sql-762"><span class="linenos">762</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PRIMARY KEY</span><span class="si">{</span><span class="s1">' DESC'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">desc</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">' ASC'</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.primarykeycolumnconstraint_sql-763"><a href="#Generator.primarykeycolumnconstraint_sql-763"><span class="linenos">763</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PRIMARY KEY"</span> </span></pre></div> @@ -8875,12 +8965,12 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.uniquecolumnconstraint_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.uniquecolumnconstraint_sql-762"><a href="#Generator.uniquecolumnconstraint_sql-762"><span class="linenos">762</span></a> <span class="k">def</span> <span class="nf">uniquecolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">UniqueColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.uniquecolumnconstraint_sql-763"><a href="#Generator.uniquecolumnconstraint_sql-763"><span class="linenos">763</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.uniquecolumnconstraint_sql-764"><a href="#Generator.uniquecolumnconstraint_sql-764"><span class="linenos">764</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.uniquecolumnconstraint_sql-765"><a href="#Generator.uniquecolumnconstraint_sql-765"><span class="linenos">765</span></a> <span class="n">index_type</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">"index_type"</span><span class="p">)</span> -</span><span id="Generator.uniquecolumnconstraint_sql-766"><a href="#Generator.uniquecolumnconstraint_sql-766"><span class="linenos">766</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.uniquecolumnconstraint_sql-767"><a href="#Generator.uniquecolumnconstraint_sql-767"><span class="linenos">767</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"UNIQUE</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="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.uniquecolumnconstraint_sql-765"><a href="#Generator.uniquecolumnconstraint_sql-765"><span class="linenos">765</span></a> <span class="k">def</span> <span class="nf">uniquecolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">UniqueColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.uniquecolumnconstraint_sql-766"><a href="#Generator.uniquecolumnconstraint_sql-766"><span class="linenos">766</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.uniquecolumnconstraint_sql-767"><a href="#Generator.uniquecolumnconstraint_sql-767"><span class="linenos">767</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.uniquecolumnconstraint_sql-768"><a href="#Generator.uniquecolumnconstraint_sql-768"><span class="linenos">768</span></a> <span class="n">index_type</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">"index_type"</span><span class="p">)</span> +</span><span id="Generator.uniquecolumnconstraint_sql-769"><a href="#Generator.uniquecolumnconstraint_sql-769"><span class="linenos">769</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.uniquecolumnconstraint_sql-770"><a href="#Generator.uniquecolumnconstraint_sql-770"><span class="linenos">770</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"UNIQUE</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="s2">"</span> </span></pre></div> @@ -8898,8 +8988,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.createable_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.createable_sql-769"><a href="#Generator.createable_sql-769"><span class="linenos">769</span></a> <span class="k">def</span> <span class="nf">createable_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">,</span> <span class="n">locations</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">DefaultDict</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.createable_sql-770"><a href="#Generator.createable_sql-770"><span class="linenos">770</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">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.createable_sql-772"><a href="#Generator.createable_sql-772"><span class="linenos">772</span></a> <span class="k">def</span> <span class="nf">createable_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">,</span> <span class="n">locations</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">DefaultDict</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.createable_sql-773"><a href="#Generator.createable_sql-773"><span class="linenos">773</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">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> </span></pre></div> @@ -8917,92 +9007,92 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.create_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.create_sql-772"><a href="#Generator.create_sql-772"><span class="linenos">772</span></a> <span class="k">def</span> <span class="nf">create_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.create_sql-773"><a href="#Generator.create_sql-773"><span class="linenos">773</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 class="o">.</span><span class="n">upper</span><span class="p">()</span> -</span><span id="Generator.create_sql-774"><a href="#Generator.create_sql-774"><span class="linenos">774</span></a> <span class="n">properties</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">"properties"</span><span class="p">)</span> -</span><span id="Generator.create_sql-775"><a href="#Generator.create_sql-775"><span class="linenos">775</span></a> <span class="n">properties_locs</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">locate_properties</span><span class="p">(</span><span class="n">properties</span><span class="p">)</span> <span class="k">if</span> <span class="n">properties</span> <span class="k">else</span> <span class="n">defaultdict</span><span class="p">()</span> -</span><span id="Generator.create_sql-776"><a href="#Generator.create_sql-776"><span class="linenos">776</span></a> -</span><span id="Generator.create_sql-777"><a href="#Generator.create_sql-777"><span class="linenos">777</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">createable_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">properties_locs</span><span class="p">)</span> -</span><span id="Generator.create_sql-778"><a href="#Generator.create_sql-778"><span class="linenos">778</span></a> -</span><span id="Generator.create_sql-779"><a href="#Generator.create_sql-779"><span class="linenos">779</span></a> <span class="n">properties_sql</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator.create_sql-780"><a href="#Generator.create_sql-780"><span class="linenos">780</span></a> <span class="k">if</span> <span class="n">properties_locs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">)</span> <span class="ow">or</span> <span class="n">properties_locs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span> -</span><span id="Generator.create_sql-781"><a href="#Generator.create_sql-781"><span class="linenos">781</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span> -</span><span id="Generator.create_sql-782"><a href="#Generator.create_sql-782"><span class="linenos">782</span></a> <span class="p">):</span> -</span><span id="Generator.create_sql-783"><a href="#Generator.create_sql-783"><span class="linenos">783</span></a> <span class="n">properties_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><span id="Generator.create_sql-784"><a href="#Generator.create_sql-784"><span class="linenos">784</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span> -</span><span id="Generator.create_sql-785"><a href="#Generator.create_sql-785"><span class="linenos">785</span></a> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span> -</span><span id="Generator.create_sql-786"><a href="#Generator.create_sql-786"><span class="linenos">786</span></a> <span class="o">*</span><span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">],</span> -</span><span id="Generator.create_sql-787"><a href="#Generator.create_sql-787"><span class="linenos">787</span></a> <span class="o">*</span><span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">],</span> -</span><span id="Generator.create_sql-788"><a href="#Generator.create_sql-788"><span class="linenos">788</span></a> <span class="p">]</span> -</span><span id="Generator.create_sql-789"><a href="#Generator.create_sql-789"><span class="linenos">789</span></a> <span class="p">)</span> -</span><span id="Generator.create_sql-790"><a href="#Generator.create_sql-790"><span class="linenos">790</span></a> <span class="p">)</span> -</span><span id="Generator.create_sql-791"><a href="#Generator.create_sql-791"><span class="linenos">791</span></a> -</span><span id="Generator.create_sql-792"><a href="#Generator.create_sql-792"><span class="linenos">792</span></a> <span class="n">begin</span> <span class="o">=</span> <span class="s2">" BEGIN"</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">"begin"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.create_sql-793"><a href="#Generator.create_sql-793"><span class="linenos">793</span></a> <span class="n">end</span> <span class="o">=</span> <span class="s2">" END"</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">"end"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.create_sql-775"><a href="#Generator.create_sql-775"><span class="linenos">775</span></a> <span class="k">def</span> <span class="nf">create_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.create_sql-776"><a href="#Generator.create_sql-776"><span class="linenos">776</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 class="o">.</span><span class="n">upper</span><span class="p">()</span> +</span><span id="Generator.create_sql-777"><a href="#Generator.create_sql-777"><span class="linenos">777</span></a> <span class="n">properties</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">"properties"</span><span class="p">)</span> +</span><span id="Generator.create_sql-778"><a href="#Generator.create_sql-778"><span class="linenos">778</span></a> <span class="n">properties_locs</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">locate_properties</span><span class="p">(</span><span class="n">properties</span><span class="p">)</span> <span class="k">if</span> <span class="n">properties</span> <span class="k">else</span> <span class="n">defaultdict</span><span class="p">()</span> +</span><span id="Generator.create_sql-779"><a href="#Generator.create_sql-779"><span class="linenos">779</span></a> +</span><span id="Generator.create_sql-780"><a href="#Generator.create_sql-780"><span class="linenos">780</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">createable_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">properties_locs</span><span class="p">)</span> +</span><span id="Generator.create_sql-781"><a href="#Generator.create_sql-781"><span class="linenos">781</span></a> +</span><span id="Generator.create_sql-782"><a href="#Generator.create_sql-782"><span class="linenos">782</span></a> <span class="n">properties_sql</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator.create_sql-783"><a href="#Generator.create_sql-783"><span class="linenos">783</span></a> <span class="k">if</span> <span class="n">properties_locs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">)</span> <span class="ow">or</span> <span class="n">properties_locs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span> +</span><span id="Generator.create_sql-784"><a href="#Generator.create_sql-784"><span class="linenos">784</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span> +</span><span id="Generator.create_sql-785"><a href="#Generator.create_sql-785"><span class="linenos">785</span></a> <span class="p">):</span> +</span><span id="Generator.create_sql-786"><a href="#Generator.create_sql-786"><span class="linenos">786</span></a> <span class="n">properties_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><span id="Generator.create_sql-787"><a href="#Generator.create_sql-787"><span class="linenos">787</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span> +</span><span id="Generator.create_sql-788"><a href="#Generator.create_sql-788"><span class="linenos">788</span></a> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span> +</span><span id="Generator.create_sql-789"><a href="#Generator.create_sql-789"><span class="linenos">789</span></a> <span class="o">*</span><span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">],</span> +</span><span id="Generator.create_sql-790"><a href="#Generator.create_sql-790"><span class="linenos">790</span></a> <span class="o">*</span><span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">],</span> +</span><span id="Generator.create_sql-791"><a href="#Generator.create_sql-791"><span class="linenos">791</span></a> <span class="p">]</span> +</span><span id="Generator.create_sql-792"><a href="#Generator.create_sql-792"><span class="linenos">792</span></a> <span class="p">)</span> +</span><span id="Generator.create_sql-793"><a href="#Generator.create_sql-793"><span class="linenos">793</span></a> <span class="p">)</span> </span><span id="Generator.create_sql-794"><a href="#Generator.create_sql-794"><span class="linenos">794</span></a> -</span><span id="Generator.create_sql-795"><a href="#Generator.create_sql-795"><span class="linenos">795</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.create_sql-796"><a href="#Generator.create_sql-796"><span class="linenos">796</span></a> <span class="k">if</span> <span class="n">expression_sql</span><span class="p">:</span> -</span><span id="Generator.create_sql-797"><a href="#Generator.create_sql-797"><span class="linenos">797</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">begin</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="n">expression_sql</span><span class="si">}{</span><span class="n">end</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.create_sql-798"><a href="#Generator.create_sql-798"><span class="linenos">798</span></a> -</span><span id="Generator.create_sql-799"><a href="#Generator.create_sql-799"><span class="linenos">799</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">CREATE_FUNCTION_RETURN_AS</span> <span class="ow">or</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">Return</span><span class="p">):</span> -</span><span id="Generator.create_sql-800"><a href="#Generator.create_sql-800"><span class="linenos">800</span></a> <span class="k">if</span> <span class="n">properties_locs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_ALIAS</span><span class="p">):</span> -</span><span id="Generator.create_sql-801"><a href="#Generator.create_sql-801"><span class="linenos">801</span></a> <span class="n">postalias_props_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span> -</span><span id="Generator.create_sql-802"><a href="#Generator.create_sql-802"><span class="linenos">802</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span> -</span><span id="Generator.create_sql-803"><a href="#Generator.create_sql-803"><span class="linenos">803</span></a> <span class="n">expressions</span><span class="o">=</span><span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_ALIAS</span><span class="p">]</span> -</span><span id="Generator.create_sql-804"><a href="#Generator.create_sql-804"><span class="linenos">804</span></a> <span class="p">),</span> -</span><span id="Generator.create_sql-805"><a href="#Generator.create_sql-805"><span class="linenos">805</span></a> <span class="n">wrapped</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> -</span><span id="Generator.create_sql-806"><a href="#Generator.create_sql-806"><span class="linenos">806</span></a> <span class="p">)</span> -</span><span id="Generator.create_sql-807"><a href="#Generator.create_sql-807"><span class="linenos">807</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="n">postalias_props_sql</span><span class="si">}{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.create_sql-808"><a href="#Generator.create_sql-808"><span class="linenos">808</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator.create_sql-809"><a href="#Generator.create_sql-809"><span class="linenos">809</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS</span><span class="si">{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.create_sql-810"><a href="#Generator.create_sql-810"><span class="linenos">810</span></a> -</span><span id="Generator.create_sql-811"><a href="#Generator.create_sql-811"><span class="linenos">811</span></a> <span class="n">postindex_props_sql</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator.create_sql-812"><a href="#Generator.create_sql-812"><span class="linenos">812</span></a> <span class="k">if</span> <span class="n">properties_locs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_INDEX</span><span class="p">):</span> -</span><span id="Generator.create_sql-813"><a href="#Generator.create_sql-813"><span class="linenos">813</span></a> <span class="n">postindex_props_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span> -</span><span id="Generator.create_sql-814"><a href="#Generator.create_sql-814"><span class="linenos">814</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_INDEX</span><span class="p">]),</span> -</span><span id="Generator.create_sql-815"><a href="#Generator.create_sql-815"><span class="linenos">815</span></a> <span class="n">wrapped</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> -</span><span id="Generator.create_sql-816"><a href="#Generator.create_sql-816"><span class="linenos">816</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> -</span><span id="Generator.create_sql-817"><a href="#Generator.create_sql-817"><span class="linenos">817</span></a> <span class="p">)</span> -</span><span id="Generator.create_sql-818"><a href="#Generator.create_sql-818"><span class="linenos">818</span></a> -</span><span id="Generator.create_sql-819"><a href="#Generator.create_sql-819"><span class="linenos">819</span></a> <span class="n">indexes</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">"indexes"</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="kc">False</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.create_sql-820"><a href="#Generator.create_sql-820"><span class="linenos">820</span></a> <span class="n">indexes</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">indexes</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">indexes</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.create_sql-821"><a href="#Generator.create_sql-821"><span class="linenos">821</span></a> <span class="n">index_sql</span> <span class="o">=</span> <span class="n">indexes</span> <span class="o">+</span> <span class="n">postindex_props_sql</span> -</span><span id="Generator.create_sql-822"><a href="#Generator.create_sql-822"><span class="linenos">822</span></a> -</span><span id="Generator.create_sql-823"><a href="#Generator.create_sql-823"><span class="linenos">823</span></a> <span class="n">replace</span> <span class="o">=</span> <span class="s2">" OR REPLACE"</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">"replace"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.create_sql-824"><a href="#Generator.create_sql-824"><span class="linenos">824</span></a> <span class="n">unique</span> <span class="o">=</span> <span class="s2">" UNIQUE"</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">"unique"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.create_sql-795"><a href="#Generator.create_sql-795"><span class="linenos">795</span></a> <span class="n">begin</span> <span class="o">=</span> <span class="s2">" BEGIN"</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">"begin"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.create_sql-796"><a href="#Generator.create_sql-796"><span class="linenos">796</span></a> <span class="n">end</span> <span class="o">=</span> <span class="s2">" END"</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">"end"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.create_sql-797"><a href="#Generator.create_sql-797"><span class="linenos">797</span></a> +</span><span id="Generator.create_sql-798"><a href="#Generator.create_sql-798"><span class="linenos">798</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.create_sql-799"><a href="#Generator.create_sql-799"><span class="linenos">799</span></a> <span class="k">if</span> <span class="n">expression_sql</span><span class="p">:</span> +</span><span id="Generator.create_sql-800"><a href="#Generator.create_sql-800"><span class="linenos">800</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">begin</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="n">expression_sql</span><span class="si">}{</span><span class="n">end</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.create_sql-801"><a href="#Generator.create_sql-801"><span class="linenos">801</span></a> +</span><span id="Generator.create_sql-802"><a href="#Generator.create_sql-802"><span class="linenos">802</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">CREATE_FUNCTION_RETURN_AS</span> <span class="ow">or</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">Return</span><span class="p">):</span> +</span><span id="Generator.create_sql-803"><a href="#Generator.create_sql-803"><span class="linenos">803</span></a> <span class="k">if</span> <span class="n">properties_locs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_ALIAS</span><span class="p">):</span> +</span><span id="Generator.create_sql-804"><a href="#Generator.create_sql-804"><span class="linenos">804</span></a> <span class="n">postalias_props_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span> +</span><span id="Generator.create_sql-805"><a href="#Generator.create_sql-805"><span class="linenos">805</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span> +</span><span id="Generator.create_sql-806"><a href="#Generator.create_sql-806"><span class="linenos">806</span></a> <span class="n">expressions</span><span class="o">=</span><span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_ALIAS</span><span class="p">]</span> +</span><span id="Generator.create_sql-807"><a href="#Generator.create_sql-807"><span class="linenos">807</span></a> <span class="p">),</span> +</span><span id="Generator.create_sql-808"><a href="#Generator.create_sql-808"><span class="linenos">808</span></a> <span class="n">wrapped</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> +</span><span id="Generator.create_sql-809"><a href="#Generator.create_sql-809"><span class="linenos">809</span></a> <span class="p">)</span> +</span><span id="Generator.create_sql-810"><a href="#Generator.create_sql-810"><span class="linenos">810</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="n">postalias_props_sql</span><span class="si">}{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.create_sql-811"><a href="#Generator.create_sql-811"><span class="linenos">811</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator.create_sql-812"><a href="#Generator.create_sql-812"><span class="linenos">812</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS</span><span class="si">{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.create_sql-813"><a href="#Generator.create_sql-813"><span class="linenos">813</span></a> +</span><span id="Generator.create_sql-814"><a href="#Generator.create_sql-814"><span class="linenos">814</span></a> <span class="n">postindex_props_sql</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator.create_sql-815"><a href="#Generator.create_sql-815"><span class="linenos">815</span></a> <span class="k">if</span> <span class="n">properties_locs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_INDEX</span><span class="p">):</span> +</span><span id="Generator.create_sql-816"><a href="#Generator.create_sql-816"><span class="linenos">816</span></a> <span class="n">postindex_props_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span> +</span><span id="Generator.create_sql-817"><a href="#Generator.create_sql-817"><span class="linenos">817</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_INDEX</span><span class="p">]),</span> +</span><span id="Generator.create_sql-818"><a href="#Generator.create_sql-818"><span class="linenos">818</span></a> <span class="n">wrapped</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> +</span><span id="Generator.create_sql-819"><a href="#Generator.create_sql-819"><span class="linenos">819</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> +</span><span id="Generator.create_sql-820"><a href="#Generator.create_sql-820"><span class="linenos">820</span></a> <span class="p">)</span> +</span><span id="Generator.create_sql-821"><a href="#Generator.create_sql-821"><span class="linenos">821</span></a> +</span><span id="Generator.create_sql-822"><a href="#Generator.create_sql-822"><span class="linenos">822</span></a> <span class="n">indexes</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">"indexes"</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="kc">False</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.create_sql-823"><a href="#Generator.create_sql-823"><span class="linenos">823</span></a> <span class="n">indexes</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">indexes</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">indexes</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.create_sql-824"><a href="#Generator.create_sql-824"><span class="linenos">824</span></a> <span class="n">index_sql</span> <span class="o">=</span> <span class="n">indexes</span> <span class="o">+</span> <span class="n">postindex_props_sql</span> </span><span id="Generator.create_sql-825"><a href="#Generator.create_sql-825"><span class="linenos">825</span></a> -</span><span id="Generator.create_sql-826"><a href="#Generator.create_sql-826"><span class="linenos">826</span></a> <span class="n">postcreate_props_sql</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator.create_sql-827"><a href="#Generator.create_sql-827"><span class="linenos">827</span></a> <span class="k">if</span> <span class="n">properties_locs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">):</span> -</span><span id="Generator.create_sql-828"><a href="#Generator.create_sql-828"><span class="linenos">828</span></a> <span class="n">postcreate_props_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span> -</span><span id="Generator.create_sql-829"><a href="#Generator.create_sql-829"><span class="linenos">829</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">]),</span> -</span><span id="Generator.create_sql-830"><a href="#Generator.create_sql-830"><span class="linenos">830</span></a> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> -</span><span id="Generator.create_sql-831"><a href="#Generator.create_sql-831"><span class="linenos">831</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> -</span><span id="Generator.create_sql-832"><a href="#Generator.create_sql-832"><span class="linenos">832</span></a> <span class="n">wrapped</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> -</span><span id="Generator.create_sql-833"><a href="#Generator.create_sql-833"><span class="linenos">833</span></a> <span class="p">)</span> -</span><span id="Generator.create_sql-834"><a href="#Generator.create_sql-834"><span class="linenos">834</span></a> -</span><span id="Generator.create_sql-835"><a href="#Generator.create_sql-835"><span class="linenos">835</span></a> <span class="n">modifiers</span> <span class="o">=</span> <span class="s2">""</span><span class="o">.</span><span class="n">join</span><span class="p">((</span><span class="n">replace</span><span class="p">,</span> <span class="n">unique</span><span class="p">,</span> <span class="n">postcreate_props_sql</span><span class="p">))</span> -</span><span id="Generator.create_sql-836"><a href="#Generator.create_sql-836"><span class="linenos">836</span></a> -</span><span id="Generator.create_sql-837"><a href="#Generator.create_sql-837"><span class="linenos">837</span></a> <span class="n">postexpression_props_sql</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator.create_sql-838"><a href="#Generator.create_sql-838"><span class="linenos">838</span></a> <span class="k">if</span> <span class="n">properties_locs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_EXPRESSION</span><span class="p">):</span> -</span><span id="Generator.create_sql-839"><a href="#Generator.create_sql-839"><span class="linenos">839</span></a> <span class="n">postexpression_props_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span> -</span><span id="Generator.create_sql-840"><a href="#Generator.create_sql-840"><span class="linenos">840</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span> -</span><span id="Generator.create_sql-841"><a href="#Generator.create_sql-841"><span class="linenos">841</span></a> <span class="n">expressions</span><span class="o">=</span><span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_EXPRESSION</span><span class="p">]</span> -</span><span id="Generator.create_sql-842"><a href="#Generator.create_sql-842"><span class="linenos">842</span></a> <span class="p">),</span> -</span><span id="Generator.create_sql-843"><a href="#Generator.create_sql-843"><span class="linenos">843</span></a> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> -</span><span id="Generator.create_sql-844"><a href="#Generator.create_sql-844"><span class="linenos">844</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> -</span><span id="Generator.create_sql-845"><a href="#Generator.create_sql-845"><span class="linenos">845</span></a> <span class="n">wrapped</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> -</span><span id="Generator.create_sql-846"><a href="#Generator.create_sql-846"><span class="linenos">846</span></a> <span class="p">)</span> -</span><span id="Generator.create_sql-847"><a href="#Generator.create_sql-847"><span class="linenos">847</span></a> -</span><span id="Generator.create_sql-848"><a href="#Generator.create_sql-848"><span class="linenos">848</span></a> <span class="n">exists_sql</span> <span class="o">=</span> <span class="s2">" IF NOT 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.create_sql-849"><a href="#Generator.create_sql-849"><span class="linenos">849</span></a> <span class="n">no_schema_binding</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Generator.create_sql-850"><a href="#Generator.create_sql-850"><span class="linenos">850</span></a> <span class="s2">" WITH NO SCHEMA BINDING"</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">"no_schema_binding"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.create_sql-851"><a href="#Generator.create_sql-851"><span class="linenos">851</span></a> <span class="p">)</span> -</span><span id="Generator.create_sql-852"><a href="#Generator.create_sql-852"><span class="linenos">852</span></a> -</span><span id="Generator.create_sql-853"><a href="#Generator.create_sql-853"><span class="linenos">853</span></a> <span class="n">clone</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"clone"</span><span class="p">)</span> -</span><span id="Generator.create_sql-854"><a href="#Generator.create_sql-854"><span class="linenos">854</span></a> <span class="n">clone</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">clone</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">clone</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.create_sql-826"><a href="#Generator.create_sql-826"><span class="linenos">826</span></a> <span class="n">replace</span> <span class="o">=</span> <span class="s2">" OR REPLACE"</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">"replace"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.create_sql-827"><a href="#Generator.create_sql-827"><span class="linenos">827</span></a> <span class="n">unique</span> <span class="o">=</span> <span class="s2">" UNIQUE"</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">"unique"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.create_sql-828"><a href="#Generator.create_sql-828"><span class="linenos">828</span></a> +</span><span id="Generator.create_sql-829"><a href="#Generator.create_sql-829"><span class="linenos">829</span></a> <span class="n">postcreate_props_sql</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator.create_sql-830"><a href="#Generator.create_sql-830"><span class="linenos">830</span></a> <span class="k">if</span> <span class="n">properties_locs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">):</span> +</span><span id="Generator.create_sql-831"><a href="#Generator.create_sql-831"><span class="linenos">831</span></a> <span class="n">postcreate_props_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span> +</span><span id="Generator.create_sql-832"><a href="#Generator.create_sql-832"><span class="linenos">832</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">]),</span> +</span><span id="Generator.create_sql-833"><a href="#Generator.create_sql-833"><span class="linenos">833</span></a> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> +</span><span id="Generator.create_sql-834"><a href="#Generator.create_sql-834"><span class="linenos">834</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> +</span><span id="Generator.create_sql-835"><a href="#Generator.create_sql-835"><span class="linenos">835</span></a> <span class="n">wrapped</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> +</span><span id="Generator.create_sql-836"><a href="#Generator.create_sql-836"><span class="linenos">836</span></a> <span class="p">)</span> +</span><span id="Generator.create_sql-837"><a href="#Generator.create_sql-837"><span class="linenos">837</span></a> +</span><span id="Generator.create_sql-838"><a href="#Generator.create_sql-838"><span class="linenos">838</span></a> <span class="n">modifiers</span> <span class="o">=</span> <span class="s2">""</span><span class="o">.</span><span class="n">join</span><span class="p">((</span><span class="n">replace</span><span class="p">,</span> <span class="n">unique</span><span class="p">,</span> <span class="n">postcreate_props_sql</span><span class="p">))</span> +</span><span id="Generator.create_sql-839"><a href="#Generator.create_sql-839"><span class="linenos">839</span></a> +</span><span id="Generator.create_sql-840"><a href="#Generator.create_sql-840"><span class="linenos">840</span></a> <span class="n">postexpression_props_sql</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator.create_sql-841"><a href="#Generator.create_sql-841"><span class="linenos">841</span></a> <span class="k">if</span> <span class="n">properties_locs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_EXPRESSION</span><span class="p">):</span> +</span><span id="Generator.create_sql-842"><a href="#Generator.create_sql-842"><span class="linenos">842</span></a> <span class="n">postexpression_props_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span> +</span><span id="Generator.create_sql-843"><a href="#Generator.create_sql-843"><span class="linenos">843</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span> +</span><span id="Generator.create_sql-844"><a href="#Generator.create_sql-844"><span class="linenos">844</span></a> <span class="n">expressions</span><span class="o">=</span><span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_EXPRESSION</span><span class="p">]</span> +</span><span id="Generator.create_sql-845"><a href="#Generator.create_sql-845"><span class="linenos">845</span></a> <span class="p">),</span> +</span><span id="Generator.create_sql-846"><a href="#Generator.create_sql-846"><span class="linenos">846</span></a> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> +</span><span id="Generator.create_sql-847"><a href="#Generator.create_sql-847"><span class="linenos">847</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> +</span><span id="Generator.create_sql-848"><a href="#Generator.create_sql-848"><span class="linenos">848</span></a> <span class="n">wrapped</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> +</span><span id="Generator.create_sql-849"><a href="#Generator.create_sql-849"><span class="linenos">849</span></a> <span class="p">)</span> +</span><span id="Generator.create_sql-850"><a href="#Generator.create_sql-850"><span class="linenos">850</span></a> +</span><span id="Generator.create_sql-851"><a href="#Generator.create_sql-851"><span class="linenos">851</span></a> <span class="n">exists_sql</span> <span class="o">=</span> <span class="s2">" IF NOT 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.create_sql-852"><a href="#Generator.create_sql-852"><span class="linenos">852</span></a> <span class="n">no_schema_binding</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Generator.create_sql-853"><a href="#Generator.create_sql-853"><span class="linenos">853</span></a> <span class="s2">" WITH NO SCHEMA BINDING"</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">"no_schema_binding"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.create_sql-854"><a href="#Generator.create_sql-854"><span class="linenos">854</span></a> <span class="p">)</span> </span><span id="Generator.create_sql-855"><a href="#Generator.create_sql-855"><span class="linenos">855</span></a> -</span><span id="Generator.create_sql-856"><a href="#Generator.create_sql-856"><span class="linenos">856</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"CREATE</span><span class="si">{</span><span class="n">modifiers</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">exists_sql</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">properties_sql</span><span class="si">}{</span><span class="n">expression_sql</span><span class="si">}{</span><span class="n">postexpression_props_sql</span><span class="si">}{</span><span class="n">index_sql</span><span class="si">}{</span><span class="n">no_schema_binding</span><span class="si">}{</span><span class="n">clone</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.create_sql-857"><a href="#Generator.create_sql-857"><span class="linenos">857</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">expression_sql</span><span class="p">)</span> +</span><span id="Generator.create_sql-856"><a href="#Generator.create_sql-856"><span class="linenos">856</span></a> <span class="n">clone</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"clone"</span><span class="p">)</span> +</span><span id="Generator.create_sql-857"><a href="#Generator.create_sql-857"><span class="linenos">857</span></a> <span class="n">clone</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">clone</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">clone</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.create_sql-858"><a href="#Generator.create_sql-858"><span class="linenos">858</span></a> +</span><span id="Generator.create_sql-859"><a href="#Generator.create_sql-859"><span class="linenos">859</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"CREATE</span><span class="si">{</span><span class="n">modifiers</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">exists_sql</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">properties_sql</span><span class="si">}{</span><span class="n">expression_sql</span><span class="si">}{</span><span class="n">postexpression_props_sql</span><span class="si">}{</span><span class="n">index_sql</span><span class="si">}{</span><span class="n">no_schema_binding</span><span class="si">}{</span><span class="n">clone</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.create_sql-860"><a href="#Generator.create_sql-860"><span class="linenos">860</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">expression_sql</span><span class="p">)</span> </span></pre></div> @@ -9020,19 +9110,11 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.clone_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.clone_sql-859"><a href="#Generator.clone_sql-859"><span class="linenos">859</span></a> <span class="k">def</span> <span class="nf">clone_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Clone</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.clone_sql-860"><a href="#Generator.clone_sql-860"><span class="linenos">860</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.clone_sql-861"><a href="#Generator.clone_sql-861"><span class="linenos">861</span></a> <span class="n">shallow</span> <span class="o">=</span> <span class="s2">"SHALLOW "</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">"shallow"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.clone_sql-862"><a href="#Generator.clone_sql-862"><span class="linenos">862</span></a> <span class="n">keyword</span> <span class="o">=</span> <span class="s2">"COPY"</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">"copy"</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">SUPPORTS_TABLE_COPY</span> <span class="k">else</span> <span class="s2">"CLONE"</span> -</span><span id="Generator.clone_sql-863"><a href="#Generator.clone_sql-863"><span class="linenos">863</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">shallow</span><span class="si">}{</span><span class="n">keyword</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">"</span> -</span><span id="Generator.clone_sql-864"><a href="#Generator.clone_sql-864"><span class="linenos">864</span></a> <span class="n">when</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"when"</span><span class="p">)</span> -</span><span id="Generator.clone_sql-865"><a href="#Generator.clone_sql-865"><span class="linenos">865</span></a> -</span><span id="Generator.clone_sql-866"><a href="#Generator.clone_sql-866"><span class="linenos">866</span></a> <span class="k">if</span> <span class="n">when</span><span class="p">:</span> -</span><span id="Generator.clone_sql-867"><a href="#Generator.clone_sql-867"><span class="linenos">867</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.clone_sql-868"><a href="#Generator.clone_sql-868"><span class="linenos">868</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.clone_sql-869"><a href="#Generator.clone_sql-869"><span class="linenos">869</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">when</span><span class="si">}</span><span class="s2"> (</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">expr</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="Generator.clone_sql-870"><a href="#Generator.clone_sql-870"><span class="linenos">870</span></a> -</span><span id="Generator.clone_sql-871"><a href="#Generator.clone_sql-871"><span class="linenos">871</span></a> <span class="k">return</span> <span class="n">this</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.clone_sql-862"><a href="#Generator.clone_sql-862"><span class="linenos">862</span></a> <span class="k">def</span> <span class="nf">clone_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Clone</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.clone_sql-863"><a href="#Generator.clone_sql-863"><span class="linenos">863</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.clone_sql-864"><a href="#Generator.clone_sql-864"><span class="linenos">864</span></a> <span class="n">shallow</span> <span class="o">=</span> <span class="s2">"SHALLOW "</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">"shallow"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.clone_sql-865"><a href="#Generator.clone_sql-865"><span class="linenos">865</span></a> <span class="n">keyword</span> <span class="o">=</span> <span class="s2">"COPY"</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">"copy"</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">SUPPORTS_TABLE_COPY</span> <span class="k">else</span> <span class="s2">"CLONE"</span> +</span><span id="Generator.clone_sql-866"><a href="#Generator.clone_sql-866"><span class="linenos">866</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">shallow</span><span class="si">}{</span><span class="n">keyword</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">"</span> </span></pre></div> @@ -9050,8 +9132,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.describe_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.describe_sql-873"><a href="#Generator.describe_sql-873"><span class="linenos">873</span></a> <span class="k">def</span> <span class="nf">describe_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Describe</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.describe_sql-874"><a href="#Generator.describe_sql-874"><span class="linenos">874</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"DESCRIBE </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.describe_sql-868"><a href="#Generator.describe_sql-868"><span class="linenos">868</span></a> <span class="k">def</span> <span class="nf">describe_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Describe</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.describe_sql-869"><a href="#Generator.describe_sql-869"><span class="linenos">869</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"DESCRIBE </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> @@ -9069,11 +9151,11 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.prepend_ctes"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.prepend_ctes-876"><a href="#Generator.prepend_ctes-876"><span class="linenos">876</span></a> <span class="k">def</span> <span class="nf">prepend_ctes</span><span class="p">(</span><span class="bp">self</span><span 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">sql</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.prepend_ctes-877"><a href="#Generator.prepend_ctes-877"><span class="linenos">877</span></a> <span class="n">with_</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"with"</span><span class="p">)</span> -</span><span id="Generator.prepend_ctes-878"><a href="#Generator.prepend_ctes-878"><span class="linenos">878</span></a> <span class="k">if</span> <span class="n">with_</span><span class="p">:</span> -</span><span id="Generator.prepend_ctes-879"><a href="#Generator.prepend_ctes-879"><span class="linenos">879</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">with_</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="n">sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.prepend_ctes-880"><a href="#Generator.prepend_ctes-880"><span class="linenos">880</span></a> <span class="k">return</span> <span class="n">sql</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.prepend_ctes-871"><a href="#Generator.prepend_ctes-871"><span class="linenos">871</span></a> <span class="k">def</span> <span class="nf">prepend_ctes</span><span class="p">(</span><span class="bp">self</span><span 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">sql</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.prepend_ctes-872"><a href="#Generator.prepend_ctes-872"><span class="linenos">872</span></a> <span class="n">with_</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"with"</span><span class="p">)</span> +</span><span id="Generator.prepend_ctes-873"><a href="#Generator.prepend_ctes-873"><span class="linenos">873</span></a> <span class="k">if</span> <span class="n">with_</span><span class="p">:</span> +</span><span id="Generator.prepend_ctes-874"><a href="#Generator.prepend_ctes-874"><span class="linenos">874</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">with_</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="n">sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.prepend_ctes-875"><a href="#Generator.prepend_ctes-875"><span class="linenos">875</span></a> <span class="k">return</span> <span class="n">sql</span> </span></pre></div> @@ -9091,15 +9173,15 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.with_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.with_sql-882"><a href="#Generator.with_sql-882"><span class="linenos">882</span></a> <span class="k">def</span> <span class="nf">with_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">With</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.with_sql-883"><a href="#Generator.with_sql-883"><span class="linenos">883</span></a> <span class="n">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="kc">True</span><span class="p">)</span> -</span><span id="Generator.with_sql-884"><a href="#Generator.with_sql-884"><span class="linenos">884</span></a> <span class="n">recursive</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Generator.with_sql-885"><a href="#Generator.with_sql-885"><span class="linenos">885</span></a> <span class="s2">"RECURSIVE "</span> -</span><span id="Generator.with_sql-886"><a href="#Generator.with_sql-886"><span class="linenos">886</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">CTE_RECURSIVE_KEYWORD_REQUIRED</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">"recursive"</span><span class="p">)</span> -</span><span id="Generator.with_sql-887"><a href="#Generator.with_sql-887"><span class="linenos">887</span></a> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.with_sql-888"><a href="#Generator.with_sql-888"><span class="linenos">888</span></a> <span class="p">)</span> -</span><span id="Generator.with_sql-889"><a href="#Generator.with_sql-889"><span class="linenos">889</span></a> -</span><span id="Generator.with_sql-890"><a href="#Generator.with_sql-890"><span class="linenos">890</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"WITH </span><span class="si">{</span><span class="n">recursive</span><span class="si">}{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.with_sql-877"><a href="#Generator.with_sql-877"><span class="linenos">877</span></a> <span class="k">def</span> <span class="nf">with_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">With</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.with_sql-878"><a href="#Generator.with_sql-878"><span class="linenos">878</span></a> <span class="n">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="kc">True</span><span class="p">)</span> +</span><span id="Generator.with_sql-879"><a href="#Generator.with_sql-879"><span class="linenos">879</span></a> <span class="n">recursive</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Generator.with_sql-880"><a href="#Generator.with_sql-880"><span class="linenos">880</span></a> <span class="s2">"RECURSIVE "</span> +</span><span id="Generator.with_sql-881"><a href="#Generator.with_sql-881"><span class="linenos">881</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">CTE_RECURSIVE_KEYWORD_REQUIRED</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">"recursive"</span><span class="p">)</span> +</span><span id="Generator.with_sql-882"><a href="#Generator.with_sql-882"><span class="linenos">882</span></a> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.with_sql-883"><a href="#Generator.with_sql-883"><span class="linenos">883</span></a> <span class="p">)</span> +</span><span id="Generator.with_sql-884"><a href="#Generator.with_sql-884"><span class="linenos">884</span></a> +</span><span id="Generator.with_sql-885"><a href="#Generator.with_sql-885"><span class="linenos">885</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"WITH </span><span class="si">{</span><span class="n">recursive</span><span class="si">}{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -9117,9 +9199,9 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.cte_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.cte_sql-892"><a href="#Generator.cte_sql-892"><span class="linenos">892</span></a> <span class="k">def</span> <span class="nf">cte_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">CTE</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.cte_sql-893"><a href="#Generator.cte_sql-893"><span class="linenos">893</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.cte_sql-894"><a href="#Generator.cte_sql-894"><span class="linenos">894</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">alias</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">wrap</span><span class="p">(</span><span class="n">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.cte_sql-887"><a href="#Generator.cte_sql-887"><span class="linenos">887</span></a> <span class="k">def</span> <span class="nf">cte_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">CTE</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.cte_sql-888"><a href="#Generator.cte_sql-888"><span class="linenos">888</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.cte_sql-889"><a href="#Generator.cte_sql-889"><span class="linenos">889</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">alias</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">wrap</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -9137,15 +9219,15 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.tablealias_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.tablealias_sql-896"><a href="#Generator.tablealias_sql-896"><span class="linenos">896</span></a> <span class="k">def</span> <span class="nf">tablealias_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TableAlias</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.tablealias_sql-897"><a href="#Generator.tablealias_sql-897"><span class="linenos">897</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">"this"</span><span class="p">)</span> -</span><span id="Generator.tablealias_sql-898"><a href="#Generator.tablealias_sql-898"><span class="linenos">898</span></a> <span class="n">columns</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">"columns"</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.tablealias_sql-899"><a href="#Generator.tablealias_sql-899"><span class="linenos">899</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">columns</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">columns</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.tablealias_sql-900"><a href="#Generator.tablealias_sql-900"><span class="linenos">900</span></a> -</span><span id="Generator.tablealias_sql-901"><a href="#Generator.tablealias_sql-901"><span class="linenos">901</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">alias</span> <span class="ow">and</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">UNNEST_COLUMN_ONLY</span><span class="p">:</span> -</span><span id="Generator.tablealias_sql-902"><a href="#Generator.tablealias_sql-902"><span class="linenos">902</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="s2">"_t"</span> -</span><span id="Generator.tablealias_sql-903"><a href="#Generator.tablealias_sql-903"><span class="linenos">903</span></a> -</span><span id="Generator.tablealias_sql-904"><a href="#Generator.tablealias_sql-904"><span class="linenos">904</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">alias</span><span class="si">}{</span><span class="n">columns</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.tablealias_sql-891"><a href="#Generator.tablealias_sql-891"><span class="linenos">891</span></a> <span class="k">def</span> <span class="nf">tablealias_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TableAlias</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.tablealias_sql-892"><a href="#Generator.tablealias_sql-892"><span class="linenos">892</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">"this"</span><span class="p">)</span> +</span><span id="Generator.tablealias_sql-893"><a href="#Generator.tablealias_sql-893"><span class="linenos">893</span></a> <span class="n">columns</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">"columns"</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.tablealias_sql-894"><a href="#Generator.tablealias_sql-894"><span class="linenos">894</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">columns</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">columns</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.tablealias_sql-895"><a href="#Generator.tablealias_sql-895"><span class="linenos">895</span></a> +</span><span id="Generator.tablealias_sql-896"><a href="#Generator.tablealias_sql-896"><span class="linenos">896</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">alias</span> <span class="ow">and</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">UNNEST_COLUMN_ONLY</span><span class="p">:</span> +</span><span id="Generator.tablealias_sql-897"><a href="#Generator.tablealias_sql-897"><span class="linenos">897</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="s2">"_t"</span> +</span><span id="Generator.tablealias_sql-898"><a href="#Generator.tablealias_sql-898"><span class="linenos">898</span></a> +</span><span id="Generator.tablealias_sql-899"><a href="#Generator.tablealias_sql-899"><span class="linenos">899</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">alias</span><span class="si">}{</span><span class="n">columns</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -9163,11 +9245,11 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.bitstring_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.bitstring_sql-906"><a href="#Generator.bitstring_sql-906"><span class="linenos">906</span></a> <span class="k">def</span> <span class="nf">bitstring_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">BitString</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.bitstring_sql-907"><a href="#Generator.bitstring_sql-907"><span class="linenos">907</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.bitstring_sql-908"><a href="#Generator.bitstring_sql-908"><span class="linenos">908</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">BIT_START</span><span class="p">:</span> -</span><span id="Generator.bitstring_sql-909"><a href="#Generator.bitstring_sql-909"><span class="linenos">909</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">dialect</span><span class="o">.</span><span class="n">BIT_START</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">BIT_END</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.bitstring_sql-910"><a href="#Generator.bitstring_sql-910"><span class="linenos">910</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="nb">int</span><span class="p">(</span><span class="n">this</span><span class="p">,</span><span class="w"> </span><span class="mi">2</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.bitstring_sql-901"><a href="#Generator.bitstring_sql-901"><span class="linenos">901</span></a> <span class="k">def</span> <span class="nf">bitstring_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">BitString</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.bitstring_sql-902"><a href="#Generator.bitstring_sql-902"><span class="linenos">902</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.bitstring_sql-903"><a href="#Generator.bitstring_sql-903"><span class="linenos">903</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">BIT_START</span><span class="p">:</span> +</span><span id="Generator.bitstring_sql-904"><a href="#Generator.bitstring_sql-904"><span class="linenos">904</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">dialect</span><span class="o">.</span><span class="n">BIT_START</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">BIT_END</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.bitstring_sql-905"><a href="#Generator.bitstring_sql-905"><span class="linenos">905</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="nb">int</span><span class="p">(</span><span class="n">this</span><span class="p">,</span><span class="w"> </span><span class="mi">2</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -9185,11 +9267,11 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.hexstring_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.hexstring_sql-912"><a href="#Generator.hexstring_sql-912"><span class="linenos">912</span></a> <span class="k">def</span> <span class="nf">hexstring_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">HexString</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.hexstring_sql-913"><a href="#Generator.hexstring_sql-913"><span class="linenos">913</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.hexstring_sql-914"><a href="#Generator.hexstring_sql-914"><span class="linenos">914</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">HEX_START</span><span class="p">:</span> -</span><span id="Generator.hexstring_sql-915"><a href="#Generator.hexstring_sql-915"><span class="linenos">915</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">dialect</span><span class="o">.</span><span class="n">HEX_START</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">HEX_END</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.hexstring_sql-916"><a href="#Generator.hexstring_sql-916"><span class="linenos">916</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="nb">int</span><span class="p">(</span><span class="n">this</span><span class="p">,</span><span class="w"> </span><span class="mi">16</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.hexstring_sql-907"><a href="#Generator.hexstring_sql-907"><span class="linenos">907</span></a> <span class="k">def</span> <span class="nf">hexstring_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">HexString</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.hexstring_sql-908"><a href="#Generator.hexstring_sql-908"><span class="linenos">908</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.hexstring_sql-909"><a href="#Generator.hexstring_sql-909"><span class="linenos">909</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">HEX_START</span><span class="p">:</span> +</span><span id="Generator.hexstring_sql-910"><a href="#Generator.hexstring_sql-910"><span class="linenos">910</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">dialect</span><span class="o">.</span><span class="n">HEX_START</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">HEX_END</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.hexstring_sql-911"><a href="#Generator.hexstring_sql-911"><span class="linenos">911</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="nb">int</span><span class="p">(</span><span class="n">this</span><span class="p">,</span><span class="w"> </span><span class="mi">16</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -9207,11 +9289,11 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.bytestring_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.bytestring_sql-918"><a href="#Generator.bytestring_sql-918"><span class="linenos">918</span></a> <span class="k">def</span> <span class="nf">bytestring_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ByteString</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.bytestring_sql-919"><a href="#Generator.bytestring_sql-919"><span class="linenos">919</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.bytestring_sql-920"><a href="#Generator.bytestring_sql-920"><span class="linenos">920</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">BYTE_START</span><span class="p">:</span> -</span><span id="Generator.bytestring_sql-921"><a href="#Generator.bytestring_sql-921"><span class="linenos">921</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">dialect</span><span class="o">.</span><span class="n">BYTE_START</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">BYTE_END</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.bytestring_sql-922"><a href="#Generator.bytestring_sql-922"><span class="linenos">922</span></a> <span class="k">return</span> <span class="n">this</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.bytestring_sql-913"><a href="#Generator.bytestring_sql-913"><span class="linenos">913</span></a> <span class="k">def</span> <span class="nf">bytestring_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ByteString</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.bytestring_sql-914"><a href="#Generator.bytestring_sql-914"><span class="linenos">914</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.bytestring_sql-915"><a href="#Generator.bytestring_sql-915"><span class="linenos">915</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">BYTE_START</span><span class="p">:</span> +</span><span id="Generator.bytestring_sql-916"><a href="#Generator.bytestring_sql-916"><span class="linenos">916</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">dialect</span><span class="o">.</span><span class="n">BYTE_START</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">BYTE_END</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.bytestring_sql-917"><a href="#Generator.bytestring_sql-917"><span class="linenos">917</span></a> <span class="k">return</span> <span class="n">this</span> </span></pre></div> @@ -9229,9 +9311,9 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.rawstring_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.rawstring_sql-924"><a href="#Generator.rawstring_sql-924"><span class="linenos">924</span></a> <span class="k">def</span> <span class="nf">rawstring_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RawString</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.rawstring_sql-925"><a href="#Generator.rawstring_sql-925"><span class="linenos">925</span></a> <span class="n">string</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">escape_str</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">"</span><span class="se">\\</span><span class="s2">"</span><span class="p">,</span> <span class="s2">"</span><span class="se">\\\\</span><span class="s2">"</span><span class="p">))</span> -</span><span id="Generator.rawstring_sql-926"><a href="#Generator.rawstring_sql-926"><span class="linenos">926</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">dialect</span><span class="o">.</span><span class="n">QUOTE_START</span><span class="si">}{</span><span class="n">string</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">QUOTE_END</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.rawstring_sql-919"><a href="#Generator.rawstring_sql-919"><span class="linenos">919</span></a> <span class="k">def</span> <span class="nf">rawstring_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RawString</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.rawstring_sql-920"><a href="#Generator.rawstring_sql-920"><span class="linenos">920</span></a> <span class="n">string</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">escape_str</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">"</span><span class="se">\\</span><span class="s2">"</span><span class="p">,</span> <span class="s2">"</span><span class="se">\\\\</span><span class="s2">"</span><span class="p">))</span> +</span><span id="Generator.rawstring_sql-921"><a href="#Generator.rawstring_sql-921"><span class="linenos">921</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">dialect</span><span class="o">.</span><span class="n">QUOTE_START</span><span class="si">}{</span><span class="n">string</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">QUOTE_END</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -9249,11 +9331,11 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.datatypeparam_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.datatypeparam_sql-928"><a href="#Generator.datatypeparam_sql-928"><span class="linenos">928</span></a> <span class="k">def</span> <span class="nf">datatypeparam_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataTypeParam</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.datatypeparam_sql-929"><a href="#Generator.datatypeparam_sql-929"><span class="linenos">929</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.datatypeparam_sql-930"><a href="#Generator.datatypeparam_sql-930"><span class="linenos">930</span></a> <span class="n">specifier</span> <span class="o">=</span> <span class="bp">self</span><span 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.datatypeparam_sql-931"><a href="#Generator.datatypeparam_sql-931"><span class="linenos">931</span></a> <span class="n">specifier</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">specifier</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">specifier</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">DATA_TYPE_SPECIFIERS_ALLOWED</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.datatypeparam_sql-932"><a href="#Generator.datatypeparam_sql-932"><span class="linenos">932</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">specifier</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.datatypeparam_sql-923"><a href="#Generator.datatypeparam_sql-923"><span class="linenos">923</span></a> <span class="k">def</span> <span class="nf">datatypeparam_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataTypeParam</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.datatypeparam_sql-924"><a href="#Generator.datatypeparam_sql-924"><span class="linenos">924</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.datatypeparam_sql-925"><a href="#Generator.datatypeparam_sql-925"><span class="linenos">925</span></a> <span class="n">specifier</span> <span class="o">=</span> <span class="bp">self</span><span 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.datatypeparam_sql-926"><a href="#Generator.datatypeparam_sql-926"><span class="linenos">926</span></a> <span class="n">specifier</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">specifier</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">specifier</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">DATA_TYPE_SPECIFIERS_ALLOWED</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.datatypeparam_sql-927"><a href="#Generator.datatypeparam_sql-927"><span class="linenos">927</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">specifier</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -9271,42 +9353,42 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.datatype_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.datatype_sql-934"><a href="#Generator.datatype_sql-934"><span class="linenos">934</span></a> <span class="k">def</span> <span class="nf">datatype_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.datatype_sql-935"><a href="#Generator.datatype_sql-935"><span class="linenos">935</span></a> <span class="n">type_value</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> -</span><span id="Generator.datatype_sql-936"><a href="#Generator.datatype_sql-936"><span class="linenos">936</span></a> -</span><span id="Generator.datatype_sql-937"><a href="#Generator.datatype_sql-937"><span class="linenos">937</span></a> <span class="k">if</span> <span class="n">type_value</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">USERDEFINED</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">"kind"</span><span class="p">):</span> -</span><span id="Generator.datatype_sql-938"><a href="#Generator.datatype_sql-938"><span class="linenos">938</span></a> <span class="n">type_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">"kind"</span><span class="p">)</span> -</span><span id="Generator.datatype_sql-939"><a href="#Generator.datatype_sql-939"><span class="linenos">939</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator.datatype_sql-940"><a href="#Generator.datatype_sql-940"><span class="linenos">940</span></a> <span class="n">type_sql</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Generator.datatype_sql-941"><a href="#Generator.datatype_sql-941"><span class="linenos">941</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">TYPE_MAPPING</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">type_value</span><span class="p">,</span> <span class="n">type_value</span><span class="o">.</span><span class="n">value</span><span class="p">)</span> -</span><span id="Generator.datatype_sql-942"><a href="#Generator.datatype_sql-942"><span class="linenos">942</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">type_value</span><span class="p">,</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="p">)</span> -</span><span id="Generator.datatype_sql-943"><a href="#Generator.datatype_sql-943"><span class="linenos">943</span></a> <span class="k">else</span> <span class="n">type_value</span> -</span><span id="Generator.datatype_sql-944"><a href="#Generator.datatype_sql-944"><span class="linenos">944</span></a> <span class="p">)</span> -</span><span id="Generator.datatype_sql-945"><a href="#Generator.datatype_sql-945"><span class="linenos">945</span></a> -</span><span id="Generator.datatype_sql-946"><a href="#Generator.datatype_sql-946"><span class="linenos">946</span></a> <span class="n">nested</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator.datatype_sql-947"><a href="#Generator.datatype_sql-947"><span class="linenos">947</span></a> <span class="n">interior</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.datatype_sql-948"><a href="#Generator.datatype_sql-948"><span class="linenos">948</span></a> <span class="n">values</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator.datatype_sql-949"><a href="#Generator.datatype_sql-949"><span class="linenos">949</span></a> -</span><span id="Generator.datatype_sql-950"><a href="#Generator.datatype_sql-950"><span class="linenos">950</span></a> <span class="k">if</span> <span class="n">interior</span><span class="p">:</span> -</span><span id="Generator.datatype_sql-951"><a href="#Generator.datatype_sql-951"><span class="linenos">951</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">"nested"</span><span class="p">):</span> -</span><span id="Generator.datatype_sql-952"><a href="#Generator.datatype_sql-952"><span class="linenos">952</span></a> <span class="n">nested</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">STRUCT_DELIMITER</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="si">}{</span><span class="n">interior</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">STRUCT_DELIMITER</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.datatype_sql-953"><a href="#Generator.datatype_sql-953"><span class="linenos">953</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">"values"</span><span class="p">)</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Generator.datatype_sql-954"><a href="#Generator.datatype_sql-954"><span class="linenos">954</span></a> <span class="n">delimiters</span> <span class="o">=</span> <span class="p">(</span><span class="s2">"["</span><span class="p">,</span> <span class="s2">"]"</span><span class="p">)</span> <span class="k">if</span> <span class="n">type_value</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">ARRAY</span> <span class="k">else</span> <span class="p">(</span><span class="s2">"("</span><span class="p">,</span> <span class="s2">")"</span><span class="p">)</span> -</span><span id="Generator.datatype_sql-955"><a href="#Generator.datatype_sql-955"><span class="linenos">955</span></a> <span class="n">values</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">"values"</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.datatype_sql-956"><a href="#Generator.datatype_sql-956"><span class="linenos">956</span></a> <span class="n">values</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">delimiters</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="si">}{</span><span class="n">values</span><span class="si">}{</span><span class="n">delimiters</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.datatype_sql-957"><a href="#Generator.datatype_sql-957"><span class="linenos">957</span></a> <span class="k">elif</span> <span class="n">type_value</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">INTERVAL</span><span class="p">:</span> -</span><span id="Generator.datatype_sql-958"><a href="#Generator.datatype_sql-958"><span class="linenos">958</span></a> <span class="n">nested</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">interior</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.datatype_sql-959"><a href="#Generator.datatype_sql-959"><span class="linenos">959</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator.datatype_sql-960"><a href="#Generator.datatype_sql-960"><span class="linenos">960</span></a> <span class="n">nested</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">interior</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="Generator.datatype_sql-961"><a href="#Generator.datatype_sql-961"><span class="linenos">961</span></a> -</span><span id="Generator.datatype_sql-962"><a href="#Generator.datatype_sql-962"><span class="linenos">962</span></a> <span class="n">type_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">type_sql</span><span class="si">}{</span><span class="n">nested</span><span class="si">}{</span><span class="n">values</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.datatype_sql-963"><a href="#Generator.datatype_sql-963"><span class="linenos">963</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">TZ_TO_WITH_TIME_ZONE</span> <span class="ow">and</span> <span class="n">type_value</span> <span class="ow">in</span> <span class="p">(</span> -</span><span id="Generator.datatype_sql-964"><a href="#Generator.datatype_sql-964"><span class="linenos">964</span></a> <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">TIMETZ</span><span class="p">,</span> -</span><span id="Generator.datatype_sql-965"><a href="#Generator.datatype_sql-965"><span class="linenos">965</span></a> <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">TIMESTAMPTZ</span><span class="p">,</span> -</span><span id="Generator.datatype_sql-966"><a href="#Generator.datatype_sql-966"><span class="linenos">966</span></a> <span class="p">):</span> -</span><span id="Generator.datatype_sql-967"><a href="#Generator.datatype_sql-967"><span class="linenos">967</span></a> <span class="n">type_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">type_sql</span><span class="si">}</span><span class="s2"> WITH TIME ZONE"</span> -</span><span id="Generator.datatype_sql-968"><a href="#Generator.datatype_sql-968"><span class="linenos">968</span></a> -</span><span id="Generator.datatype_sql-969"><a href="#Generator.datatype_sql-969"><span class="linenos">969</span></a> <span class="k">return</span> <span class="n">type_sql</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.datatype_sql-929"><a href="#Generator.datatype_sql-929"><span class="linenos">929</span></a> <span class="k">def</span> <span class="nf">datatype_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.datatype_sql-930"><a href="#Generator.datatype_sql-930"><span class="linenos">930</span></a> <span class="n">type_value</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> +</span><span id="Generator.datatype_sql-931"><a href="#Generator.datatype_sql-931"><span class="linenos">931</span></a> +</span><span id="Generator.datatype_sql-932"><a href="#Generator.datatype_sql-932"><span class="linenos">932</span></a> <span class="k">if</span> <span class="n">type_value</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">USERDEFINED</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">"kind"</span><span class="p">):</span> +</span><span id="Generator.datatype_sql-933"><a href="#Generator.datatype_sql-933"><span class="linenos">933</span></a> <span class="n">type_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">"kind"</span><span class="p">)</span> +</span><span id="Generator.datatype_sql-934"><a href="#Generator.datatype_sql-934"><span class="linenos">934</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator.datatype_sql-935"><a href="#Generator.datatype_sql-935"><span class="linenos">935</span></a> <span class="n">type_sql</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Generator.datatype_sql-936"><a href="#Generator.datatype_sql-936"><span class="linenos">936</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">TYPE_MAPPING</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">type_value</span><span class="p">,</span> <span class="n">type_value</span><span class="o">.</span><span class="n">value</span><span class="p">)</span> +</span><span id="Generator.datatype_sql-937"><a href="#Generator.datatype_sql-937"><span class="linenos">937</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">type_value</span><span class="p">,</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="p">)</span> +</span><span id="Generator.datatype_sql-938"><a href="#Generator.datatype_sql-938"><span class="linenos">938</span></a> <span class="k">else</span> <span class="n">type_value</span> +</span><span id="Generator.datatype_sql-939"><a href="#Generator.datatype_sql-939"><span class="linenos">939</span></a> <span class="p">)</span> +</span><span id="Generator.datatype_sql-940"><a href="#Generator.datatype_sql-940"><span class="linenos">940</span></a> +</span><span id="Generator.datatype_sql-941"><a href="#Generator.datatype_sql-941"><span class="linenos">941</span></a> <span class="n">nested</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator.datatype_sql-942"><a href="#Generator.datatype_sql-942"><span class="linenos">942</span></a> <span class="n">interior</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.datatype_sql-943"><a href="#Generator.datatype_sql-943"><span class="linenos">943</span></a> <span class="n">values</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator.datatype_sql-944"><a href="#Generator.datatype_sql-944"><span class="linenos">944</span></a> +</span><span id="Generator.datatype_sql-945"><a href="#Generator.datatype_sql-945"><span class="linenos">945</span></a> <span class="k">if</span> <span class="n">interior</span><span class="p">:</span> +</span><span id="Generator.datatype_sql-946"><a href="#Generator.datatype_sql-946"><span class="linenos">946</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">"nested"</span><span class="p">):</span> +</span><span id="Generator.datatype_sql-947"><a href="#Generator.datatype_sql-947"><span class="linenos">947</span></a> <span class="n">nested</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">STRUCT_DELIMITER</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="si">}{</span><span class="n">interior</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">STRUCT_DELIMITER</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.datatype_sql-948"><a href="#Generator.datatype_sql-948"><span class="linenos">948</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">"values"</span><span class="p">)</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Generator.datatype_sql-949"><a href="#Generator.datatype_sql-949"><span class="linenos">949</span></a> <span class="n">delimiters</span> <span class="o">=</span> <span class="p">(</span><span class="s2">"["</span><span class="p">,</span> <span class="s2">"]"</span><span class="p">)</span> <span class="k">if</span> <span class="n">type_value</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">ARRAY</span> <span class="k">else</span> <span class="p">(</span><span class="s2">"("</span><span class="p">,</span> <span class="s2">")"</span><span class="p">)</span> +</span><span id="Generator.datatype_sql-950"><a href="#Generator.datatype_sql-950"><span class="linenos">950</span></a> <span class="n">values</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">"values"</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.datatype_sql-951"><a href="#Generator.datatype_sql-951"><span class="linenos">951</span></a> <span class="n">values</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">delimiters</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="si">}{</span><span class="n">values</span><span class="si">}{</span><span class="n">delimiters</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.datatype_sql-952"><a href="#Generator.datatype_sql-952"><span class="linenos">952</span></a> <span class="k">elif</span> <span class="n">type_value</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">INTERVAL</span><span class="p">:</span> +</span><span id="Generator.datatype_sql-953"><a href="#Generator.datatype_sql-953"><span class="linenos">953</span></a> <span class="n">nested</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">interior</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.datatype_sql-954"><a href="#Generator.datatype_sql-954"><span class="linenos">954</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator.datatype_sql-955"><a href="#Generator.datatype_sql-955"><span class="linenos">955</span></a> <span class="n">nested</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">interior</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Generator.datatype_sql-956"><a href="#Generator.datatype_sql-956"><span class="linenos">956</span></a> +</span><span id="Generator.datatype_sql-957"><a href="#Generator.datatype_sql-957"><span class="linenos">957</span></a> <span class="n">type_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">type_sql</span><span class="si">}{</span><span class="n">nested</span><span class="si">}{</span><span class="n">values</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.datatype_sql-958"><a href="#Generator.datatype_sql-958"><span class="linenos">958</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">TZ_TO_WITH_TIME_ZONE</span> <span class="ow">and</span> <span class="n">type_value</span> <span class="ow">in</span> <span class="p">(</span> +</span><span id="Generator.datatype_sql-959"><a href="#Generator.datatype_sql-959"><span class="linenos">959</span></a> <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">TIMETZ</span><span class="p">,</span> +</span><span id="Generator.datatype_sql-960"><a href="#Generator.datatype_sql-960"><span class="linenos">960</span></a> <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">TIMESTAMPTZ</span><span class="p">,</span> +</span><span id="Generator.datatype_sql-961"><a href="#Generator.datatype_sql-961"><span class="linenos">961</span></a> <span class="p">):</span> +</span><span id="Generator.datatype_sql-962"><a href="#Generator.datatype_sql-962"><span class="linenos">962</span></a> <span class="n">type_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">type_sql</span><span class="si">}</span><span class="s2"> WITH TIME ZONE"</span> +</span><span id="Generator.datatype_sql-963"><a href="#Generator.datatype_sql-963"><span class="linenos">963</span></a> +</span><span id="Generator.datatype_sql-964"><a href="#Generator.datatype_sql-964"><span class="linenos">964</span></a> <span class="k">return</span> <span class="n">type_sql</span> </span></pre></div> @@ -9324,11 +9406,11 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.directory_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.directory_sql-971"><a href="#Generator.directory_sql-971"><span class="linenos">971</span></a> <span class="k">def</span> <span class="nf">directory_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Directory</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.directory_sql-972"><a href="#Generator.directory_sql-972"><span class="linenos">972</span></a> <span class="n">local</span> <span class="o">=</span> <span class="s2">"LOCAL "</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">"local"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.directory_sql-973"><a href="#Generator.directory_sql-973"><span class="linenos">973</span></a> <span class="n">row_format</span> <span class="o">=</span> <span class="bp">self</span><span 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"</span><span class="p">)</span> -</span><span id="Generator.directory_sql-974"><a href="#Generator.directory_sql-974"><span class="linenos">974</span></a> <span class="n">row_format</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">row_format</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">row_format</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.directory_sql-975"><a href="#Generator.directory_sql-975"><span class="linenos">975</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">local</span><span class="si">}</span><span class="s2">DIRECTORY </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">row_format</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.directory_sql-966"><a href="#Generator.directory_sql-966"><span class="linenos">966</span></a> <span class="k">def</span> <span class="nf">directory_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Directory</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.directory_sql-967"><a href="#Generator.directory_sql-967"><span class="linenos">967</span></a> <span class="n">local</span> <span class="o">=</span> <span class="s2">"LOCAL "</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">"local"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.directory_sql-968"><a href="#Generator.directory_sql-968"><span class="linenos">968</span></a> <span class="n">row_format</span> <span class="o">=</span> <span class="bp">self</span><span 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"</span><span class="p">)</span> +</span><span id="Generator.directory_sql-969"><a href="#Generator.directory_sql-969"><span class="linenos">969</span></a> <span class="n">row_format</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">row_format</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">row_format</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.directory_sql-970"><a href="#Generator.directory_sql-970"><span class="linenos">970</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">local</span><span class="si">}</span><span class="s2">DIRECTORY </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">row_format</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -9346,21 +9428,21 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.delete_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.delete_sql-977"><a href="#Generator.delete_sql-977"><span class="linenos">977</span></a> <span class="k">def</span> <span class="nf">delete_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Delete</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.delete_sql-978"><a href="#Generator.delete_sql-978"><span class="linenos">978</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.delete_sql-979"><a href="#Generator.delete_sql-979"><span class="linenos">979</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" FROM </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.delete_sql-980"><a href="#Generator.delete_sql-980"><span class="linenos">980</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.delete_sql-981"><a href="#Generator.delete_sql-981"><span class="linenos">981</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.delete_sql-982"><a href="#Generator.delete_sql-982"><span class="linenos">982</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.delete_sql-983"><a href="#Generator.delete_sql-983"><span class="linenos">983</span></a> <span class="n">returning</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"returning"</span><span class="p">)</span> -</span><span id="Generator.delete_sql-984"><a href="#Generator.delete_sql-984"><span class="linenos">984</span></a> <span class="n">limit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"limit"</span><span class="p">)</span> -</span><span id="Generator.delete_sql-985"><a href="#Generator.delete_sql-985"><span class="linenos">985</span></a> <span class="n">tables</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">"tables"</span><span class="p">)</span> -</span><span id="Generator.delete_sql-986"><a href="#Generator.delete_sql-986"><span class="linenos">986</span></a> <span class="n">tables</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">tables</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">tables</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.delete_sql-987"><a href="#Generator.delete_sql-987"><span class="linenos">987</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">RETURNING_END</span><span class="p">:</span> -</span><span id="Generator.delete_sql-988"><a href="#Generator.delete_sql-988"><span class="linenos">988</span></a> <span class="n">expression_sql</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="n">using</span><span class="si">}{</span><span class="n">where</span><span class="si">}{</span><span class="n">returning</span><span class="si">}{</span><span class="n">limit</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.delete_sql-989"><a href="#Generator.delete_sql-989"><span class="linenos">989</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator.delete_sql-990"><a href="#Generator.delete_sql-990"><span class="linenos">990</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">returning</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="n">using</span><span class="si">}{</span><span class="n">where</span><span class="si">}{</span><span class="n">limit</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.delete_sql-991"><a href="#Generator.delete_sql-991"><span class="linenos">991</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="sa">f</span><span class="s2">"DELETE</span><span class="si">{</span><span class="n">tables</span><span class="si">}{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.delete_sql-972"><a href="#Generator.delete_sql-972"><span class="linenos">972</span></a> <span class="k">def</span> <span class="nf">delete_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Delete</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.delete_sql-973"><a href="#Generator.delete_sql-973"><span class="linenos">973</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.delete_sql-974"><a href="#Generator.delete_sql-974"><span class="linenos">974</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" FROM </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.delete_sql-975"><a href="#Generator.delete_sql-975"><span class="linenos">975</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.delete_sql-976"><a href="#Generator.delete_sql-976"><span class="linenos">976</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.delete_sql-977"><a href="#Generator.delete_sql-977"><span class="linenos">977</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.delete_sql-978"><a href="#Generator.delete_sql-978"><span class="linenos">978</span></a> <span class="n">returning</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"returning"</span><span class="p">)</span> +</span><span id="Generator.delete_sql-979"><a href="#Generator.delete_sql-979"><span class="linenos">979</span></a> <span class="n">limit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"limit"</span><span class="p">)</span> +</span><span id="Generator.delete_sql-980"><a href="#Generator.delete_sql-980"><span class="linenos">980</span></a> <span class="n">tables</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">"tables"</span><span class="p">)</span> +</span><span id="Generator.delete_sql-981"><a href="#Generator.delete_sql-981"><span class="linenos">981</span></a> <span class="n">tables</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">tables</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">tables</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.delete_sql-982"><a href="#Generator.delete_sql-982"><span class="linenos">982</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">RETURNING_END</span><span class="p">:</span> +</span><span id="Generator.delete_sql-983"><a href="#Generator.delete_sql-983"><span class="linenos">983</span></a> <span class="n">expression_sql</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="n">using</span><span class="si">}{</span><span class="n">where</span><span class="si">}{</span><span class="n">returning</span><span class="si">}{</span><span class="n">limit</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.delete_sql-984"><a href="#Generator.delete_sql-984"><span class="linenos">984</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator.delete_sql-985"><a href="#Generator.delete_sql-985"><span class="linenos">985</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">returning</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="n">using</span><span class="si">}{</span><span class="n">where</span><span class="si">}{</span><span class="n">limit</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.delete_sql-986"><a href="#Generator.delete_sql-986"><span class="linenos">986</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="sa">f</span><span class="s2">"DELETE</span><span class="si">{</span><span class="n">tables</span><span class="si">}{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> </span></pre></div> @@ -9378,18 +9460,18 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.drop_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.drop_sql-993"><a href="#Generator.drop_sql-993"><span class="linenos"> 993</span></a> <span class="k">def</span> <span class="nf">drop_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Drop</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.drop_sql-994"><a href="#Generator.drop_sql-994"><span class="linenos"> 994</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.drop_sql-995"><a href="#Generator.drop_sql-995"><span class="linenos"> 995</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.drop_sql-996"><a href="#Generator.drop_sql-996"><span class="linenos"> 996</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.drop_sql-997"><a href="#Generator.drop_sql-997"><span class="linenos"> 997</span></a> <span class="n">temporary</span> <span class="o">=</span> <span class="s2">" TEMPORARY"</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">"temporary"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.drop_sql-998"><a href="#Generator.drop_sql-998"><span class="linenos"> 998</span></a> <span class="n">materialized</span> <span class="o">=</span> <span class="s2">" MATERIALIZED"</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">"materialized"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.drop_sql-999"><a href="#Generator.drop_sql-999"><span class="linenos"> 999</span></a> <span class="n">cascade</span> <span class="o">=</span> <span class="s2">" CASCADE"</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">"cascade"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.drop_sql-1000"><a href="#Generator.drop_sql-1000"><span class="linenos">1000</span></a> <span class="n">constraints</span> <span class="o">=</span> <span class="s2">" CONSTRAINTS"</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">"constraints"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.drop_sql-1001"><a href="#Generator.drop_sql-1001"><span class="linenos">1001</span></a> <span class="n">purge</span> <span class="o">=</span> <span class="s2">" PURGE"</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">"purge"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.drop_sql-1002"><a href="#Generator.drop_sql-1002"><span class="linenos">1002</span></a> <span class="k">return</span> <span class="p">(</span> -</span><span id="Generator.drop_sql-1003"><a href="#Generator.drop_sql-1003"><span class="linenos">1003</span></a> <span class="sa">f</span><span class="s2">"DROP</span><span class="si">{</span><span class="n">temporary</span><span class="si">}{</span><span class="n">materialized</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">exists_sql</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="n">cascade</span><span class="si">}{</span><span class="n">constraints</span><span class="si">}{</span><span class="n">purge</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.drop_sql-1004"><a href="#Generator.drop_sql-1004"><span class="linenos">1004</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.drop_sql-988"><a href="#Generator.drop_sql-988"><span class="linenos">988</span></a> <span class="k">def</span> <span class="nf">drop_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Drop</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.drop_sql-989"><a href="#Generator.drop_sql-989"><span class="linenos">989</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.drop_sql-990"><a href="#Generator.drop_sql-990"><span class="linenos">990</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.drop_sql-991"><a href="#Generator.drop_sql-991"><span class="linenos">991</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.drop_sql-992"><a href="#Generator.drop_sql-992"><span class="linenos">992</span></a> <span class="n">temporary</span> <span class="o">=</span> <span class="s2">" TEMPORARY"</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">"temporary"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.drop_sql-993"><a href="#Generator.drop_sql-993"><span class="linenos">993</span></a> <span class="n">materialized</span> <span class="o">=</span> <span class="s2">" MATERIALIZED"</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">"materialized"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.drop_sql-994"><a href="#Generator.drop_sql-994"><span class="linenos">994</span></a> <span class="n">cascade</span> <span class="o">=</span> <span class="s2">" CASCADE"</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">"cascade"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.drop_sql-995"><a href="#Generator.drop_sql-995"><span class="linenos">995</span></a> <span class="n">constraints</span> <span class="o">=</span> <span class="s2">" CONSTRAINTS"</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">"constraints"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.drop_sql-996"><a href="#Generator.drop_sql-996"><span class="linenos">996</span></a> <span class="n">purge</span> <span class="o">=</span> <span class="s2">" PURGE"</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">"purge"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.drop_sql-997"><a href="#Generator.drop_sql-997"><span class="linenos">997</span></a> <span class="k">return</span> <span class="p">(</span> +</span><span id="Generator.drop_sql-998"><a href="#Generator.drop_sql-998"><span class="linenos">998</span></a> <span class="sa">f</span><span class="s2">"DROP</span><span class="si">{</span><span class="n">temporary</span><span class="si">}{</span><span class="n">materialized</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">exists_sql</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="n">cascade</span><span class="si">}{</span><span class="n">constraints</span><span class="si">}{</span><span class="n">purge</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.drop_sql-999"><a href="#Generator.drop_sql-999"><span class="linenos">999</span></a> <span class="p">)</span> </span></pre></div> @@ -9407,11 +9489,11 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.except_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.except_sql-1006"><a href="#Generator.except_sql-1006"><span class="linenos">1006</span></a> <span class="k">def</span> <span class="nf">except_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Except</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.except_sql-1007"><a href="#Generator.except_sql-1007"><span class="linenos">1007</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><span id="Generator.except_sql-1008"><a href="#Generator.except_sql-1008"><span class="linenos">1008</span></a> <span class="n">expression</span><span class="p">,</span> -</span><span id="Generator.except_sql-1009"><a href="#Generator.except_sql-1009"><span class="linenos">1009</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">set_operation</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">except_op</span><span class="p">(</span><span class="n">expression</span><span class="p">)),</span> -</span><span id="Generator.except_sql-1010"><a href="#Generator.except_sql-1010"><span class="linenos">1010</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.except_sql-1001"><a href="#Generator.except_sql-1001"><span class="linenos">1001</span></a> <span class="k">def</span> <span class="nf">except_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Except</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.except_sql-1002"><a href="#Generator.except_sql-1002"><span class="linenos">1002</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><span id="Generator.except_sql-1003"><a href="#Generator.except_sql-1003"><span class="linenos">1003</span></a> <span class="n">expression</span><span class="p">,</span> +</span><span id="Generator.except_sql-1004"><a href="#Generator.except_sql-1004"><span class="linenos">1004</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">set_operation</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">except_op</span><span class="p">(</span><span class="n">expression</span><span class="p">)),</span> +</span><span id="Generator.except_sql-1005"><a href="#Generator.except_sql-1005"><span class="linenos">1005</span></a> <span class="p">)</span> </span></pre></div> @@ -9429,8 +9511,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.except_op"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.except_op-1012"><a href="#Generator.except_op-1012"><span class="linenos">1012</span></a> <span class="k">def</span> <span class="nf">except_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Except</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.except_op-1013"><a href="#Generator.except_op-1013"><span class="linenos">1013</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"EXCEPT</span><span class="si">{</span><span class="s1">''</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">'distinct'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">' ALL'</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.except_op-1007"><a href="#Generator.except_op-1007"><span class="linenos">1007</span></a> <span class="k">def</span> <span class="nf">except_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Except</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.except_op-1008"><a href="#Generator.except_op-1008"><span class="linenos">1008</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"EXCEPT</span><span class="si">{</span><span class="s1">''</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">'distinct'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">' ALL'</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -9448,15 +9530,15 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.fetch_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.fetch_sql-1015"><a href="#Generator.fetch_sql-1015"><span class="linenos">1015</span></a> <span class="k">def</span> <span class="nf">fetch_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.fetch_sql-1016"><a href="#Generator.fetch_sql-1016"><span class="linenos">1016</span></a> <span class="n">direction</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">"direction"</span><span class="p">)</span> -</span><span id="Generator.fetch_sql-1017"><a href="#Generator.fetch_sql-1017"><span class="linenos">1017</span></a> <span class="n">direction</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">direction</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">direction</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.fetch_sql-1018"><a href="#Generator.fetch_sql-1018"><span class="linenos">1018</span></a> <span class="n">count</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">"count"</span><span class="p">)</span> -</span><span id="Generator.fetch_sql-1019"><a href="#Generator.fetch_sql-1019"><span class="linenos">1019</span></a> <span class="n">count</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">count</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">count</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.fetch_sql-1020"><a href="#Generator.fetch_sql-1020"><span class="linenos">1020</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">"percent"</span><span class="p">):</span> -</span><span id="Generator.fetch_sql-1021"><a href="#Generator.fetch_sql-1021"><span class="linenos">1021</span></a> <span class="n">count</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">count</span><span class="si">}</span><span class="s2"> PERCENT"</span> -</span><span id="Generator.fetch_sql-1022"><a href="#Generator.fetch_sql-1022"><span class="linenos">1022</span></a> <span class="n">with_ties_or_only</span> <span class="o">=</span> <span class="s2">"WITH TIES"</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">"with_ties"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">"ONLY"</span> -</span><span id="Generator.fetch_sql-1023"><a href="#Generator.fetch_sql-1023"><span class="linenos">1023</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="s1">'FETCH'</span><span class="p">)</span><span class="si">}{</span><span class="n">direction</span><span class="si">}{</span><span class="n">count</span><span class="si">}</span><span class="s2"> ROWS </span><span class="si">{</span><span class="n">with_ties_or_only</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.fetch_sql-1010"><a href="#Generator.fetch_sql-1010"><span class="linenos">1010</span></a> <span class="k">def</span> <span class="nf">fetch_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.fetch_sql-1011"><a href="#Generator.fetch_sql-1011"><span class="linenos">1011</span></a> <span class="n">direction</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">"direction"</span><span class="p">)</span> +</span><span id="Generator.fetch_sql-1012"><a href="#Generator.fetch_sql-1012"><span class="linenos">1012</span></a> <span class="n">direction</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">direction</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">direction</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.fetch_sql-1013"><a href="#Generator.fetch_sql-1013"><span class="linenos">1013</span></a> <span class="n">count</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">"count"</span><span class="p">)</span> +</span><span id="Generator.fetch_sql-1014"><a href="#Generator.fetch_sql-1014"><span class="linenos">1014</span></a> <span class="n">count</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">count</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">count</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.fetch_sql-1015"><a href="#Generator.fetch_sql-1015"><span class="linenos">1015</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">"percent"</span><span class="p">):</span> +</span><span id="Generator.fetch_sql-1016"><a href="#Generator.fetch_sql-1016"><span class="linenos">1016</span></a> <span class="n">count</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">count</span><span class="si">}</span><span class="s2"> PERCENT"</span> +</span><span id="Generator.fetch_sql-1017"><a href="#Generator.fetch_sql-1017"><span class="linenos">1017</span></a> <span class="n">with_ties_or_only</span> <span class="o">=</span> <span class="s2">"WITH TIES"</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">"with_ties"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">"ONLY"</span> +</span><span id="Generator.fetch_sql-1018"><a href="#Generator.fetch_sql-1018"><span class="linenos">1018</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="s1">'FETCH'</span><span class="p">)</span><span class="si">}{</span><span class="n">direction</span><span class="si">}{</span><span class="n">count</span><span class="si">}</span><span class="s2"> ROWS </span><span class="si">{</span><span class="n">with_ties_or_only</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -9474,17 +9556,17 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.filter_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.filter_sql-1025"><a href="#Generator.filter_sql-1025"><span class="linenos">1025</span></a> <span class="k">def</span> <span class="nf">filter_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Filter</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.filter_sql-1026"><a href="#Generator.filter_sql-1026"><span class="linenos">1026</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">AGGREGATE_FILTER_SUPPORTED</span><span class="p">:</span> -</span><span id="Generator.filter_sql-1027"><a href="#Generator.filter_sql-1027"><span class="linenos">1027</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.filter_sql-1028"><a href="#Generator.filter_sql-1028"><span class="linenos">1028</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">"expression"</span><span class="p">)</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> -</span><span id="Generator.filter_sql-1029"><a href="#Generator.filter_sql-1029"><span class="linenos">1029</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"> FILTER(</span><span class="si">{</span><span class="n">where</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="Generator.filter_sql-1030"><a href="#Generator.filter_sql-1030"><span class="linenos">1030</span></a> -</span><span id="Generator.filter_sql-1031"><a href="#Generator.filter_sql-1031"><span class="linenos">1031</span></a> <span class="n">agg</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> -</span><span id="Generator.filter_sql-1032"><a href="#Generator.filter_sql-1032"><span class="linenos">1032</span></a> <span class="n">agg_arg</span> <span class="o">=</span> <span class="n">agg</span><span class="o">.</span><span class="n">this</span> -</span><span id="Generator.filter_sql-1033"><a href="#Generator.filter_sql-1033"><span class="linenos">1033</span></a> <span class="n">cond</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">this</span> -</span><span id="Generator.filter_sql-1034"><a href="#Generator.filter_sql-1034"><span class="linenos">1034</span></a> <span class="n">agg_arg</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">If</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">cond</span><span class="o">.</span><span class="n">copy</span><span class="p">(),</span> <span class="n">true</span><span class="o">=</span><span class="n">agg_arg</span><span class="o">.</span><span class="n">copy</span><span class="p">()))</span> -</span><span id="Generator.filter_sql-1035"><a href="#Generator.filter_sql-1035"><span class="linenos">1035</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">agg</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.filter_sql-1020"><a href="#Generator.filter_sql-1020"><span class="linenos">1020</span></a> <span class="k">def</span> <span class="nf">filter_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Filter</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.filter_sql-1021"><a href="#Generator.filter_sql-1021"><span class="linenos">1021</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">AGGREGATE_FILTER_SUPPORTED</span><span class="p">:</span> +</span><span id="Generator.filter_sql-1022"><a href="#Generator.filter_sql-1022"><span class="linenos">1022</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.filter_sql-1023"><a href="#Generator.filter_sql-1023"><span class="linenos">1023</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">"expression"</span><span class="p">)</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> +</span><span id="Generator.filter_sql-1024"><a href="#Generator.filter_sql-1024"><span class="linenos">1024</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"> FILTER(</span><span class="si">{</span><span class="n">where</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Generator.filter_sql-1025"><a href="#Generator.filter_sql-1025"><span class="linenos">1025</span></a> +</span><span id="Generator.filter_sql-1026"><a href="#Generator.filter_sql-1026"><span class="linenos">1026</span></a> <span class="n">agg</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> +</span><span id="Generator.filter_sql-1027"><a href="#Generator.filter_sql-1027"><span class="linenos">1027</span></a> <span class="n">agg_arg</span> <span class="o">=</span> <span class="n">agg</span><span class="o">.</span><span class="n">this</span> +</span><span id="Generator.filter_sql-1028"><a href="#Generator.filter_sql-1028"><span class="linenos">1028</span></a> <span class="n">cond</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">this</span> +</span><span id="Generator.filter_sql-1029"><a href="#Generator.filter_sql-1029"><span class="linenos">1029</span></a> <span class="n">agg_arg</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">If</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">cond</span><span class="o">.</span><span class="n">copy</span><span class="p">(),</span> <span class="n">true</span><span class="o">=</span><span class="n">agg_arg</span><span class="o">.</span><span class="n">copy</span><span class="p">()))</span> +</span><span id="Generator.filter_sql-1030"><a href="#Generator.filter_sql-1030"><span class="linenos">1030</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">agg</span><span class="p">)</span> </span></pre></div> @@ -9502,12 +9584,12 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.hint_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.hint_sql-1037"><a href="#Generator.hint_sql-1037"><span class="linenos">1037</span></a> <span class="k">def</span> <span class="nf">hint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Hint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.hint_sql-1038"><a href="#Generator.hint_sql-1038"><span class="linenos">1038</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">QUERY_HINTS</span><span class="p">:</span> -</span><span id="Generator.hint_sql-1039"><a href="#Generator.hint_sql-1039"><span class="linenos">1039</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Hints are not supported"</span><span class="p">)</span> -</span><span id="Generator.hint_sql-1040"><a href="#Generator.hint_sql-1040"><span class="linenos">1040</span></a> <span class="k">return</span> <span class="s2">""</span> -</span><span id="Generator.hint_sql-1041"><a href="#Generator.hint_sql-1041"><span class="linenos">1041</span></a> -</span><span id="Generator.hint_sql-1042"><a href="#Generator.hint_sql-1042"><span class="linenos">1042</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">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">QUERY_HINT_SEP</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.hint_sql-1032"><a href="#Generator.hint_sql-1032"><span class="linenos">1032</span></a> <span class="k">def</span> <span class="nf">hint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Hint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.hint_sql-1033"><a href="#Generator.hint_sql-1033"><span class="linenos">1033</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">QUERY_HINTS</span><span class="p">:</span> +</span><span id="Generator.hint_sql-1034"><a href="#Generator.hint_sql-1034"><span class="linenos">1034</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Hints are not supported"</span><span class="p">)</span> +</span><span id="Generator.hint_sql-1035"><a href="#Generator.hint_sql-1035"><span class="linenos">1035</span></a> <span class="k">return</span> <span class="s2">""</span> +</span><span id="Generator.hint_sql-1036"><a href="#Generator.hint_sql-1036"><span class="linenos">1036</span></a> +</span><span id="Generator.hint_sql-1037"><a href="#Generator.hint_sql-1037"><span class="linenos">1037</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">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">QUERY_HINT_SEP</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> @@ -9525,23 +9607,23 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.index_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.index_sql-1044"><a href="#Generator.index_sql-1044"><span class="linenos">1044</span></a> <span class="k">def</span> <span class="nf">index_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Index</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.index_sql-1045"><a href="#Generator.index_sql-1045"><span class="linenos">1045</span></a> <span class="n">unique</span> <span class="o">=</span> <span class="s2">"UNIQUE "</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">"unique"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.index_sql-1046"><a href="#Generator.index_sql-1046"><span class="linenos">1046</span></a> <span class="n">primary</span> <span class="o">=</span> <span class="s2">"PRIMARY "</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">"primary"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.index_sql-1047"><a href="#Generator.index_sql-1047"><span class="linenos">1047</span></a> <span class="n">amp</span> <span class="o">=</span> <span class="s2">"AMP "</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">"amp"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.index_sql-1048"><a href="#Generator.index_sql-1048"><span class="linenos">1048</span></a> <span class="n">name</span> <span class="o">=</span> <span class="bp">self</span><span 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.index_sql-1049"><a href="#Generator.index_sql-1049"><span class="linenos">1049</span></a> <span class="n">name</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">name</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">name</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.index_sql-1050"><a href="#Generator.index_sql-1050"><span class="linenos">1050</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">"table"</span><span class="p">)</span> -</span><span id="Generator.index_sql-1051"><a href="#Generator.index_sql-1051"><span class="linenos">1051</span></a> <span class="n">table</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">INDEX_ON</span><span class="si">}</span><span class="s2"> </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="n">table</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.index_sql-1052"><a href="#Generator.index_sql-1052"><span class="linenos">1052</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.index_sql-1053"><a href="#Generator.index_sql-1053"><span class="linenos">1053</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.index_sql-1054"><a href="#Generator.index_sql-1054"><span class="linenos">1054</span></a> <span class="n">index</span> <span class="o">=</span> <span class="s2">"INDEX "</span> <span class="k">if</span> <span class="ow">not</span> <span class="n">table</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.index_sql-1055"><a href="#Generator.index_sql-1055"><span class="linenos">1055</span></a> <span class="n">columns</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">"columns"</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.index_sql-1056"><a href="#Generator.index_sql-1056"><span class="linenos">1056</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">columns</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">columns</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.index_sql-1057"><a href="#Generator.index_sql-1057"><span class="linenos">1057</span></a> <span class="n">partition_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">"partition_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.index_sql-1058"><a href="#Generator.index_sql-1058"><span class="linenos">1058</span></a> <span class="n">partition_by</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" PARTITION BY </span><span class="si">{</span><span class="n">partition_by</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">partition_by</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.index_sql-1059"><a href="#Generator.index_sql-1059"><span class="linenos">1059</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.index_sql-1060"><a href="#Generator.index_sql-1060"><span class="linenos">1060</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">unique</span><span class="si">}{</span><span class="n">primary</span><span class="si">}{</span><span class="n">amp</span><span class="si">}{</span><span class="n">index</span><span class="si">}{</span><span class="n">name</span><span class="si">}{</span><span class="n">table</span><span class="si">}{</span><span class="n">using</span><span class="si">}{</span><span class="n">columns</span><span class="si">}{</span><span class="n">partition_by</span><span class="si">}{</span><span class="n">where</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.index_sql-1039"><a href="#Generator.index_sql-1039"><span class="linenos">1039</span></a> <span class="k">def</span> <span class="nf">index_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Index</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.index_sql-1040"><a href="#Generator.index_sql-1040"><span class="linenos">1040</span></a> <span class="n">unique</span> <span class="o">=</span> <span class="s2">"UNIQUE "</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">"unique"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.index_sql-1041"><a href="#Generator.index_sql-1041"><span class="linenos">1041</span></a> <span class="n">primary</span> <span class="o">=</span> <span class="s2">"PRIMARY "</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">"primary"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.index_sql-1042"><a href="#Generator.index_sql-1042"><span class="linenos">1042</span></a> <span class="n">amp</span> <span class="o">=</span> <span class="s2">"AMP "</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">"amp"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.index_sql-1043"><a href="#Generator.index_sql-1043"><span class="linenos">1043</span></a> <span class="n">name</span> <span class="o">=</span> <span class="bp">self</span><span 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.index_sql-1044"><a href="#Generator.index_sql-1044"><span class="linenos">1044</span></a> <span class="n">name</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">name</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">name</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.index_sql-1045"><a href="#Generator.index_sql-1045"><span class="linenos">1045</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">"table"</span><span class="p">)</span> +</span><span id="Generator.index_sql-1046"><a href="#Generator.index_sql-1046"><span class="linenos">1046</span></a> <span class="n">table</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">INDEX_ON</span><span class="si">}</span><span class="s2"> </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="n">table</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.index_sql-1047"><a href="#Generator.index_sql-1047"><span class="linenos">1047</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.index_sql-1048"><a href="#Generator.index_sql-1048"><span class="linenos">1048</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.index_sql-1049"><a href="#Generator.index_sql-1049"><span class="linenos">1049</span></a> <span class="n">index</span> <span class="o">=</span> <span class="s2">"INDEX "</span> <span class="k">if</span> <span class="ow">not</span> <span class="n">table</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.index_sql-1050"><a href="#Generator.index_sql-1050"><span class="linenos">1050</span></a> <span class="n">columns</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">"columns"</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.index_sql-1051"><a href="#Generator.index_sql-1051"><span class="linenos">1051</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">columns</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">columns</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.index_sql-1052"><a href="#Generator.index_sql-1052"><span class="linenos">1052</span></a> <span class="n">partition_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">"partition_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.index_sql-1053"><a href="#Generator.index_sql-1053"><span class="linenos">1053</span></a> <span class="n">partition_by</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" PARTITION BY </span><span class="si">{</span><span class="n">partition_by</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">partition_by</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.index_sql-1054"><a href="#Generator.index_sql-1054"><span class="linenos">1054</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.index_sql-1055"><a href="#Generator.index_sql-1055"><span class="linenos">1055</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">unique</span><span class="si">}{</span><span class="n">primary</span><span class="si">}{</span><span class="n">amp</span><span class="si">}{</span><span class="n">index</span><span class="si">}{</span><span class="n">name</span><span class="si">}{</span><span class="n">table</span><span class="si">}{</span><span class="n">using</span><span class="si">}{</span><span class="n">columns</span><span class="si">}{</span><span class="n">partition_by</span><span class="si">}{</span><span class="n">where</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -9559,19 +9641,19 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.identifier_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.identifier_sql-1062"><a href="#Generator.identifier_sql-1062"><span class="linenos">1062</span></a> <span class="k">def</span> <span class="nf">identifier_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.identifier_sql-1063"><a href="#Generator.identifier_sql-1063"><span class="linenos">1063</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">name</span> -</span><span id="Generator.identifier_sql-1064"><a href="#Generator.identifier_sql-1064"><span class="linenos">1064</span></a> <span class="n">lower</span> <span class="o">=</span> <span class="n">text</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> -</span><span id="Generator.identifier_sql-1065"><a href="#Generator.identifier_sql-1065"><span class="linenos">1065</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">lower</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">normalize</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">quoted</span> <span class="k">else</span> <span class="n">text</span> -</span><span id="Generator.identifier_sql-1066"><a href="#Generator.identifier_sql-1066"><span class="linenos">1066</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">text</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">IDENTIFIER_END</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_escaped_identifier_end</span><span class="p">)</span> -</span><span id="Generator.identifier_sql-1067"><a href="#Generator.identifier_sql-1067"><span class="linenos">1067</span></a> <span class="k">if</span> <span class="p">(</span> -</span><span id="Generator.identifier_sql-1068"><a href="#Generator.identifier_sql-1068"><span class="linenos">1068</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">quoted</span> -</span><span id="Generator.identifier_sql-1069"><a href="#Generator.identifier_sql-1069"><span class="linenos">1069</span></a> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">can_identify</span><span class="p">(</span><span class="n">text</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">identify</span><span class="p">)</span> -</span><span id="Generator.identifier_sql-1070"><a href="#Generator.identifier_sql-1070"><span class="linenos">1070</span></a> <span class="ow">or</span> <span class="n">lower</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">RESERVED_KEYWORDS</span> -</span><span id="Generator.identifier_sql-1071"><a href="#Generator.identifier_sql-1071"><span class="linenos">1071</span></a> <span class="ow">or</span> <span class="p">(</span><span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">IDENTIFIERS_CAN_START_WITH_DIGIT</span> <span class="ow">and</span> <span class="n">text</span><span class="p">[:</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">isdigit</span><span class="p">())</span> -</span><span id="Generator.identifier_sql-1072"><a href="#Generator.identifier_sql-1072"><span class="linenos">1072</span></a> <span class="p">):</span> -</span><span id="Generator.identifier_sql-1073"><a href="#Generator.identifier_sql-1073"><span class="linenos">1073</span></a> <span class="n">text</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">dialect</span><span class="o">.</span><span class="n">IDENTIFIER_START</span><span class="si">}{</span><span class="n">text</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">IDENTIFIER_END</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.identifier_sql-1074"><a href="#Generator.identifier_sql-1074"><span class="linenos">1074</span></a> <span class="k">return</span> <span class="n">text</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.identifier_sql-1057"><a href="#Generator.identifier_sql-1057"><span class="linenos">1057</span></a> <span class="k">def</span> <span class="nf">identifier_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.identifier_sql-1058"><a href="#Generator.identifier_sql-1058"><span class="linenos">1058</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">name</span> +</span><span id="Generator.identifier_sql-1059"><a href="#Generator.identifier_sql-1059"><span class="linenos">1059</span></a> <span class="n">lower</span> <span class="o">=</span> <span class="n">text</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> +</span><span id="Generator.identifier_sql-1060"><a href="#Generator.identifier_sql-1060"><span class="linenos">1060</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">lower</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">normalize</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">quoted</span> <span class="k">else</span> <span class="n">text</span> +</span><span id="Generator.identifier_sql-1061"><a href="#Generator.identifier_sql-1061"><span class="linenos">1061</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">text</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">IDENTIFIER_END</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_escaped_identifier_end</span><span class="p">)</span> +</span><span id="Generator.identifier_sql-1062"><a href="#Generator.identifier_sql-1062"><span class="linenos">1062</span></a> <span class="k">if</span> <span class="p">(</span> +</span><span id="Generator.identifier_sql-1063"><a href="#Generator.identifier_sql-1063"><span class="linenos">1063</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">quoted</span> +</span><span id="Generator.identifier_sql-1064"><a href="#Generator.identifier_sql-1064"><span class="linenos">1064</span></a> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">can_identify</span><span class="p">(</span><span class="n">text</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">identify</span><span class="p">)</span> +</span><span id="Generator.identifier_sql-1065"><a href="#Generator.identifier_sql-1065"><span class="linenos">1065</span></a> <span class="ow">or</span> <span class="n">lower</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">RESERVED_KEYWORDS</span> +</span><span id="Generator.identifier_sql-1066"><a href="#Generator.identifier_sql-1066"><span class="linenos">1066</span></a> <span class="ow">or</span> <span class="p">(</span><span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">IDENTIFIERS_CAN_START_WITH_DIGIT</span> <span class="ow">and</span> <span class="n">text</span><span class="p">[:</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">isdigit</span><span class="p">())</span> +</span><span id="Generator.identifier_sql-1067"><a href="#Generator.identifier_sql-1067"><span class="linenos">1067</span></a> <span class="p">):</span> +</span><span id="Generator.identifier_sql-1068"><a href="#Generator.identifier_sql-1068"><span class="linenos">1068</span></a> <span class="n">text</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">dialect</span><span class="o">.</span><span class="n">IDENTIFIER_START</span><span class="si">}{</span><span class="n">text</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">IDENTIFIER_END</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.identifier_sql-1069"><a href="#Generator.identifier_sql-1069"><span class="linenos">1069</span></a> <span class="k">return</span> <span class="n">text</span> </span></pre></div> @@ -9589,12 +9671,12 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.inputoutputformat_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.inputoutputformat_sql-1076"><a href="#Generator.inputoutputformat_sql-1076"><span class="linenos">1076</span></a> <span class="k">def</span> <span class="nf">inputoutputformat_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">InputOutputFormat</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.inputoutputformat_sql-1077"><a href="#Generator.inputoutputformat_sql-1077"><span class="linenos">1077</span></a> <span class="n">input_format</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"input_format"</span><span class="p">)</span> -</span><span id="Generator.inputoutputformat_sql-1078"><a href="#Generator.inputoutputformat_sql-1078"><span class="linenos">1078</span></a> <span class="n">input_format</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"INPUTFORMAT </span><span class="si">{</span><span class="n">input_format</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">input_format</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.inputoutputformat_sql-1079"><a href="#Generator.inputoutputformat_sql-1079"><span class="linenos">1079</span></a> <span class="n">output_format</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"output_format"</span><span class="p">)</span> -</span><span id="Generator.inputoutputformat_sql-1080"><a href="#Generator.inputoutputformat_sql-1080"><span class="linenos">1080</span></a> <span class="n">output_format</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"OUTPUTFORMAT </span><span class="si">{</span><span class="n">output_format</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">output_format</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.inputoutputformat_sql-1081"><a href="#Generator.inputoutputformat_sql-1081"><span class="linenos">1081</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="o">.</span><span class="n">join</span><span class="p">((</span><span class="n">input_format</span><span class="p">,</span> <span class="n">output_format</span><span class="p">))</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.inputoutputformat_sql-1071"><a href="#Generator.inputoutputformat_sql-1071"><span class="linenos">1071</span></a> <span class="k">def</span> <span class="nf">inputoutputformat_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">InputOutputFormat</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.inputoutputformat_sql-1072"><a href="#Generator.inputoutputformat_sql-1072"><span class="linenos">1072</span></a> <span class="n">input_format</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"input_format"</span><span class="p">)</span> +</span><span id="Generator.inputoutputformat_sql-1073"><a href="#Generator.inputoutputformat_sql-1073"><span class="linenos">1073</span></a> <span class="n">input_format</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"INPUTFORMAT </span><span class="si">{</span><span class="n">input_format</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">input_format</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.inputoutputformat_sql-1074"><a href="#Generator.inputoutputformat_sql-1074"><span class="linenos">1074</span></a> <span class="n">output_format</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"output_format"</span><span class="p">)</span> +</span><span id="Generator.inputoutputformat_sql-1075"><a href="#Generator.inputoutputformat_sql-1075"><span class="linenos">1075</span></a> <span class="n">output_format</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"OUTPUTFORMAT </span><span class="si">{</span><span class="n">output_format</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">output_format</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.inputoutputformat_sql-1076"><a href="#Generator.inputoutputformat_sql-1076"><span class="linenos">1076</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="o">.</span><span class="n">join</span><span class="p">((</span><span class="n">input_format</span><span class="p">,</span> <span class="n">output_format</span><span class="p">))</span> </span></pre></div> @@ -9612,9 +9694,9 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.national_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.national_sql-1083"><a href="#Generator.national_sql-1083"><span class="linenos">1083</span></a> <span class="k">def</span> <span class="nf">national_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">National</span><span class="p">,</span> <span class="n">prefix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"N"</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.national_sql-1084"><a href="#Generator.national_sql-1084"><span class="linenos">1084</span></a> <span class="n">string</span> <span class="o">=</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">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="p">))</span> -</span><span id="Generator.national_sql-1085"><a href="#Generator.national_sql-1085"><span class="linenos">1085</span></a> <span class="k">return</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">string</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.national_sql-1078"><a href="#Generator.national_sql-1078"><span class="linenos">1078</span></a> <span class="k">def</span> <span class="nf">national_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">National</span><span class="p">,</span> <span class="n">prefix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"N"</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.national_sql-1079"><a href="#Generator.national_sql-1079"><span class="linenos">1079</span></a> <span class="n">string</span> <span class="o">=</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">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="p">))</span> +</span><span id="Generator.national_sql-1080"><a href="#Generator.national_sql-1080"><span class="linenos">1080</span></a> <span class="k">return</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">string</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -9632,8 +9714,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.partition_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.partition_sql-1087"><a href="#Generator.partition_sql-1087"><span class="linenos">1087</span></a> <span class="k">def</span> <span class="nf">partition_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Partition</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.partition_sql-1088"><a href="#Generator.partition_sql-1088"><span class="linenos">1088</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PARTITION(</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.partition_sql-1082"><a href="#Generator.partition_sql-1082"><span class="linenos">1082</span></a> <span class="k">def</span> <span class="nf">partition_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Partition</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.partition_sql-1083"><a href="#Generator.partition_sql-1083"><span class="linenos">1083</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PARTITION(</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> @@ -9651,20 +9733,20 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.properties_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.properties_sql-1090"><a href="#Generator.properties_sql-1090"><span class="linenos">1090</span></a> <span class="k">def</span> <span class="nf">properties_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.properties_sql-1091"><a href="#Generator.properties_sql-1091"><span class="linenos">1091</span></a> <span class="n">root_properties</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="Generator.properties_sql-1092"><a href="#Generator.properties_sql-1092"><span class="linenos">1092</span></a> <span class="n">with_properties</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="Generator.properties_sql-1093"><a href="#Generator.properties_sql-1093"><span class="linenos">1093</span></a> -</span><span id="Generator.properties_sql-1094"><a href="#Generator.properties_sql-1094"><span class="linenos">1094</span></a> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> -</span><span id="Generator.properties_sql-1095"><a href="#Generator.properties_sql-1095"><span class="linenos">1095</span></a> <span class="n">p_loc</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">PROPERTIES_LOCATION</span><span class="p">[</span><span class="n">p</span><span class="o">.</span><span class="vm">__class__</span><span class="p">]</span> -</span><span id="Generator.properties_sql-1096"><a href="#Generator.properties_sql-1096"><span class="linenos">1096</span></a> <span class="k">if</span> <span class="n">p_loc</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">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">:</span> -</span><span id="Generator.properties_sql-1097"><a href="#Generator.properties_sql-1097"><span class="linenos">1097</span></a> <span class="n">with_properties</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> -</span><span id="Generator.properties_sql-1098"><a href="#Generator.properties_sql-1098"><span class="linenos">1098</span></a> <span class="k">elif</span> <span class="n">p_loc</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">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">:</span> -</span><span id="Generator.properties_sql-1099"><a href="#Generator.properties_sql-1099"><span class="linenos">1099</span></a> <span class="n">root_properties</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> -</span><span id="Generator.properties_sql-1100"><a href="#Generator.properties_sql-1100"><span class="linenos">1100</span></a> -</span><span id="Generator.properties_sql-1101"><a href="#Generator.properties_sql-1101"><span class="linenos">1101</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">root_properties</span><span class="p">(</span> -</span><span id="Generator.properties_sql-1102"><a href="#Generator.properties_sql-1102"><span class="linenos">1102</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">root_properties</span><span class="p">)</span> -</span><span id="Generator.properties_sql-1103"><a href="#Generator.properties_sql-1103"><span class="linenos">1103</span></a> <span class="p">)</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">with_properties</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">with_properties</span><span class="p">))</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.properties_sql-1085"><a href="#Generator.properties_sql-1085"><span class="linenos">1085</span></a> <span class="k">def</span> <span class="nf">properties_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.properties_sql-1086"><a href="#Generator.properties_sql-1086"><span class="linenos">1086</span></a> <span class="n">root_properties</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="Generator.properties_sql-1087"><a href="#Generator.properties_sql-1087"><span class="linenos">1087</span></a> <span class="n">with_properties</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="Generator.properties_sql-1088"><a href="#Generator.properties_sql-1088"><span class="linenos">1088</span></a> +</span><span id="Generator.properties_sql-1089"><a href="#Generator.properties_sql-1089"><span class="linenos">1089</span></a> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> +</span><span id="Generator.properties_sql-1090"><a href="#Generator.properties_sql-1090"><span class="linenos">1090</span></a> <span class="n">p_loc</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">PROPERTIES_LOCATION</span><span class="p">[</span><span class="n">p</span><span class="o">.</span><span class="vm">__class__</span><span class="p">]</span> +</span><span id="Generator.properties_sql-1091"><a href="#Generator.properties_sql-1091"><span class="linenos">1091</span></a> <span class="k">if</span> <span class="n">p_loc</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">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">:</span> +</span><span id="Generator.properties_sql-1092"><a href="#Generator.properties_sql-1092"><span class="linenos">1092</span></a> <span class="n">with_properties</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> +</span><span id="Generator.properties_sql-1093"><a href="#Generator.properties_sql-1093"><span class="linenos">1093</span></a> <span class="k">elif</span> <span class="n">p_loc</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">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">:</span> +</span><span id="Generator.properties_sql-1094"><a href="#Generator.properties_sql-1094"><span class="linenos">1094</span></a> <span class="n">root_properties</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> +</span><span id="Generator.properties_sql-1095"><a href="#Generator.properties_sql-1095"><span class="linenos">1095</span></a> +</span><span id="Generator.properties_sql-1096"><a href="#Generator.properties_sql-1096"><span class="linenos">1096</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">root_properties</span><span class="p">(</span> +</span><span id="Generator.properties_sql-1097"><a href="#Generator.properties_sql-1097"><span class="linenos">1097</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">root_properties</span><span class="p">)</span> +</span><span id="Generator.properties_sql-1098"><a href="#Generator.properties_sql-1098"><span class="linenos">1098</span></a> <span class="p">)</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">with_properties</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">with_properties</span><span class="p">))</span> </span></pre></div> @@ -9682,10 +9764,10 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.root_properties"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.root_properties-1105"><a href="#Generator.root_properties-1105"><span class="linenos">1105</span></a> <span class="k">def</span> <span class="nf">root_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.root_properties-1106"><a href="#Generator.root_properties-1106"><span class="linenos">1106</span></a> <span class="k">if</span> <span class="n">properties</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> -</span><span id="Generator.root_properties-1107"><a href="#Generator.root_properties-1107"><span class="linenos">1107</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</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">properties</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="kc">False</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.root_properties-1108"><a href="#Generator.root_properties-1108"><span class="linenos">1108</span></a> <span class="k">return</span> <span class="s2">""</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.root_properties-1100"><a href="#Generator.root_properties-1100"><span class="linenos">1100</span></a> <span class="k">def</span> <span class="nf">root_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.root_properties-1101"><a href="#Generator.root_properties-1101"><span class="linenos">1101</span></a> <span class="k">if</span> <span class="n">properties</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> +</span><span id="Generator.root_properties-1102"><a href="#Generator.root_properties-1102"><span class="linenos">1102</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</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">properties</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="kc">False</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.root_properties-1103"><a href="#Generator.root_properties-1103"><span class="linenos">1103</span></a> <span class="k">return</span> <span class="s2">""</span> </span></pre></div> @@ -9703,20 +9785,20 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.properties"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.properties-1110"><a href="#Generator.properties-1110"><span class="linenos">1110</span></a> <span class="k">def</span> <span class="nf">properties</span><span class="p">(</span> -</span><span id="Generator.properties-1111"><a href="#Generator.properties-1111"><span class="linenos">1111</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Generator.properties-1112"><a href="#Generator.properties-1112"><span class="linenos">1112</span></a> <span class="n">properties</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.properties-1113"><a href="#Generator.properties-1113"><span class="linenos">1113</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.properties-1114"><a href="#Generator.properties-1114"><span class="linenos">1114</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.properties-1115"><a href="#Generator.properties-1115"><span class="linenos">1115</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.properties-1116"><a href="#Generator.properties-1116"><span class="linenos">1116</span></a> <span class="n">wrapped</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.properties-1117"><a href="#Generator.properties-1117"><span class="linenos">1117</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.properties-1118"><a href="#Generator.properties-1118"><span class="linenos">1118</span></a> <span class="k">if</span> <span class="n">properties</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> -</span><span id="Generator.properties-1119"><a href="#Generator.properties-1119"><span class="linenos">1119</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">properties</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="n">sep</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> -</span><span id="Generator.properties-1120"><a href="#Generator.properties-1120"><span class="linenos">1120</span></a> <span class="k">if</span> <span class="n">expressions</span><span class="p">:</span> -</span><span id="Generator.properties-1121"><a href="#Generator.properties-1121"><span class="linenos">1121</span></a> <span class="n">expressions</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">expressions</span><span class="p">)</span> <span class="k">if</span> <span class="n">wrapped</span> <span class="k">else</span> <span class="n">expressions</span> -</span><span id="Generator.properties-1122"><a href="#Generator.properties-1122"><span class="linenos">1122</span></a> <span class="k">return</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="s1">' '</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">prefix</span><span class="o">.</span><span class="n">strip</span><span class="p">()</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</span><span class="si">}{</span><span class="n">suffix</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.properties-1123"><a href="#Generator.properties-1123"><span class="linenos">1123</span></a> <span class="k">return</span> <span class="s2">""</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.properties-1105"><a href="#Generator.properties-1105"><span class="linenos">1105</span></a> <span class="k">def</span> <span class="nf">properties</span><span class="p">(</span> +</span><span id="Generator.properties-1106"><a href="#Generator.properties-1106"><span class="linenos">1106</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Generator.properties-1107"><a href="#Generator.properties-1107"><span class="linenos">1107</span></a> <span class="n">properties</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.properties-1108"><a href="#Generator.properties-1108"><span class="linenos">1108</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.properties-1109"><a href="#Generator.properties-1109"><span class="linenos">1109</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.properties-1110"><a href="#Generator.properties-1110"><span class="linenos">1110</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.properties-1111"><a href="#Generator.properties-1111"><span class="linenos">1111</span></a> <span class="n">wrapped</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.properties-1112"><a href="#Generator.properties-1112"><span class="linenos">1112</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.properties-1113"><a href="#Generator.properties-1113"><span class="linenos">1113</span></a> <span class="k">if</span> <span class="n">properties</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> +</span><span id="Generator.properties-1114"><a href="#Generator.properties-1114"><span class="linenos">1114</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">properties</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="n">sep</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</span><span id="Generator.properties-1115"><a href="#Generator.properties-1115"><span class="linenos">1115</span></a> <span class="k">if</span> <span class="n">expressions</span><span class="p">:</span> +</span><span id="Generator.properties-1116"><a href="#Generator.properties-1116"><span class="linenos">1116</span></a> <span class="n">expressions</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">expressions</span><span class="p">)</span> <span class="k">if</span> <span class="n">wrapped</span> <span class="k">else</span> <span class="n">expressions</span> +</span><span id="Generator.properties-1117"><a href="#Generator.properties-1117"><span class="linenos">1117</span></a> <span class="k">return</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="s1">' '</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">prefix</span><span class="o">.</span><span class="n">strip</span><span class="p">()</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</span><span class="si">}{</span><span class="n">suffix</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.properties-1118"><a href="#Generator.properties-1118"><span class="linenos">1118</span></a> <span class="k">return</span> <span class="s2">""</span> </span></pre></div> @@ -9734,8 +9816,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.with_properties"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.with_properties-1125"><a href="#Generator.with_properties-1125"><span class="linenos">1125</span></a> <span class="k">def</span> <span class="nf">with_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.with_properties-1126"><a href="#Generator.with_properties-1126"><span class="linenos">1126</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span><span class="n">properties</span><span class="p">,</span> <span class="n">prefix</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">"WITH"</span><span class="p">))</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.with_properties-1120"><a href="#Generator.with_properties-1120"><span class="linenos">1120</span></a> <span class="k">def</span> <span class="nf">with_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.with_properties-1121"><a href="#Generator.with_properties-1121"><span class="linenos">1121</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span><span class="n">properties</span><span class="p">,</span> <span class="n">prefix</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">"WITH"</span><span class="p">))</span> </span></pre></div> @@ -9753,16 +9835,16 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.locate_properties"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.locate_properties-1128"><a href="#Generator.locate_properties-1128"><span class="linenos">1128</span></a> <span class="k">def</span> <span class="nf">locate_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">DefaultDict</span><span class="p">:</span> -</span><span id="Generator.locate_properties-1129"><a href="#Generator.locate_properties-1129"><span class="linenos">1129</span></a> <span class="n">properties_locs</span> <span class="o">=</span> <span class="n">defaultdict</span><span class="p">(</span><span class="nb">list</span><span class="p">)</span> -</span><span id="Generator.locate_properties-1130"><a href="#Generator.locate_properties-1130"><span class="linenos">1130</span></a> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">properties</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> -</span><span id="Generator.locate_properties-1131"><a href="#Generator.locate_properties-1131"><span class="linenos">1131</span></a> <span class="n">p_loc</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">PROPERTIES_LOCATION</span><span class="p">[</span><span class="n">p</span><span class="o">.</span><span class="vm">__class__</span><span class="p">]</span> -</span><span id="Generator.locate_properties-1132"><a href="#Generator.locate_properties-1132"><span class="linenos">1132</span></a> <span class="k">if</span> <span class="n">p_loc</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">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span><span class="p">:</span> -</span><span id="Generator.locate_properties-1133"><a href="#Generator.locate_properties-1133"><span class="linenos">1133</span></a> <span class="n">properties_locs</span><span class="p">[</span><span class="n">p_loc</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> -</span><span id="Generator.locate_properties-1134"><a href="#Generator.locate_properties-1134"><span class="linenos">1134</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator.locate_properties-1135"><a href="#Generator.locate_properties-1135"><span class="linenos">1135</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">p</span><span class="o">.</span><span class="n">key</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="Generator.locate_properties-1136"><a href="#Generator.locate_properties-1136"><span class="linenos">1136</span></a> -</span><span id="Generator.locate_properties-1137"><a href="#Generator.locate_properties-1137"><span class="linenos">1137</span></a> <span class="k">return</span> <span class="n">properties_locs</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.locate_properties-1123"><a href="#Generator.locate_properties-1123"><span class="linenos">1123</span></a> <span class="k">def</span> <span class="nf">locate_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">DefaultDict</span><span class="p">:</span> +</span><span id="Generator.locate_properties-1124"><a href="#Generator.locate_properties-1124"><span class="linenos">1124</span></a> <span class="n">properties_locs</span> <span class="o">=</span> <span class="n">defaultdict</span><span class="p">(</span><span class="nb">list</span><span class="p">)</span> +</span><span id="Generator.locate_properties-1125"><a href="#Generator.locate_properties-1125"><span class="linenos">1125</span></a> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">properties</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> +</span><span id="Generator.locate_properties-1126"><a href="#Generator.locate_properties-1126"><span class="linenos">1126</span></a> <span class="n">p_loc</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">PROPERTIES_LOCATION</span><span class="p">[</span><span class="n">p</span><span class="o">.</span><span class="vm">__class__</span><span class="p">]</span> +</span><span id="Generator.locate_properties-1127"><a href="#Generator.locate_properties-1127"><span class="linenos">1127</span></a> <span class="k">if</span> <span class="n">p_loc</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">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span><span class="p">:</span> +</span><span id="Generator.locate_properties-1128"><a href="#Generator.locate_properties-1128"><span class="linenos">1128</span></a> <span class="n">properties_locs</span><span class="p">[</span><span class="n">p_loc</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> +</span><span id="Generator.locate_properties-1129"><a href="#Generator.locate_properties-1129"><span class="linenos">1129</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator.locate_properties-1130"><a href="#Generator.locate_properties-1130"><span class="linenos">1130</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">p</span><span class="o">.</span><span class="n">key</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="Generator.locate_properties-1131"><a href="#Generator.locate_properties-1131"><span class="linenos">1131</span></a> +</span><span id="Generator.locate_properties-1132"><a href="#Generator.locate_properties-1132"><span class="linenos">1132</span></a> <span class="k">return</span> <span class="n">properties_locs</span> </span></pre></div> @@ -9780,10 +9862,10 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.property_name"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.property_name-1139"><a href="#Generator.property_name-1139"><span class="linenos">1139</span></a> <span class="k">def</span> <span class="nf">property_name</span><span class="p">(</span><span class="bp">self</span><span 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="n">string_key</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.property_name-1140"><a href="#Generator.property_name-1140"><span class="linenos">1140</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">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Dot</span><span class="p">):</span> -</span><span id="Generator.property_name-1141"><a href="#Generator.property_name-1141"><span class="linenos">1141</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">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.property_name-1142"><a href="#Generator.property_name-1142"><span class="linenos">1142</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">name</span><span class="si">}</span><span class="s2">'"</span> <span class="k">if</span> <span class="n">string_key</span> <span class="k">else</span> <span class="n">expression</span><span class="o">.</span><span class="n">name</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.property_name-1134"><a href="#Generator.property_name-1134"><span class="linenos">1134</span></a> <span class="k">def</span> <span class="nf">property_name</span><span class="p">(</span><span class="bp">self</span><span 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="n">string_key</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.property_name-1135"><a href="#Generator.property_name-1135"><span class="linenos">1135</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">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Dot</span><span class="p">):</span> +</span><span id="Generator.property_name-1136"><a href="#Generator.property_name-1136"><span class="linenos">1136</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">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.property_name-1137"><a href="#Generator.property_name-1137"><span class="linenos">1137</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">name</span><span class="si">}</span><span class="s2">'"</span> <span class="k">if</span> <span class="n">string_key</span> <span class="k">else</span> <span class="n">expression</span><span class="o">.</span><span class="n">name</span> </span></pre></div> @@ -9801,16 +9883,16 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.property_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.property_sql-1144"><a href="#Generator.property_sql-1144"><span class="linenos">1144</span></a> <span class="k">def</span> <span class="nf">property_sql</span><span class="p">(</span><span class="bp">self</span><span 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.property_sql-1145"><a href="#Generator.property_sql-1145"><span class="linenos">1145</span></a> <span class="n">property_cls</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="vm">__class__</span> -</span><span id="Generator.property_sql-1146"><a href="#Generator.property_sql-1146"><span class="linenos">1146</span></a> <span class="k">if</span> <span class="n">property_cls</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Property</span><span class="p">:</span> -</span><span id="Generator.property_sql-1147"><a href="#Generator.property_sql-1147"><span class="linenos">1147</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">property_name</span><span class="p">(</span><span class="n">expression</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.property_sql-1148"><a href="#Generator.property_sql-1148"><span class="linenos">1148</span></a> -</span><span id="Generator.property_sql-1149"><a href="#Generator.property_sql-1149"><span class="linenos">1149</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">property_cls</span><span class="p">)</span> -</span><span id="Generator.property_sql-1150"><a href="#Generator.property_sql-1150"><span class="linenos">1150</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.property_sql-1151"><a href="#Generator.property_sql-1151"><span class="linenos">1151</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="n">key</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="Generator.property_sql-1152"><a href="#Generator.property_sql-1152"><span class="linenos">1152</span></a> -</span><span id="Generator.property_sql-1153"><a href="#Generator.property_sql-1153"><span class="linenos">1153</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.property_sql-1139"><a href="#Generator.property_sql-1139"><span class="linenos">1139</span></a> <span class="k">def</span> <span class="nf">property_sql</span><span class="p">(</span><span class="bp">self</span><span 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.property_sql-1140"><a href="#Generator.property_sql-1140"><span class="linenos">1140</span></a> <span class="n">property_cls</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="vm">__class__</span> +</span><span id="Generator.property_sql-1141"><a href="#Generator.property_sql-1141"><span class="linenos">1141</span></a> <span class="k">if</span> <span class="n">property_cls</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Property</span><span class="p">:</span> +</span><span id="Generator.property_sql-1142"><a href="#Generator.property_sql-1142"><span class="linenos">1142</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">property_name</span><span class="p">(</span><span class="n">expression</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.property_sql-1143"><a href="#Generator.property_sql-1143"><span class="linenos">1143</span></a> +</span><span id="Generator.property_sql-1144"><a href="#Generator.property_sql-1144"><span class="linenos">1144</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">property_cls</span><span class="p">)</span> +</span><span id="Generator.property_sql-1145"><a href="#Generator.property_sql-1145"><span class="linenos">1145</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.property_sql-1146"><a href="#Generator.property_sql-1146"><span class="linenos">1146</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="n">key</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="Generator.property_sql-1147"><a href="#Generator.property_sql-1147"><span class="linenos">1147</span></a> +</span><span id="Generator.property_sql-1148"><a href="#Generator.property_sql-1148"><span class="linenos">1148</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> @@ -9828,10 +9910,10 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.likeproperty_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.likeproperty_sql-1155"><a href="#Generator.likeproperty_sql-1155"><span class="linenos">1155</span></a> <span class="k">def</span> <span class="nf">likeproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">LikeProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.likeproperty_sql-1156"><a href="#Generator.likeproperty_sql-1156"><span class="linenos">1156</span></a> <span class="n">options</span> <span class="o">=</span> <span class="s2">" "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">e</span><span class="o">.</span><span class="n">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">e</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 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">expressions</span><span class="p">)</span> -</span><span id="Generator.likeproperty_sql-1157"><a href="#Generator.likeproperty_sql-1157"><span class="linenos">1157</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.likeproperty_sql-1158"><a href="#Generator.likeproperty_sql-1158"><span class="linenos">1158</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"LIKE </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">options</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.likeproperty_sql-1150"><a href="#Generator.likeproperty_sql-1150"><span class="linenos">1150</span></a> <span class="k">def</span> <span class="nf">likeproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">LikeProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.likeproperty_sql-1151"><a href="#Generator.likeproperty_sql-1151"><span class="linenos">1151</span></a> <span class="n">options</span> <span class="o">=</span> <span class="s2">" "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">e</span><span class="o">.</span><span class="n">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">e</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 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">expressions</span><span class="p">)</span> +</span><span id="Generator.likeproperty_sql-1152"><a href="#Generator.likeproperty_sql-1152"><span class="linenos">1152</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.likeproperty_sql-1153"><a href="#Generator.likeproperty_sql-1153"><span class="linenos">1153</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"LIKE </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">options</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -9849,10 +9931,10 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.fallbackproperty_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.fallbackproperty_sql-1160"><a href="#Generator.fallbackproperty_sql-1160"><span class="linenos">1160</span></a> <span class="k">def</span> <span class="nf">fallbackproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">FallbackProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.fallbackproperty_sql-1161"><a href="#Generator.fallbackproperty_sql-1161"><span class="linenos">1161</span></a> <span class="n">no</span> <span class="o">=</span> <span class="s2">"NO "</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">"no"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.fallbackproperty_sql-1162"><a href="#Generator.fallbackproperty_sql-1162"><span class="linenos">1162</span></a> <span class="n">protection</span> <span class="o">=</span> <span class="s2">" PROTECTION"</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">"protection"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.fallbackproperty_sql-1163"><a href="#Generator.fallbackproperty_sql-1163"><span class="linenos">1163</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">no</span><span class="si">}</span><span class="s2">FALLBACK</span><span class="si">{</span><span class="n">protection</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.fallbackproperty_sql-1155"><a href="#Generator.fallbackproperty_sql-1155"><span class="linenos">1155</span></a> <span class="k">def</span> <span class="nf">fallbackproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">FallbackProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.fallbackproperty_sql-1156"><a href="#Generator.fallbackproperty_sql-1156"><span class="linenos">1156</span></a> <span class="n">no</span> <span class="o">=</span> <span class="s2">"NO "</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">"no"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.fallbackproperty_sql-1157"><a href="#Generator.fallbackproperty_sql-1157"><span class="linenos">1157</span></a> <span class="n">protection</span> <span class="o">=</span> <span class="s2">" PROTECTION"</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">"protection"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.fallbackproperty_sql-1158"><a href="#Generator.fallbackproperty_sql-1158"><span class="linenos">1158</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">no</span><span class="si">}</span><span class="s2">FALLBACK</span><span class="si">{</span><span class="n">protection</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -9870,14 +9952,14 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.journalproperty_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.journalproperty_sql-1165"><a href="#Generator.journalproperty_sql-1165"><span class="linenos">1165</span></a> <span class="k">def</span> <span class="nf">journalproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">JournalProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.journalproperty_sql-1166"><a href="#Generator.journalproperty_sql-1166"><span class="linenos">1166</span></a> <span class="n">no</span> <span class="o">=</span> <span class="s2">"NO "</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">"no"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.journalproperty_sql-1167"><a href="#Generator.journalproperty_sql-1167"><span class="linenos">1167</span></a> <span class="n">local</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">"local"</span><span class="p">)</span> -</span><span id="Generator.journalproperty_sql-1168"><a href="#Generator.journalproperty_sql-1168"><span class="linenos">1168</span></a> <span class="n">local</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">local</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">local</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.journalproperty_sql-1169"><a href="#Generator.journalproperty_sql-1169"><span class="linenos">1169</span></a> <span class="n">dual</span> <span class="o">=</span> <span class="s2">"DUAL "</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">"dual"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.journalproperty_sql-1170"><a href="#Generator.journalproperty_sql-1170"><span class="linenos">1170</span></a> <span class="n">before</span> <span class="o">=</span> <span class="s2">"BEFORE "</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">"before"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.journalproperty_sql-1171"><a href="#Generator.journalproperty_sql-1171"><span class="linenos">1171</span></a> <span class="n">after</span> <span class="o">=</span> <span class="s2">"AFTER "</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">"after"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.journalproperty_sql-1172"><a href="#Generator.journalproperty_sql-1172"><span class="linenos">1172</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">no</span><span class="si">}{</span><span class="n">local</span><span class="si">}{</span><span class="n">dual</span><span class="si">}{</span><span class="n">before</span><span class="si">}{</span><span class="n">after</span><span class="si">}</span><span class="s2">JOURNAL"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.journalproperty_sql-1160"><a href="#Generator.journalproperty_sql-1160"><span class="linenos">1160</span></a> <span class="k">def</span> <span class="nf">journalproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">JournalProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.journalproperty_sql-1161"><a href="#Generator.journalproperty_sql-1161"><span class="linenos">1161</span></a> <span class="n">no</span> <span class="o">=</span> <span class="s2">"NO "</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">"no"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.journalproperty_sql-1162"><a href="#Generator.journalproperty_sql-1162"><span class="linenos">1162</span></a> <span class="n">local</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">"local"</span><span class="p">)</span> +</span><span id="Generator.journalproperty_sql-1163"><a href="#Generator.journalproperty_sql-1163"><span class="linenos">1163</span></a> <span class="n">local</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">local</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">local</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.journalproperty_sql-1164"><a href="#Generator.journalproperty_sql-1164"><span class="linenos">1164</span></a> <span class="n">dual</span> <span class="o">=</span> <span class="s2">"DUAL "</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">"dual"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.journalproperty_sql-1165"><a href="#Generator.journalproperty_sql-1165"><span class="linenos">1165</span></a> <span class="n">before</span> <span class="o">=</span> <span class="s2">"BEFORE "</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">"before"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.journalproperty_sql-1166"><a href="#Generator.journalproperty_sql-1166"><span class="linenos">1166</span></a> <span class="n">after</span> <span class="o">=</span> <span class="s2">"AFTER "</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">"after"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.journalproperty_sql-1167"><a href="#Generator.journalproperty_sql-1167"><span class="linenos">1167</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">no</span><span class="si">}{</span><span class="n">local</span><span class="si">}{</span><span class="n">dual</span><span class="si">}{</span><span class="n">before</span><span class="si">}{</span><span class="n">after</span><span class="si">}</span><span class="s2">JOURNAL"</span> </span></pre></div> @@ -9895,10 +9977,10 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.freespaceproperty_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.freespaceproperty_sql-1174"><a href="#Generator.freespaceproperty_sql-1174"><span class="linenos">1174</span></a> <span class="k">def</span> <span class="nf">freespaceproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">FreespaceProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.freespaceproperty_sql-1175"><a href="#Generator.freespaceproperty_sql-1175"><span class="linenos">1175</span></a> <span class="n">freespace</span> <span class="o">=</span> <span class="bp">self</span><span 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.freespaceproperty_sql-1176"><a href="#Generator.freespaceproperty_sql-1176"><span class="linenos">1176</span></a> <span class="n">percent</span> <span class="o">=</span> <span class="s2">" PERCENT"</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">"percent"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.freespaceproperty_sql-1177"><a href="#Generator.freespaceproperty_sql-1177"><span class="linenos">1177</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"FREESPACE=</span><span class="si">{</span><span class="n">freespace</span><span class="si">}{</span><span class="n">percent</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.freespaceproperty_sql-1169"><a href="#Generator.freespaceproperty_sql-1169"><span class="linenos">1169</span></a> <span class="k">def</span> <span class="nf">freespaceproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">FreespaceProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.freespaceproperty_sql-1170"><a href="#Generator.freespaceproperty_sql-1170"><span class="linenos">1170</span></a> <span class="n">freespace</span> <span class="o">=</span> <span class="bp">self</span><span 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.freespaceproperty_sql-1171"><a href="#Generator.freespaceproperty_sql-1171"><span class="linenos">1171</span></a> <span class="n">percent</span> <span class="o">=</span> <span class="s2">" PERCENT"</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">"percent"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.freespaceproperty_sql-1172"><a href="#Generator.freespaceproperty_sql-1172"><span class="linenos">1172</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"FREESPACE=</span><span class="si">{</span><span class="n">freespace</span><span class="si">}{</span><span class="n">percent</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -9916,14 +9998,14 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.checksumproperty_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.checksumproperty_sql-1179"><a href="#Generator.checksumproperty_sql-1179"><span class="linenos">1179</span></a> <span class="k">def</span> <span class="nf">checksumproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ChecksumProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.checksumproperty_sql-1180"><a href="#Generator.checksumproperty_sql-1180"><span class="linenos">1180</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">"default"</span><span class="p">):</span> -</span><span id="Generator.checksumproperty_sql-1181"><a href="#Generator.checksumproperty_sql-1181"><span class="linenos">1181</span></a> <span class="nb">property</span> <span class="o">=</span> <span class="s2">"DEFAULT"</span> -</span><span id="Generator.checksumproperty_sql-1182"><a href="#Generator.checksumproperty_sql-1182"><span class="linenos">1182</span></a> <span class="k">elif</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">"on"</span><span class="p">):</span> -</span><span id="Generator.checksumproperty_sql-1183"><a href="#Generator.checksumproperty_sql-1183"><span class="linenos">1183</span></a> <span class="nb">property</span> <span class="o">=</span> <span class="s2">"ON"</span> -</span><span id="Generator.checksumproperty_sql-1184"><a href="#Generator.checksumproperty_sql-1184"><span class="linenos">1184</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator.checksumproperty_sql-1185"><a href="#Generator.checksumproperty_sql-1185"><span class="linenos">1185</span></a> <span class="nb">property</span> <span class="o">=</span> <span class="s2">"OFF"</span> -</span><span id="Generator.checksumproperty_sql-1186"><a href="#Generator.checksumproperty_sql-1186"><span class="linenos">1186</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CHECKSUM=</span><span class="si">{</span><span class="nb">property</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.checksumproperty_sql-1174"><a href="#Generator.checksumproperty_sql-1174"><span class="linenos">1174</span></a> <span class="k">def</span> <span class="nf">checksumproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ChecksumProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.checksumproperty_sql-1175"><a href="#Generator.checksumproperty_sql-1175"><span class="linenos">1175</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">"default"</span><span class="p">):</span> +</span><span id="Generator.checksumproperty_sql-1176"><a href="#Generator.checksumproperty_sql-1176"><span class="linenos">1176</span></a> <span class="nb">property</span> <span class="o">=</span> <span class="s2">"DEFAULT"</span> +</span><span id="Generator.checksumproperty_sql-1177"><a href="#Generator.checksumproperty_sql-1177"><span class="linenos">1177</span></a> <span class="k">elif</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">"on"</span><span class="p">):</span> +</span><span id="Generator.checksumproperty_sql-1178"><a href="#Generator.checksumproperty_sql-1178"><span class="linenos">1178</span></a> <span class="nb">property</span> <span class="o">=</span> <span class="s2">"ON"</span> +</span><span id="Generator.checksumproperty_sql-1179"><a href="#Generator.checksumproperty_sql-1179"><span class="linenos">1179</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator.checksumproperty_sql-1180"><a href="#Generator.checksumproperty_sql-1180"><span class="linenos">1180</span></a> <span class="nb">property</span> <span class="o">=</span> <span class="s2">"OFF"</span> +</span><span id="Generator.checksumproperty_sql-1181"><a href="#Generator.checksumproperty_sql-1181"><span class="linenos">1181</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CHECKSUM=</span><span class="si">{</span><span class="nb">property</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -9941,14 +10023,14 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.mergeblockratioproperty_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.mergeblockratioproperty_sql-1188"><a href="#Generator.mergeblockratioproperty_sql-1188"><span class="linenos">1188</span></a> <span class="k">def</span> <span class="nf">mergeblockratioproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">MergeBlockRatioProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.mergeblockratioproperty_sql-1189"><a href="#Generator.mergeblockratioproperty_sql-1189"><span class="linenos">1189</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">"no"</span><span class="p">):</span> -</span><span id="Generator.mergeblockratioproperty_sql-1190"><a href="#Generator.mergeblockratioproperty_sql-1190"><span class="linenos">1190</span></a> <span class="k">return</span> <span class="s2">"NO MERGEBLOCKRATIO"</span> -</span><span id="Generator.mergeblockratioproperty_sql-1191"><a href="#Generator.mergeblockratioproperty_sql-1191"><span class="linenos">1191</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">"default"</span><span class="p">):</span> -</span><span id="Generator.mergeblockratioproperty_sql-1192"><a href="#Generator.mergeblockratioproperty_sql-1192"><span class="linenos">1192</span></a> <span class="k">return</span> <span class="s2">"DEFAULT MERGEBLOCKRATIO"</span> -</span><span id="Generator.mergeblockratioproperty_sql-1193"><a href="#Generator.mergeblockratioproperty_sql-1193"><span class="linenos">1193</span></a> -</span><span id="Generator.mergeblockratioproperty_sql-1194"><a href="#Generator.mergeblockratioproperty_sql-1194"><span class="linenos">1194</span></a> <span class="n">percent</span> <span class="o">=</span> <span class="s2">" PERCENT"</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">"percent"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.mergeblockratioproperty_sql-1195"><a href="#Generator.mergeblockratioproperty_sql-1195"><span class="linenos">1195</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"MERGEBLOCKRATIO=</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">percent</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.mergeblockratioproperty_sql-1183"><a href="#Generator.mergeblockratioproperty_sql-1183"><span class="linenos">1183</span></a> <span class="k">def</span> <span class="nf">mergeblockratioproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">MergeBlockRatioProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.mergeblockratioproperty_sql-1184"><a href="#Generator.mergeblockratioproperty_sql-1184"><span class="linenos">1184</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">"no"</span><span class="p">):</span> +</span><span id="Generator.mergeblockratioproperty_sql-1185"><a href="#Generator.mergeblockratioproperty_sql-1185"><span class="linenos">1185</span></a> <span class="k">return</span> <span class="s2">"NO MERGEBLOCKRATIO"</span> +</span><span id="Generator.mergeblockratioproperty_sql-1186"><a href="#Generator.mergeblockratioproperty_sql-1186"><span class="linenos">1186</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">"default"</span><span class="p">):</span> +</span><span id="Generator.mergeblockratioproperty_sql-1187"><a href="#Generator.mergeblockratioproperty_sql-1187"><span class="linenos">1187</span></a> <span class="k">return</span> <span class="s2">"DEFAULT MERGEBLOCKRATIO"</span> +</span><span id="Generator.mergeblockratioproperty_sql-1188"><a href="#Generator.mergeblockratioproperty_sql-1188"><span class="linenos">1188</span></a> +</span><span id="Generator.mergeblockratioproperty_sql-1189"><a href="#Generator.mergeblockratioproperty_sql-1189"><span class="linenos">1189</span></a> <span class="n">percent</span> <span class="o">=</span> <span class="s2">" PERCENT"</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">"percent"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.mergeblockratioproperty_sql-1190"><a href="#Generator.mergeblockratioproperty_sql-1190"><span class="linenos">1190</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"MERGEBLOCKRATIO=</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">percent</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -9966,21 +10048,21 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.datablocksizeproperty_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.datablocksizeproperty_sql-1197"><a href="#Generator.datablocksizeproperty_sql-1197"><span class="linenos">1197</span></a> <span class="k">def</span> <span class="nf">datablocksizeproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataBlocksizeProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.datablocksizeproperty_sql-1198"><a href="#Generator.datablocksizeproperty_sql-1198"><span class="linenos">1198</span></a> <span class="n">default</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">"default"</span><span class="p">)</span> -</span><span id="Generator.datablocksizeproperty_sql-1199"><a href="#Generator.datablocksizeproperty_sql-1199"><span class="linenos">1199</span></a> <span class="n">minimum</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">"minimum"</span><span class="p">)</span> -</span><span id="Generator.datablocksizeproperty_sql-1200"><a href="#Generator.datablocksizeproperty_sql-1200"><span class="linenos">1200</span></a> <span class="n">maximum</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">"maximum"</span><span class="p">)</span> -</span><span id="Generator.datablocksizeproperty_sql-1201"><a href="#Generator.datablocksizeproperty_sql-1201"><span class="linenos">1201</span></a> <span class="k">if</span> <span class="n">default</span> <span class="ow">or</span> <span class="n">minimum</span> <span class="ow">or</span> <span class="n">maximum</span><span class="p">:</span> -</span><span id="Generator.datablocksizeproperty_sql-1202"><a href="#Generator.datablocksizeproperty_sql-1202"><span class="linenos">1202</span></a> <span class="k">if</span> <span class="n">default</span><span class="p">:</span> -</span><span id="Generator.datablocksizeproperty_sql-1203"><a href="#Generator.datablocksizeproperty_sql-1203"><span class="linenos">1203</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"DEFAULT"</span> -</span><span id="Generator.datablocksizeproperty_sql-1204"><a href="#Generator.datablocksizeproperty_sql-1204"><span class="linenos">1204</span></a> <span class="k">elif</span> <span class="n">minimum</span><span class="p">:</span> -</span><span id="Generator.datablocksizeproperty_sql-1205"><a href="#Generator.datablocksizeproperty_sql-1205"><span class="linenos">1205</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"MINIMUM"</span> -</span><span id="Generator.datablocksizeproperty_sql-1206"><a href="#Generator.datablocksizeproperty_sql-1206"><span class="linenos">1206</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator.datablocksizeproperty_sql-1207"><a href="#Generator.datablocksizeproperty_sql-1207"><span class="linenos">1207</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"MAXIMUM"</span> -</span><span id="Generator.datablocksizeproperty_sql-1208"><a href="#Generator.datablocksizeproperty_sql-1208"><span class="linenos">1208</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">prop</span><span class="si">}</span><span class="s2"> DATABLOCKSIZE"</span> -</span><span id="Generator.datablocksizeproperty_sql-1209"><a href="#Generator.datablocksizeproperty_sql-1209"><span class="linenos">1209</span></a> <span class="n">units</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">"units"</span><span class="p">)</span> -</span><span id="Generator.datablocksizeproperty_sql-1210"><a href="#Generator.datablocksizeproperty_sql-1210"><span class="linenos">1210</span></a> <span class="n">units</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">units</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">units</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.datablocksizeproperty_sql-1211"><a href="#Generator.datablocksizeproperty_sql-1211"><span class="linenos">1211</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"DATABLOCKSIZE=</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">'size'</span><span class="p">)</span><span class="si">}{</span><span class="n">units</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.datablocksizeproperty_sql-1192"><a href="#Generator.datablocksizeproperty_sql-1192"><span class="linenos">1192</span></a> <span class="k">def</span> <span class="nf">datablocksizeproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataBlocksizeProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.datablocksizeproperty_sql-1193"><a href="#Generator.datablocksizeproperty_sql-1193"><span class="linenos">1193</span></a> <span class="n">default</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">"default"</span><span class="p">)</span> +</span><span id="Generator.datablocksizeproperty_sql-1194"><a href="#Generator.datablocksizeproperty_sql-1194"><span class="linenos">1194</span></a> <span class="n">minimum</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">"minimum"</span><span class="p">)</span> +</span><span id="Generator.datablocksizeproperty_sql-1195"><a href="#Generator.datablocksizeproperty_sql-1195"><span class="linenos">1195</span></a> <span class="n">maximum</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">"maximum"</span><span class="p">)</span> +</span><span id="Generator.datablocksizeproperty_sql-1196"><a href="#Generator.datablocksizeproperty_sql-1196"><span class="linenos">1196</span></a> <span class="k">if</span> <span class="n">default</span> <span class="ow">or</span> <span class="n">minimum</span> <span class="ow">or</span> <span class="n">maximum</span><span class="p">:</span> +</span><span id="Generator.datablocksizeproperty_sql-1197"><a href="#Generator.datablocksizeproperty_sql-1197"><span class="linenos">1197</span></a> <span class="k">if</span> <span class="n">default</span><span class="p">:</span> +</span><span id="Generator.datablocksizeproperty_sql-1198"><a href="#Generator.datablocksizeproperty_sql-1198"><span class="linenos">1198</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"DEFAULT"</span> +</span><span id="Generator.datablocksizeproperty_sql-1199"><a href="#Generator.datablocksizeproperty_sql-1199"><span class="linenos">1199</span></a> <span class="k">elif</span> <span class="n">minimum</span><span class="p">:</span> +</span><span id="Generator.datablocksizeproperty_sql-1200"><a href="#Generator.datablocksizeproperty_sql-1200"><span class="linenos">1200</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"MINIMUM"</span> +</span><span id="Generator.datablocksizeproperty_sql-1201"><a href="#Generator.datablocksizeproperty_sql-1201"><span class="linenos">1201</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator.datablocksizeproperty_sql-1202"><a href="#Generator.datablocksizeproperty_sql-1202"><span class="linenos">1202</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"MAXIMUM"</span> +</span><span id="Generator.datablocksizeproperty_sql-1203"><a href="#Generator.datablocksizeproperty_sql-1203"><span class="linenos">1203</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">prop</span><span class="si">}</span><span class="s2"> DATABLOCKSIZE"</span> +</span><span id="Generator.datablocksizeproperty_sql-1204"><a href="#Generator.datablocksizeproperty_sql-1204"><span class="linenos">1204</span></a> <span class="n">units</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">"units"</span><span class="p">)</span> +</span><span id="Generator.datablocksizeproperty_sql-1205"><a href="#Generator.datablocksizeproperty_sql-1205"><span class="linenos">1205</span></a> <span class="n">units</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">units</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">units</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.datablocksizeproperty_sql-1206"><a href="#Generator.datablocksizeproperty_sql-1206"><span class="linenos">1206</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"DATABLOCKSIZE=</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">'size'</span><span class="p">)</span><span class="si">}{</span><span class="n">units</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -9998,24 +10080,24 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.blockcompressionproperty_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.blockcompressionproperty_sql-1213"><a href="#Generator.blockcompressionproperty_sql-1213"><span class="linenos">1213</span></a> <span class="k">def</span> <span class="nf">blockcompressionproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">BlockCompressionProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.blockcompressionproperty_sql-1214"><a href="#Generator.blockcompressionproperty_sql-1214"><span class="linenos">1214</span></a> <span class="n">autotemp</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">"autotemp"</span><span class="p">)</span> -</span><span id="Generator.blockcompressionproperty_sql-1215"><a href="#Generator.blockcompressionproperty_sql-1215"><span class="linenos">1215</span></a> <span class="n">always</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">"always"</span><span class="p">)</span> -</span><span id="Generator.blockcompressionproperty_sql-1216"><a href="#Generator.blockcompressionproperty_sql-1216"><span class="linenos">1216</span></a> <span class="n">default</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">"default"</span><span class="p">)</span> -</span><span id="Generator.blockcompressionproperty_sql-1217"><a href="#Generator.blockcompressionproperty_sql-1217"><span class="linenos">1217</span></a> <span class="n">manual</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">"manual"</span><span class="p">)</span> -</span><span id="Generator.blockcompressionproperty_sql-1218"><a href="#Generator.blockcompressionproperty_sql-1218"><span class="linenos">1218</span></a> <span class="n">never</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">"never"</span><span class="p">)</span> -</span><span id="Generator.blockcompressionproperty_sql-1219"><a href="#Generator.blockcompressionproperty_sql-1219"><span class="linenos">1219</span></a> -</span><span id="Generator.blockcompressionproperty_sql-1220"><a href="#Generator.blockcompressionproperty_sql-1220"><span class="linenos">1220</span></a> <span class="k">if</span> <span class="n">autotemp</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Generator.blockcompressionproperty_sql-1221"><a href="#Generator.blockcompressionproperty_sql-1221"><span class="linenos">1221</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"AUTOTEMP(</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">autotemp</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="Generator.blockcompressionproperty_sql-1222"><a href="#Generator.blockcompressionproperty_sql-1222"><span class="linenos">1222</span></a> <span class="k">elif</span> <span class="n">always</span><span class="p">:</span> -</span><span id="Generator.blockcompressionproperty_sql-1223"><a href="#Generator.blockcompressionproperty_sql-1223"><span class="linenos">1223</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"ALWAYS"</span> -</span><span id="Generator.blockcompressionproperty_sql-1224"><a href="#Generator.blockcompressionproperty_sql-1224"><span class="linenos">1224</span></a> <span class="k">elif</span> <span class="n">default</span><span class="p">:</span> -</span><span id="Generator.blockcompressionproperty_sql-1225"><a href="#Generator.blockcompressionproperty_sql-1225"><span class="linenos">1225</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"DEFAULT"</span> -</span><span id="Generator.blockcompressionproperty_sql-1226"><a href="#Generator.blockcompressionproperty_sql-1226"><span class="linenos">1226</span></a> <span class="k">elif</span> <span class="n">manual</span><span class="p">:</span> -</span><span id="Generator.blockcompressionproperty_sql-1227"><a href="#Generator.blockcompressionproperty_sql-1227"><span class="linenos">1227</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"MANUAL"</span> -</span><span id="Generator.blockcompressionproperty_sql-1228"><a href="#Generator.blockcompressionproperty_sql-1228"><span class="linenos">1228</span></a> <span class="k">elif</span> <span class="n">never</span><span class="p">:</span> -</span><span id="Generator.blockcompressionproperty_sql-1229"><a href="#Generator.blockcompressionproperty_sql-1229"><span class="linenos">1229</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"NEVER"</span> -</span><span id="Generator.blockcompressionproperty_sql-1230"><a href="#Generator.blockcompressionproperty_sql-1230"><span class="linenos">1230</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"BLOCKCOMPRESSION=</span><span class="si">{</span><span class="n">prop</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.blockcompressionproperty_sql-1208"><a href="#Generator.blockcompressionproperty_sql-1208"><span class="linenos">1208</span></a> <span class="k">def</span> <span class="nf">blockcompressionproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">BlockCompressionProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.blockcompressionproperty_sql-1209"><a href="#Generator.blockcompressionproperty_sql-1209"><span class="linenos">1209</span></a> <span class="n">autotemp</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">"autotemp"</span><span class="p">)</span> +</span><span id="Generator.blockcompressionproperty_sql-1210"><a href="#Generator.blockcompressionproperty_sql-1210"><span class="linenos">1210</span></a> <span class="n">always</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">"always"</span><span class="p">)</span> +</span><span id="Generator.blockcompressionproperty_sql-1211"><a href="#Generator.blockcompressionproperty_sql-1211"><span class="linenos">1211</span></a> <span class="n">default</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">"default"</span><span class="p">)</span> +</span><span id="Generator.blockcompressionproperty_sql-1212"><a href="#Generator.blockcompressionproperty_sql-1212"><span class="linenos">1212</span></a> <span class="n">manual</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">"manual"</span><span class="p">)</span> +</span><span id="Generator.blockcompressionproperty_sql-1213"><a href="#Generator.blockcompressionproperty_sql-1213"><span class="linenos">1213</span></a> <span class="n">never</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">"never"</span><span class="p">)</span> +</span><span id="Generator.blockcompressionproperty_sql-1214"><a href="#Generator.blockcompressionproperty_sql-1214"><span class="linenos">1214</span></a> +</span><span id="Generator.blockcompressionproperty_sql-1215"><a href="#Generator.blockcompressionproperty_sql-1215"><span class="linenos">1215</span></a> <span class="k">if</span> <span class="n">autotemp</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Generator.blockcompressionproperty_sql-1216"><a href="#Generator.blockcompressionproperty_sql-1216"><span class="linenos">1216</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"AUTOTEMP(</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">autotemp</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Generator.blockcompressionproperty_sql-1217"><a href="#Generator.blockcompressionproperty_sql-1217"><span class="linenos">1217</span></a> <span class="k">elif</span> <span class="n">always</span><span class="p">:</span> +</span><span id="Generator.blockcompressionproperty_sql-1218"><a href="#Generator.blockcompressionproperty_sql-1218"><span class="linenos">1218</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"ALWAYS"</span> +</span><span id="Generator.blockcompressionproperty_sql-1219"><a href="#Generator.blockcompressionproperty_sql-1219"><span class="linenos">1219</span></a> <span class="k">elif</span> <span class="n">default</span><span class="p">:</span> +</span><span id="Generator.blockcompressionproperty_sql-1220"><a href="#Generator.blockcompressionproperty_sql-1220"><span class="linenos">1220</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"DEFAULT"</span> +</span><span id="Generator.blockcompressionproperty_sql-1221"><a href="#Generator.blockcompressionproperty_sql-1221"><span class="linenos">1221</span></a> <span class="k">elif</span> <span class="n">manual</span><span class="p">:</span> +</span><span id="Generator.blockcompressionproperty_sql-1222"><a href="#Generator.blockcompressionproperty_sql-1222"><span class="linenos">1222</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"MANUAL"</span> +</span><span id="Generator.blockcompressionproperty_sql-1223"><a href="#Generator.blockcompressionproperty_sql-1223"><span class="linenos">1223</span></a> <span class="k">elif</span> <span class="n">never</span><span class="p">:</span> +</span><span id="Generator.blockcompressionproperty_sql-1224"><a href="#Generator.blockcompressionproperty_sql-1224"><span class="linenos">1224</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"NEVER"</span> +</span><span id="Generator.blockcompressionproperty_sql-1225"><a href="#Generator.blockcompressionproperty_sql-1225"><span class="linenos">1225</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"BLOCKCOMPRESSION=</span><span class="si">{</span><span class="n">prop</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -10033,20 +10115,20 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.isolatedloadingproperty_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.isolatedloadingproperty_sql-1232"><a href="#Generator.isolatedloadingproperty_sql-1232"><span class="linenos">1232</span></a> <span class="k">def</span> <span class="nf">isolatedloadingproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">IsolatedLoadingProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.isolatedloadingproperty_sql-1233"><a href="#Generator.isolatedloadingproperty_sql-1233"><span class="linenos">1233</span></a> <span class="n">no</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">"no"</span><span class="p">)</span> -</span><span id="Generator.isolatedloadingproperty_sql-1234"><a href="#Generator.isolatedloadingproperty_sql-1234"><span class="linenos">1234</span></a> <span class="n">no</span> <span class="o">=</span> <span class="s2">" NO"</span> <span class="k">if</span> <span class="n">no</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.isolatedloadingproperty_sql-1235"><a href="#Generator.isolatedloadingproperty_sql-1235"><span class="linenos">1235</span></a> <span class="n">concurrent</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">"concurrent"</span><span class="p">)</span> -</span><span id="Generator.isolatedloadingproperty_sql-1236"><a href="#Generator.isolatedloadingproperty_sql-1236"><span class="linenos">1236</span></a> <span class="n">concurrent</span> <span class="o">=</span> <span class="s2">" CONCURRENT"</span> <span class="k">if</span> <span class="n">concurrent</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.isolatedloadingproperty_sql-1237"><a href="#Generator.isolatedloadingproperty_sql-1237"><span class="linenos">1237</span></a> -</span><span id="Generator.isolatedloadingproperty_sql-1238"><a href="#Generator.isolatedloadingproperty_sql-1238"><span class="linenos">1238</span></a> <span class="n">for_</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator.isolatedloadingproperty_sql-1239"><a href="#Generator.isolatedloadingproperty_sql-1239"><span class="linenos">1239</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">"for_all"</span><span class="p">):</span> -</span><span id="Generator.isolatedloadingproperty_sql-1240"><a href="#Generator.isolatedloadingproperty_sql-1240"><span class="linenos">1240</span></a> <span class="n">for_</span> <span class="o">=</span> <span class="s2">" FOR ALL"</span> -</span><span id="Generator.isolatedloadingproperty_sql-1241"><a href="#Generator.isolatedloadingproperty_sql-1241"><span class="linenos">1241</span></a> <span class="k">elif</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">"for_insert"</span><span class="p">):</span> -</span><span id="Generator.isolatedloadingproperty_sql-1242"><a href="#Generator.isolatedloadingproperty_sql-1242"><span class="linenos">1242</span></a> <span class="n">for_</span> <span class="o">=</span> <span class="s2">" FOR INSERT"</span> -</span><span id="Generator.isolatedloadingproperty_sql-1243"><a href="#Generator.isolatedloadingproperty_sql-1243"><span class="linenos">1243</span></a> <span class="k">elif</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">"for_none"</span><span class="p">):</span> -</span><span id="Generator.isolatedloadingproperty_sql-1244"><a href="#Generator.isolatedloadingproperty_sql-1244"><span class="linenos">1244</span></a> <span class="n">for_</span> <span class="o">=</span> <span class="s2">" FOR NONE"</span> -</span><span id="Generator.isolatedloadingproperty_sql-1245"><a href="#Generator.isolatedloadingproperty_sql-1245"><span class="linenos">1245</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"WITH</span><span class="si">{</span><span class="n">no</span><span class="si">}{</span><span class="n">concurrent</span><span class="si">}</span><span class="s2"> ISOLATED LOADING</span><span class="si">{</span><span class="n">for_</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.isolatedloadingproperty_sql-1227"><a href="#Generator.isolatedloadingproperty_sql-1227"><span class="linenos">1227</span></a> <span class="k">def</span> <span class="nf">isolatedloadingproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">IsolatedLoadingProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.isolatedloadingproperty_sql-1228"><a href="#Generator.isolatedloadingproperty_sql-1228"><span class="linenos">1228</span></a> <span class="n">no</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">"no"</span><span class="p">)</span> +</span><span id="Generator.isolatedloadingproperty_sql-1229"><a href="#Generator.isolatedloadingproperty_sql-1229"><span class="linenos">1229</span></a> <span class="n">no</span> <span class="o">=</span> <span class="s2">" NO"</span> <span class="k">if</span> <span class="n">no</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.isolatedloadingproperty_sql-1230"><a href="#Generator.isolatedloadingproperty_sql-1230"><span class="linenos">1230</span></a> <span class="n">concurrent</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">"concurrent"</span><span class="p">)</span> +</span><span id="Generator.isolatedloadingproperty_sql-1231"><a href="#Generator.isolatedloadingproperty_sql-1231"><span class="linenos">1231</span></a> <span class="n">concurrent</span> <span class="o">=</span> <span class="s2">" CONCURRENT"</span> <span class="k">if</span> <span class="n">concurrent</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.isolatedloadingproperty_sql-1232"><a href="#Generator.isolatedloadingproperty_sql-1232"><span class="linenos">1232</span></a> +</span><span id="Generator.isolatedloadingproperty_sql-1233"><a href="#Generator.isolatedloadingproperty_sql-1233"><span class="linenos">1233</span></a> <span class="n">for_</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator.isolatedloadingproperty_sql-1234"><a href="#Generator.isolatedloadingproperty_sql-1234"><span class="linenos">1234</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">"for_all"</span><span class="p">):</span> +</span><span id="Generator.isolatedloadingproperty_sql-1235"><a href="#Generator.isolatedloadingproperty_sql-1235"><span class="linenos">1235</span></a> <span class="n">for_</span> <span class="o">=</span> <span class="s2">" FOR ALL"</span> +</span><span id="Generator.isolatedloadingproperty_sql-1236"><a href="#Generator.isolatedloadingproperty_sql-1236"><span class="linenos">1236</span></a> <span class="k">elif</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">"for_insert"</span><span class="p">):</span> +</span><span id="Generator.isolatedloadingproperty_sql-1237"><a href="#Generator.isolatedloadingproperty_sql-1237"><span class="linenos">1237</span></a> <span class="n">for_</span> <span class="o">=</span> <span class="s2">" FOR INSERT"</span> +</span><span id="Generator.isolatedloadingproperty_sql-1238"><a href="#Generator.isolatedloadingproperty_sql-1238"><span class="linenos">1238</span></a> <span class="k">elif</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">"for_none"</span><span class="p">):</span> +</span><span id="Generator.isolatedloadingproperty_sql-1239"><a href="#Generator.isolatedloadingproperty_sql-1239"><span class="linenos">1239</span></a> <span class="n">for_</span> <span class="o">=</span> <span class="s2">" FOR NONE"</span> +</span><span id="Generator.isolatedloadingproperty_sql-1240"><a href="#Generator.isolatedloadingproperty_sql-1240"><span class="linenos">1240</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"WITH</span><span class="si">{</span><span class="n">no</span><span class="si">}{</span><span class="n">concurrent</span><span class="si">}</span><span class="s2"> ISOLATED LOADING</span><span class="si">{</span><span class="n">for_</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -10064,17 +10146,17 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.partitionboundspec_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.partitionboundspec_sql-1247"><a href="#Generator.partitionboundspec_sql-1247"><span class="linenos">1247</span></a> <span class="k">def</span> <span class="nf">partitionboundspec_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionBoundSpec</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.partitionboundspec_sql-1248"><a href="#Generator.partitionboundspec_sql-1248"><span class="linenos">1248</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">this</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span> -</span><span id="Generator.partitionboundspec_sql-1249"><a href="#Generator.partitionboundspec_sql-1249"><span class="linenos">1249</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"IN (</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">'this'</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.partitionboundspec_sql-1250"><a href="#Generator.partitionboundspec_sql-1250"><span class="linenos">1250</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">:</span> -</span><span id="Generator.partitionboundspec_sql-1251"><a href="#Generator.partitionboundspec_sql-1251"><span class="linenos">1251</span></a> <span class="n">modulus</span> <span class="o">=</span> <span class="bp">self</span><span 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.partitionboundspec_sql-1252"><a href="#Generator.partitionboundspec_sql-1252"><span class="linenos">1252</span></a> <span class="n">remainder</span> <span class="o">=</span> <span class="bp">self</span><span 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.partitionboundspec_sql-1253"><a href="#Generator.partitionboundspec_sql-1253"><span class="linenos">1253</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"WITH (MODULUS </span><span class="si">{</span><span class="n">modulus</span><span class="si">}</span><span class="s2">, REMAINDER </span><span class="si">{</span><span class="n">remainder</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="Generator.partitionboundspec_sql-1254"><a href="#Generator.partitionboundspec_sql-1254"><span class="linenos">1254</span></a> -</span><span id="Generator.partitionboundspec_sql-1255"><a href="#Generator.partitionboundspec_sql-1255"><span class="linenos">1255</span></a> <span class="n">from_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">"from_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.partitionboundspec_sql-1256"><a href="#Generator.partitionboundspec_sql-1256"><span class="linenos">1256</span></a> <span class="n">to_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">"to_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.partitionboundspec_sql-1257"><a href="#Generator.partitionboundspec_sql-1257"><span class="linenos">1257</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"FROM (</span><span class="si">{</span><span class="n">from_expressions</span><span class="si">}</span><span class="s2">) TO (</span><span class="si">{</span><span class="n">to_expressions</span><span class="si">}</span><span class="s2">)"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.partitionboundspec_sql-1242"><a href="#Generator.partitionboundspec_sql-1242"><span class="linenos">1242</span></a> <span class="k">def</span> <span class="nf">partitionboundspec_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionBoundSpec</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.partitionboundspec_sql-1243"><a href="#Generator.partitionboundspec_sql-1243"><span class="linenos">1243</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">this</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span> +</span><span id="Generator.partitionboundspec_sql-1244"><a href="#Generator.partitionboundspec_sql-1244"><span class="linenos">1244</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"IN (</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">'this'</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.partitionboundspec_sql-1245"><a href="#Generator.partitionboundspec_sql-1245"><span class="linenos">1245</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">:</span> +</span><span id="Generator.partitionboundspec_sql-1246"><a href="#Generator.partitionboundspec_sql-1246"><span class="linenos">1246</span></a> <span class="n">modulus</span> <span class="o">=</span> <span class="bp">self</span><span 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.partitionboundspec_sql-1247"><a href="#Generator.partitionboundspec_sql-1247"><span class="linenos">1247</span></a> <span class="n">remainder</span> <span class="o">=</span> <span class="bp">self</span><span 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.partitionboundspec_sql-1248"><a href="#Generator.partitionboundspec_sql-1248"><span class="linenos">1248</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"WITH (MODULUS </span><span class="si">{</span><span class="n">modulus</span><span class="si">}</span><span class="s2">, REMAINDER </span><span class="si">{</span><span class="n">remainder</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Generator.partitionboundspec_sql-1249"><a href="#Generator.partitionboundspec_sql-1249"><span class="linenos">1249</span></a> +</span><span id="Generator.partitionboundspec_sql-1250"><a href="#Generator.partitionboundspec_sql-1250"><span class="linenos">1250</span></a> <span class="n">from_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">"from_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.partitionboundspec_sql-1251"><a href="#Generator.partitionboundspec_sql-1251"><span class="linenos">1251</span></a> <span class="n">to_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">"to_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.partitionboundspec_sql-1252"><a href="#Generator.partitionboundspec_sql-1252"><span class="linenos">1252</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"FROM (</span><span class="si">{</span><span class="n">from_expressions</span><span class="si">}</span><span class="s2">) TO (</span><span class="si">{</span><span class="n">to_expressions</span><span class="si">}</span><span class="s2">)"</span> </span></pre></div> @@ -10092,16 +10174,16 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.partitionedofproperty_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.partitionedofproperty_sql-1259"><a href="#Generator.partitionedofproperty_sql-1259"><span class="linenos">1259</span></a> <span class="k">def</span> <span class="nf">partitionedofproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionedOfProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.partitionedofproperty_sql-1260"><a href="#Generator.partitionedofproperty_sql-1260"><span class="linenos">1260</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.partitionedofproperty_sql-1261"><a href="#Generator.partitionedofproperty_sql-1261"><span class="linenos">1261</span></a> -</span><span id="Generator.partitionedofproperty_sql-1262"><a href="#Generator.partitionedofproperty_sql-1262"><span class="linenos">1262</span></a> <span class="n">for_values_or_default</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span> -</span><span id="Generator.partitionedofproperty_sql-1263"><a href="#Generator.partitionedofproperty_sql-1263"><span class="linenos">1263</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">for_values_or_default</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionBoundSpec</span><span class="p">):</span> -</span><span id="Generator.partitionedofproperty_sql-1264"><a href="#Generator.partitionedofproperty_sql-1264"><span class="linenos">1264</span></a> <span class="n">for_values_or_default</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" FOR 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">for_values_or_default</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.partitionedofproperty_sql-1265"><a href="#Generator.partitionedofproperty_sql-1265"><span class="linenos">1265</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator.partitionedofproperty_sql-1266"><a href="#Generator.partitionedofproperty_sql-1266"><span class="linenos">1266</span></a> <span class="n">for_values_or_default</span> <span class="o">=</span> <span class="s2">" DEFAULT"</span> -</span><span id="Generator.partitionedofproperty_sql-1267"><a href="#Generator.partitionedofproperty_sql-1267"><span class="linenos">1267</span></a> -</span><span id="Generator.partitionedofproperty_sql-1268"><a href="#Generator.partitionedofproperty_sql-1268"><span class="linenos">1268</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PARTITION OF </span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">for_values_or_default</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.partitionedofproperty_sql-1254"><a href="#Generator.partitionedofproperty_sql-1254"><span class="linenos">1254</span></a> <span class="k">def</span> <span class="nf">partitionedofproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionedOfProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.partitionedofproperty_sql-1255"><a href="#Generator.partitionedofproperty_sql-1255"><span class="linenos">1255</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.partitionedofproperty_sql-1256"><a href="#Generator.partitionedofproperty_sql-1256"><span class="linenos">1256</span></a> +</span><span id="Generator.partitionedofproperty_sql-1257"><a href="#Generator.partitionedofproperty_sql-1257"><span class="linenos">1257</span></a> <span class="n">for_values_or_default</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span> +</span><span id="Generator.partitionedofproperty_sql-1258"><a href="#Generator.partitionedofproperty_sql-1258"><span class="linenos">1258</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">for_values_or_default</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionBoundSpec</span><span class="p">):</span> +</span><span id="Generator.partitionedofproperty_sql-1259"><a href="#Generator.partitionedofproperty_sql-1259"><span class="linenos">1259</span></a> <span class="n">for_values_or_default</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" FOR 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">for_values_or_default</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.partitionedofproperty_sql-1260"><a href="#Generator.partitionedofproperty_sql-1260"><span class="linenos">1260</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator.partitionedofproperty_sql-1261"><a href="#Generator.partitionedofproperty_sql-1261"><span class="linenos">1261</span></a> <span class="n">for_values_or_default</span> <span class="o">=</span> <span class="s2">" DEFAULT"</span> +</span><span id="Generator.partitionedofproperty_sql-1262"><a href="#Generator.partitionedofproperty_sql-1262"><span class="linenos">1262</span></a> +</span><span id="Generator.partitionedofproperty_sql-1263"><a href="#Generator.partitionedofproperty_sql-1263"><span class="linenos">1263</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PARTITION OF </span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">for_values_or_default</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -10119,14 +10201,14 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.lockingproperty_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.lockingproperty_sql-1270"><a href="#Generator.lockingproperty_sql-1270"><span class="linenos">1270</span></a> <span class="k">def</span> <span class="nf">lockingproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">LockingProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.lockingproperty_sql-1271"><a href="#Generator.lockingproperty_sql-1271"><span class="linenos">1271</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="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">)</span> -</span><span id="Generator.lockingproperty_sql-1272"><a href="#Generator.lockingproperty_sql-1272"><span class="linenos">1272</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="bp">self</span><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="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.lockingproperty_sql-1273"><a href="#Generator.lockingproperty_sql-1273"><span class="linenos">1273</span></a> <span class="n">for_or_in</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">"for_or_in"</span><span class="p">)</span> -</span><span id="Generator.lockingproperty_sql-1274"><a href="#Generator.lockingproperty_sql-1274"><span class="linenos">1274</span></a> <span class="n">for_or_in</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">for_or_in</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">for_or_in</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.lockingproperty_sql-1275"><a href="#Generator.lockingproperty_sql-1275"><span class="linenos">1275</span></a> <span class="n">lock_type</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">"lock_type"</span><span class="p">)</span> -</span><span id="Generator.lockingproperty_sql-1276"><a href="#Generator.lockingproperty_sql-1276"><span class="linenos">1276</span></a> <span class="n">override</span> <span class="o">=</span> <span class="s2">" OVERRIDE"</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">"override"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.lockingproperty_sql-1277"><a href="#Generator.lockingproperty_sql-1277"><span class="linenos">1277</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"LOCKING </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">for_or_in</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">lock_type</span><span class="si">}{</span><span class="n">override</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.lockingproperty_sql-1265"><a href="#Generator.lockingproperty_sql-1265"><span class="linenos">1265</span></a> <span class="k">def</span> <span class="nf">lockingproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">LockingProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.lockingproperty_sql-1266"><a href="#Generator.lockingproperty_sql-1266"><span class="linenos">1266</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="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">)</span> +</span><span id="Generator.lockingproperty_sql-1267"><a href="#Generator.lockingproperty_sql-1267"><span class="linenos">1267</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="bp">self</span><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="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.lockingproperty_sql-1268"><a href="#Generator.lockingproperty_sql-1268"><span class="linenos">1268</span></a> <span class="n">for_or_in</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">"for_or_in"</span><span class="p">)</span> +</span><span id="Generator.lockingproperty_sql-1269"><a href="#Generator.lockingproperty_sql-1269"><span class="linenos">1269</span></a> <span class="n">for_or_in</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">for_or_in</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">for_or_in</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.lockingproperty_sql-1270"><a href="#Generator.lockingproperty_sql-1270"><span class="linenos">1270</span></a> <span class="n">lock_type</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">"lock_type"</span><span class="p">)</span> +</span><span id="Generator.lockingproperty_sql-1271"><a href="#Generator.lockingproperty_sql-1271"><span class="linenos">1271</span></a> <span class="n">override</span> <span class="o">=</span> <span class="s2">" OVERRIDE"</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">"override"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.lockingproperty_sql-1272"><a href="#Generator.lockingproperty_sql-1272"><span class="linenos">1272</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"LOCKING </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">for_or_in</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">lock_type</span><span class="si">}{</span><span class="n">override</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -10144,13 +10226,13 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.withdataproperty_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.withdataproperty_sql-1279"><a href="#Generator.withdataproperty_sql-1279"><span class="linenos">1279</span></a> <span class="k">def</span> <span class="nf">withdataproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">WithDataProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.withdataproperty_sql-1280"><a href="#Generator.withdataproperty_sql-1280"><span class="linenos">1280</span></a> <span class="n">data_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"WITH </span><span class="si">{</span><span class="s1">'NO '</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">'no'</span><span class="p">)</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">DATA"</span> -</span><span id="Generator.withdataproperty_sql-1281"><a href="#Generator.withdataproperty_sql-1281"><span class="linenos">1281</span></a> <span class="n">statistics</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">"statistics"</span><span class="p">)</span> -</span><span id="Generator.withdataproperty_sql-1282"><a href="#Generator.withdataproperty_sql-1282"><span class="linenos">1282</span></a> <span class="n">statistics_sql</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator.withdataproperty_sql-1283"><a href="#Generator.withdataproperty_sql-1283"><span class="linenos">1283</span></a> <span class="k">if</span> <span class="n">statistics</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Generator.withdataproperty_sql-1284"><a href="#Generator.withdataproperty_sql-1284"><span class="linenos">1284</span></a> <span class="n">statistics_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AND </span><span class="si">{</span><span class="s1">'NO '</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="ow">not</span><span class="w"> </span><span class="n">statistics</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">STATISTICS"</span> -</span><span id="Generator.withdataproperty_sql-1285"><a href="#Generator.withdataproperty_sql-1285"><span class="linenos">1285</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">data_sql</span><span class="si">}{</span><span class="n">statistics_sql</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.withdataproperty_sql-1274"><a href="#Generator.withdataproperty_sql-1274"><span class="linenos">1274</span></a> <span class="k">def</span> <span class="nf">withdataproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">WithDataProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.withdataproperty_sql-1275"><a href="#Generator.withdataproperty_sql-1275"><span class="linenos">1275</span></a> <span class="n">data_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"WITH </span><span class="si">{</span><span class="s1">'NO '</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">'no'</span><span class="p">)</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">DATA"</span> +</span><span id="Generator.withdataproperty_sql-1276"><a href="#Generator.withdataproperty_sql-1276"><span class="linenos">1276</span></a> <span class="n">statistics</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">"statistics"</span><span class="p">)</span> +</span><span id="Generator.withdataproperty_sql-1277"><a href="#Generator.withdataproperty_sql-1277"><span class="linenos">1277</span></a> <span class="n">statistics_sql</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator.withdataproperty_sql-1278"><a href="#Generator.withdataproperty_sql-1278"><span class="linenos">1278</span></a> <span class="k">if</span> <span class="n">statistics</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Generator.withdataproperty_sql-1279"><a href="#Generator.withdataproperty_sql-1279"><span class="linenos">1279</span></a> <span class="n">statistics_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AND </span><span class="si">{</span><span class="s1">'NO '</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="ow">not</span><span class="w"> </span><span class="n">statistics</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">STATISTICS"</span> +</span><span id="Generator.withdataproperty_sql-1280"><a href="#Generator.withdataproperty_sql-1280"><span class="linenos">1280</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">data_sql</span><span class="si">}{</span><span class="n">statistics_sql</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -10168,20 +10250,20 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.withsystemversioningproperty_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.withsystemversioningproperty_sql-1287"><a href="#Generator.withsystemversioningproperty_sql-1287"><span class="linenos">1287</span></a> <span class="k">def</span> <span class="nf">withsystemversioningproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">WithSystemVersioningProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.withsystemversioningproperty_sql-1288"><a href="#Generator.withsystemversioningproperty_sql-1288"><span class="linenos">1288</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="s2">"WITH(SYSTEM_VERSIONING=ON"</span> -</span><span id="Generator.withsystemversioningproperty_sql-1289"><a href="#Generator.withsystemversioningproperty_sql-1289"><span class="linenos">1289</span></a> -</span><span id="Generator.withsystemversioningproperty_sql-1290"><a href="#Generator.withsystemversioningproperty_sql-1290"><span class="linenos">1290</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">:</span> -</span><span id="Generator.withsystemversioningproperty_sql-1291"><a href="#Generator.withsystemversioningproperty_sql-1291"><span class="linenos">1291</span></a> <span class="n">history_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">"this"</span><span class="p">)</span> -</span><span id="Generator.withsystemversioningproperty_sql-1292"><a href="#Generator.withsystemversioningproperty_sql-1292"><span class="linenos">1292</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="s2">(HISTORY_TABLE=</span><span class="si">{</span><span class="n">history_table</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.withsystemversioningproperty_sql-1293"><a href="#Generator.withsystemversioningproperty_sql-1293"><span class="linenos">1293</span></a> -</span><span id="Generator.withsystemversioningproperty_sql-1294"><a href="#Generator.withsystemversioningproperty_sql-1294"><span class="linenos">1294</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span><span class="p">:</span> -</span><span id="Generator.withsystemversioningproperty_sql-1295"><a href="#Generator.withsystemversioningproperty_sql-1295"><span class="linenos">1295</span></a> <span class="n">data_consistency_check</span> <span class="o">=</span> <span class="bp">self</span><span 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.withsystemversioningproperty_sql-1296"><a href="#Generator.withsystemversioningproperty_sql-1296"><span class="linenos">1296</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="s2">, DATA_CONSISTENCY_CHECK=</span><span class="si">{</span><span class="n">data_consistency_check</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.withsystemversioningproperty_sql-1297"><a href="#Generator.withsystemversioningproperty_sql-1297"><span class="linenos">1297</span></a> -</span><span id="Generator.withsystemversioningproperty_sql-1298"><a href="#Generator.withsystemversioningproperty_sql-1298"><span class="linenos">1298</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="s2">)"</span> -</span><span id="Generator.withsystemversioningproperty_sql-1299"><a href="#Generator.withsystemversioningproperty_sql-1299"><span class="linenos">1299</span></a> -</span><span id="Generator.withsystemversioningproperty_sql-1300"><a href="#Generator.withsystemversioningproperty_sql-1300"><span class="linenos">1300</span></a> <span class="k">return</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="s2">)"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.withsystemversioningproperty_sql-1282"><a href="#Generator.withsystemversioningproperty_sql-1282"><span class="linenos">1282</span></a> <span class="k">def</span> <span class="nf">withsystemversioningproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">WithSystemVersioningProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.withsystemversioningproperty_sql-1283"><a href="#Generator.withsystemversioningproperty_sql-1283"><span class="linenos">1283</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="s2">"WITH(SYSTEM_VERSIONING=ON"</span> +</span><span id="Generator.withsystemversioningproperty_sql-1284"><a href="#Generator.withsystemversioningproperty_sql-1284"><span class="linenos">1284</span></a> +</span><span id="Generator.withsystemversioningproperty_sql-1285"><a href="#Generator.withsystemversioningproperty_sql-1285"><span class="linenos">1285</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">:</span> +</span><span id="Generator.withsystemversioningproperty_sql-1286"><a href="#Generator.withsystemversioningproperty_sql-1286"><span class="linenos">1286</span></a> <span class="n">history_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">"this"</span><span class="p">)</span> +</span><span id="Generator.withsystemversioningproperty_sql-1287"><a href="#Generator.withsystemversioningproperty_sql-1287"><span class="linenos">1287</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="s2">(HISTORY_TABLE=</span><span class="si">{</span><span class="n">history_table</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.withsystemversioningproperty_sql-1288"><a href="#Generator.withsystemversioningproperty_sql-1288"><span class="linenos">1288</span></a> +</span><span id="Generator.withsystemversioningproperty_sql-1289"><a href="#Generator.withsystemversioningproperty_sql-1289"><span class="linenos">1289</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span><span class="p">:</span> +</span><span id="Generator.withsystemversioningproperty_sql-1290"><a href="#Generator.withsystemversioningproperty_sql-1290"><span class="linenos">1290</span></a> <span class="n">data_consistency_check</span> <span class="o">=</span> <span class="bp">self</span><span 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.withsystemversioningproperty_sql-1291"><a href="#Generator.withsystemversioningproperty_sql-1291"><span class="linenos">1291</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="s2">, DATA_CONSISTENCY_CHECK=</span><span class="si">{</span><span class="n">data_consistency_check</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.withsystemversioningproperty_sql-1292"><a href="#Generator.withsystemversioningproperty_sql-1292"><span class="linenos">1292</span></a> +</span><span id="Generator.withsystemversioningproperty_sql-1293"><a href="#Generator.withsystemversioningproperty_sql-1293"><span class="linenos">1293</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="s2">)"</span> +</span><span id="Generator.withsystemversioningproperty_sql-1294"><a href="#Generator.withsystemversioningproperty_sql-1294"><span class="linenos">1294</span></a> +</span><span id="Generator.withsystemversioningproperty_sql-1295"><a href="#Generator.withsystemversioningproperty_sql-1295"><span class="linenos">1295</span></a> <span class="k">return</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="s2">)"</span> </span></pre></div> @@ -10199,38 +10281,38 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.insert_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.insert_sql-1302"><a href="#Generator.insert_sql-1302"><span class="linenos">1302</span></a> <span class="k">def</span> <span class="nf">insert_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">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 class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.insert_sql-1303"><a href="#Generator.insert_sql-1303"><span class="linenos">1303</span></a> <span class="n">overwrite</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">"overwrite"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.insert_sql-1297"><a href="#Generator.insert_sql-1297"><span class="linenos">1297</span></a> <span class="k">def</span> <span class="nf">insert_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">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 class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.insert_sql-1298"><a href="#Generator.insert_sql-1298"><span class="linenos">1298</span></a> <span class="n">overwrite</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">"overwrite"</span><span class="p">)</span> +</span><span id="Generator.insert_sql-1299"><a href="#Generator.insert_sql-1299"><span class="linenos">1299</span></a> +</span><span id="Generator.insert_sql-1300"><a href="#Generator.insert_sql-1300"><span class="linenos">1300</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">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Directory</span><span class="p">):</span> +</span><span id="Generator.insert_sql-1301"><a href="#Generator.insert_sql-1301"><span class="linenos">1301</span></a> <span class="n">this</span> <span class="o">=</span> <span class="s2">" OVERWRITE"</span> <span class="k">if</span> <span class="n">overwrite</span> <span class="k">else</span> <span class="s2">" INTO"</span> +</span><span id="Generator.insert_sql-1302"><a href="#Generator.insert_sql-1302"><span class="linenos">1302</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator.insert_sql-1303"><a href="#Generator.insert_sql-1303"><span class="linenos">1303</span></a> <span class="n">this</span> <span class="o">=</span> <span class="s2">" OVERWRITE TABLE"</span> <span class="k">if</span> <span class="n">overwrite</span> <span class="k">else</span> <span class="s2">" INTO"</span> </span><span id="Generator.insert_sql-1304"><a href="#Generator.insert_sql-1304"><span class="linenos">1304</span></a> -</span><span id="Generator.insert_sql-1305"><a href="#Generator.insert_sql-1305"><span class="linenos">1305</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">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Directory</span><span class="p">):</span> -</span><span id="Generator.insert_sql-1306"><a href="#Generator.insert_sql-1306"><span class="linenos">1306</span></a> <span class="n">this</span> <span class="o">=</span> <span class="s2">" OVERWRITE"</span> <span class="k">if</span> <span class="n">overwrite</span> <span class="k">else</span> <span class="s2">" INTO"</span> -</span><span id="Generator.insert_sql-1307"><a href="#Generator.insert_sql-1307"><span class="linenos">1307</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator.insert_sql-1308"><a href="#Generator.insert_sql-1308"><span class="linenos">1308</span></a> <span class="n">this</span> <span class="o">=</span> <span class="s2">" OVERWRITE TABLE"</span> <span class="k">if</span> <span class="n">overwrite</span> <span class="k">else</span> <span class="s2">" INTO"</span> -</span><span id="Generator.insert_sql-1309"><a href="#Generator.insert_sql-1309"><span class="linenos">1309</span></a> -</span><span id="Generator.insert_sql-1310"><a href="#Generator.insert_sql-1310"><span class="linenos">1310</span></a> <span class="n">alternative</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">"alternative"</span><span class="p">)</span> -</span><span id="Generator.insert_sql-1311"><a href="#Generator.insert_sql-1311"><span class="linenos">1311</span></a> <span class="n">alternative</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" OR </span><span class="si">{</span><span class="n">alternative</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alternative</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.insert_sql-1312"><a href="#Generator.insert_sql-1312"><span class="linenos">1312</span></a> <span class="n">ignore</span> <span class="o">=</span> <span class="s2">" IGNORE"</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">"ignore"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.insert_sql-1313"><a href="#Generator.insert_sql-1313"><span class="linenos">1313</span></a> -</span><span id="Generator.insert_sql-1314"><a href="#Generator.insert_sql-1314"><span class="linenos">1314</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="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.insert_sql-1315"><a href="#Generator.insert_sql-1315"><span class="linenos">1315</span></a> -</span><span id="Generator.insert_sql-1316"><a href="#Generator.insert_sql-1316"><span class="linenos">1316</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.insert_sql-1317"><a href="#Generator.insert_sql-1317"><span class="linenos">1317</span></a> <span class="n">partition_sql</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Generator.insert_sql-1318"><a href="#Generator.insert_sql-1318"><span class="linenos">1318</span></a> <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">'partition'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</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">"partition"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.insert_sql-1319"><a href="#Generator.insert_sql-1319"><span class="linenos">1319</span></a> <span class="p">)</span> -</span><span id="Generator.insert_sql-1320"><a href="#Generator.insert_sql-1320"><span class="linenos">1320</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.insert_sql-1321"><a href="#Generator.insert_sql-1321"><span class="linenos">1321</span></a> <span class="n">where</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="si">}</span><span class="s2">REPLACE WHERE </span><span class="si">{</span><span class="n">where</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">where</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.insert_sql-1322"><a href="#Generator.insert_sql-1322"><span class="linenos">1322</span></a> <span class="n">expression_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">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.insert_sql-1323"><a href="#Generator.insert_sql-1323"><span class="linenos">1323</span></a> <span class="n">conflict</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"conflict"</span><span class="p">)</span> -</span><span id="Generator.insert_sql-1324"><a href="#Generator.insert_sql-1324"><span class="linenos">1324</span></a> <span class="n">by_name</span> <span class="o">=</span> <span class="s2">" BY NAME"</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">"by_name"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.insert_sql-1325"><a href="#Generator.insert_sql-1325"><span class="linenos">1325</span></a> <span class="n">returning</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"returning"</span><span class="p">)</span> +</span><span id="Generator.insert_sql-1305"><a href="#Generator.insert_sql-1305"><span class="linenos">1305</span></a> <span class="n">alternative</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">"alternative"</span><span class="p">)</span> +</span><span id="Generator.insert_sql-1306"><a href="#Generator.insert_sql-1306"><span class="linenos">1306</span></a> <span class="n">alternative</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" OR </span><span class="si">{</span><span class="n">alternative</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alternative</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.insert_sql-1307"><a href="#Generator.insert_sql-1307"><span class="linenos">1307</span></a> <span class="n">ignore</span> <span class="o">=</span> <span class="s2">" IGNORE"</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">"ignore"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.insert_sql-1308"><a href="#Generator.insert_sql-1308"><span class="linenos">1308</span></a> +</span><span id="Generator.insert_sql-1309"><a href="#Generator.insert_sql-1309"><span class="linenos">1309</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="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.insert_sql-1310"><a href="#Generator.insert_sql-1310"><span class="linenos">1310</span></a> +</span><span id="Generator.insert_sql-1311"><a href="#Generator.insert_sql-1311"><span class="linenos">1311</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.insert_sql-1312"><a href="#Generator.insert_sql-1312"><span class="linenos">1312</span></a> <span class="n">partition_sql</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Generator.insert_sql-1313"><a href="#Generator.insert_sql-1313"><span class="linenos">1313</span></a> <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">'partition'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</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">"partition"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.insert_sql-1314"><a href="#Generator.insert_sql-1314"><span class="linenos">1314</span></a> <span class="p">)</span> +</span><span id="Generator.insert_sql-1315"><a href="#Generator.insert_sql-1315"><span class="linenos">1315</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.insert_sql-1316"><a href="#Generator.insert_sql-1316"><span class="linenos">1316</span></a> <span class="n">where</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="si">}</span><span class="s2">REPLACE WHERE </span><span class="si">{</span><span class="n">where</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">where</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.insert_sql-1317"><a href="#Generator.insert_sql-1317"><span class="linenos">1317</span></a> <span class="n">expression_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">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.insert_sql-1318"><a href="#Generator.insert_sql-1318"><span class="linenos">1318</span></a> <span class="n">conflict</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"conflict"</span><span class="p">)</span> +</span><span id="Generator.insert_sql-1319"><a href="#Generator.insert_sql-1319"><span class="linenos">1319</span></a> <span class="n">by_name</span> <span class="o">=</span> <span class="s2">" BY NAME"</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">"by_name"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.insert_sql-1320"><a href="#Generator.insert_sql-1320"><span class="linenos">1320</span></a> <span class="n">returning</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"returning"</span><span class="p">)</span> +</span><span id="Generator.insert_sql-1321"><a href="#Generator.insert_sql-1321"><span class="linenos">1321</span></a> +</span><span id="Generator.insert_sql-1322"><a href="#Generator.insert_sql-1322"><span class="linenos">1322</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">RETURNING_END</span><span class="p">:</span> +</span><span id="Generator.insert_sql-1323"><a href="#Generator.insert_sql-1323"><span class="linenos">1323</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">expression_sql</span><span class="si">}{</span><span class="n">conflict</span><span class="si">}{</span><span class="n">returning</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.insert_sql-1324"><a href="#Generator.insert_sql-1324"><span class="linenos">1324</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator.insert_sql-1325"><a href="#Generator.insert_sql-1325"><span class="linenos">1325</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">returning</span><span class="si">}{</span><span class="n">expression_sql</span><span class="si">}{</span><span class="n">conflict</span><span class="si">}</span><span class="s2">"</span> </span><span id="Generator.insert_sql-1326"><a href="#Generator.insert_sql-1326"><span class="linenos">1326</span></a> -</span><span id="Generator.insert_sql-1327"><a href="#Generator.insert_sql-1327"><span class="linenos">1327</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">RETURNING_END</span><span class="p">:</span> -</span><span id="Generator.insert_sql-1328"><a href="#Generator.insert_sql-1328"><span class="linenos">1328</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">expression_sql</span><span class="si">}{</span><span class="n">conflict</span><span class="si">}{</span><span class="n">returning</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.insert_sql-1329"><a href="#Generator.insert_sql-1329"><span class="linenos">1329</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator.insert_sql-1330"><a href="#Generator.insert_sql-1330"><span class="linenos">1330</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">returning</span><span class="si">}{</span><span class="n">expression_sql</span><span class="si">}{</span><span class="n">conflict</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.insert_sql-1331"><a href="#Generator.insert_sql-1331"><span class="linenos">1331</span></a> -</span><span id="Generator.insert_sql-1332"><a href="#Generator.insert_sql-1332"><span class="linenos">1332</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"INSERT</span><span class="si">{</span><span class="n">alternative</span><span class="si">}{</span><span class="n">ignore</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="n">by_name</span><span class="si">}{</span><span class="n">exists</span><span class="si">}{</span><span class="n">partition_sql</span><span class="si">}{</span><span class="n">where</span><span class="si">}{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.insert_sql-1333"><a href="#Generator.insert_sql-1333"><span class="linenos">1333</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.insert_sql-1327"><a href="#Generator.insert_sql-1327"><span class="linenos">1327</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"INSERT</span><span class="si">{</span><span class="n">alternative</span><span class="si">}{</span><span class="n">ignore</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="n">by_name</span><span class="si">}{</span><span class="n">exists</span><span class="si">}{</span><span class="n">partition_sql</span><span class="si">}{</span><span class="n">where</span><span class="si">}{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.insert_sql-1328"><a href="#Generator.insert_sql-1328"><span class="linenos">1328</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> @@ -10248,11 +10330,11 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.intersect_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.intersect_sql-1335"><a href="#Generator.intersect_sql-1335"><span class="linenos">1335</span></a> <span class="k">def</span> <span class="nf">intersect_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Intersect</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.intersect_sql-1336"><a href="#Generator.intersect_sql-1336"><span class="linenos">1336</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><span id="Generator.intersect_sql-1337"><a href="#Generator.intersect_sql-1337"><span class="linenos">1337</span></a> <span class="n">expression</span><span class="p">,</span> -</span><span id="Generator.intersect_sql-1338"><a href="#Generator.intersect_sql-1338"><span class="linenos">1338</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">set_operation</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">intersect_op</span><span class="p">(</span><span class="n">expression</span><span class="p">)),</span> -</span><span id="Generator.intersect_sql-1339"><a href="#Generator.intersect_sql-1339"><span class="linenos">1339</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.intersect_sql-1330"><a href="#Generator.intersect_sql-1330"><span class="linenos">1330</span></a> <span class="k">def</span> <span class="nf">intersect_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Intersect</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.intersect_sql-1331"><a href="#Generator.intersect_sql-1331"><span class="linenos">1331</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><span id="Generator.intersect_sql-1332"><a href="#Generator.intersect_sql-1332"><span class="linenos">1332</span></a> <span class="n">expression</span><span class="p">,</span> +</span><span id="Generator.intersect_sql-1333"><a href="#Generator.intersect_sql-1333"><span class="linenos">1333</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">set_operation</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">intersect_op</span><span class="p">(</span><span class="n">expression</span><span class="p">)),</span> +</span><span id="Generator.intersect_sql-1334"><a href="#Generator.intersect_sql-1334"><span class="linenos">1334</span></a> <span class="p">)</span> </span></pre></div> @@ -10270,8 +10352,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.intersect_op"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.intersect_op-1341"><a href="#Generator.intersect_op-1341"><span class="linenos">1341</span></a> <span class="k">def</span> <span class="nf">intersect_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Intersect</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.intersect_op-1342"><a href="#Generator.intersect_op-1342"><span class="linenos">1342</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"INTERSECT</span><span class="si">{</span><span class="s1">''</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">'distinct'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">' ALL'</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.intersect_op-1336"><a href="#Generator.intersect_op-1336"><span class="linenos">1336</span></a> <span class="k">def</span> <span class="nf">intersect_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Intersect</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.intersect_op-1337"><a href="#Generator.intersect_op-1337"><span class="linenos">1337</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"INTERSECT</span><span class="si">{</span><span class="s1">''</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">'distinct'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">' ALL'</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -10289,8 +10371,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.introducer_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.introducer_sql-1344"><a href="#Generator.introducer_sql-1344"><span class="linenos">1344</span></a> <span class="k">def</span> <span class="nf">introducer_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Introducer</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.introducer_sql-1345"><a href="#Generator.introducer_sql-1345"><span class="linenos">1345</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.introducer_sql-1339"><a href="#Generator.introducer_sql-1339"><span class="linenos">1339</span></a> <span class="k">def</span> <span class="nf">introducer_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Introducer</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.introducer_sql-1340"><a href="#Generator.introducer_sql-1340"><span class="linenos">1340</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> @@ -10308,12 +10390,12 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.kill_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.kill_sql-1347"><a href="#Generator.kill_sql-1347"><span class="linenos">1347</span></a> <span class="k">def</span> <span class="nf">kill_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Kill</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.kill_sql-1348"><a href="#Generator.kill_sql-1348"><span class="linenos">1348</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.kill_sql-1349"><a href="#Generator.kill_sql-1349"><span class="linenos">1349</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.kill_sql-1350"><a href="#Generator.kill_sql-1350"><span class="linenos">1350</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.kill_sql-1351"><a href="#Generator.kill_sql-1351"><span class="linenos">1351</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.kill_sql-1352"><a href="#Generator.kill_sql-1352"><span class="linenos">1352</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"KILL</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.kill_sql-1342"><a href="#Generator.kill_sql-1342"><span class="linenos">1342</span></a> <span class="k">def</span> <span class="nf">kill_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Kill</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.kill_sql-1343"><a href="#Generator.kill_sql-1343"><span class="linenos">1343</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.kill_sql-1344"><a href="#Generator.kill_sql-1344"><span class="linenos">1344</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.kill_sql-1345"><a href="#Generator.kill_sql-1345"><span class="linenos">1345</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.kill_sql-1346"><a href="#Generator.kill_sql-1346"><span class="linenos">1346</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.kill_sql-1347"><a href="#Generator.kill_sql-1347"><span class="linenos">1347</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"KILL</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> @@ -10331,8 +10413,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.pseudotype_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.pseudotype_sql-1354"><a href="#Generator.pseudotype_sql-1354"><span class="linenos">1354</span></a> <span class="k">def</span> <span class="nf">pseudotype_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">PseudoType</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.pseudotype_sql-1355"><a href="#Generator.pseudotype_sql-1355"><span class="linenos">1355</span></a> <span class="k">return</span> <span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.pseudotype_sql-1349"><a href="#Generator.pseudotype_sql-1349"><span class="linenos">1349</span></a> <span class="k">def</span> <span class="nf">pseudotype_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">PseudoType</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.pseudotype_sql-1350"><a href="#Generator.pseudotype_sql-1350"><span class="linenos">1350</span></a> <span class="k">return</span> <span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> </span></pre></div> @@ -10350,8 +10432,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.objectidentifier_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.objectidentifier_sql-1357"><a href="#Generator.objectidentifier_sql-1357"><span class="linenos">1357</span></a> <span class="k">def</span> <span class="nf">objectidentifier_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ObjectIdentifier</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.objectidentifier_sql-1358"><a href="#Generator.objectidentifier_sql-1358"><span class="linenos">1358</span></a> <span class="k">return</span> <span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.objectidentifier_sql-1352"><a href="#Generator.objectidentifier_sql-1352"><span class="linenos">1352</span></a> <span class="k">def</span> <span class="nf">objectidentifier_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ObjectIdentifier</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.objectidentifier_sql-1353"><a href="#Generator.objectidentifier_sql-1353"><span class="linenos">1353</span></a> <span class="k">return</span> <span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> </span></pre></div> @@ -10369,19 +10451,19 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.onconflict_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.onconflict_sql-1360"><a href="#Generator.onconflict_sql-1360"><span class="linenos">1360</span></a> <span class="k">def</span> <span class="nf">onconflict_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">OnConflict</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.onconflict_sql-1361"><a href="#Generator.onconflict_sql-1361"><span class="linenos">1361</span></a> <span class="n">conflict</span> <span class="o">=</span> <span class="s2">"ON DUPLICATE KEY"</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">"duplicate"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">"ON CONFLICT"</span> -</span><span id="Generator.onconflict_sql-1362"><a href="#Generator.onconflict_sql-1362"><span class="linenos">1362</span></a> <span class="n">constraint</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"constraint"</span><span class="p">)</span> -</span><span id="Generator.onconflict_sql-1363"><a href="#Generator.onconflict_sql-1363"><span class="linenos">1363</span></a> <span class="k">if</span> <span class="n">constraint</span><span class="p">:</span> -</span><span id="Generator.onconflict_sql-1364"><a href="#Generator.onconflict_sql-1364"><span class="linenos">1364</span></a> <span class="n">constraint</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"ON CONSTRAINT </span><span class="si">{</span><span class="n">constraint</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.onconflict_sql-1365"><a href="#Generator.onconflict_sql-1365"><span class="linenos">1365</span></a> <span class="n">key</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">"key"</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.onconflict_sql-1366"><a href="#Generator.onconflict_sql-1366"><span class="linenos">1366</span></a> <span class="n">do</span> <span class="o">=</span> <span class="s2">""</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">"duplicate"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">" DO "</span> -</span><span id="Generator.onconflict_sql-1367"><a href="#Generator.onconflict_sql-1367"><span class="linenos">1367</span></a> <span class="n">nothing</span> <span class="o">=</span> <span class="s2">"NOTHING"</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">"nothing"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.onconflict_sql-1368"><a href="#Generator.onconflict_sql-1368"><span class="linenos">1368</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.onconflict_sql-1369"><a href="#Generator.onconflict_sql-1369"><span class="linenos">1369</span></a> <span class="n">set_keyword</span> <span class="o">=</span> <span class="s2">"SET "</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">DUPLICATE_KEY_UPDATE_WITH_SET</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.onconflict_sql-1370"><a href="#Generator.onconflict_sql-1370"><span class="linenos">1370</span></a> <span class="k">if</span> <span class="n">expressions</span><span class="p">:</span> -</span><span id="Generator.onconflict_sql-1371"><a href="#Generator.onconflict_sql-1371"><span class="linenos">1371</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"UPDATE </span><span class="si">{</span><span class="n">set_keyword</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.onconflict_sql-1372"><a href="#Generator.onconflict_sql-1372"><span class="linenos">1372</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">conflict</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">constraint</span><span class="si">}{</span><span class="n">key</span><span class="si">}{</span><span class="n">do</span><span class="si">}{</span><span class="n">nothing</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.onconflict_sql-1355"><a href="#Generator.onconflict_sql-1355"><span class="linenos">1355</span></a> <span class="k">def</span> <span class="nf">onconflict_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">OnConflict</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.onconflict_sql-1356"><a href="#Generator.onconflict_sql-1356"><span class="linenos">1356</span></a> <span class="n">conflict</span> <span class="o">=</span> <span class="s2">"ON DUPLICATE KEY"</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">"duplicate"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">"ON CONFLICT"</span> +</span><span id="Generator.onconflict_sql-1357"><a href="#Generator.onconflict_sql-1357"><span class="linenos">1357</span></a> <span class="n">constraint</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"constraint"</span><span class="p">)</span> +</span><span id="Generator.onconflict_sql-1358"><a href="#Generator.onconflict_sql-1358"><span class="linenos">1358</span></a> <span class="k">if</span> <span class="n">constraint</span><span class="p">:</span> +</span><span id="Generator.onconflict_sql-1359"><a href="#Generator.onconflict_sql-1359"><span class="linenos">1359</span></a> <span class="n">constraint</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"ON CONSTRAINT </span><span class="si">{</span><span class="n">constraint</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.onconflict_sql-1360"><a href="#Generator.onconflict_sql-1360"><span class="linenos">1360</span></a> <span class="n">key</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">"key"</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.onconflict_sql-1361"><a href="#Generator.onconflict_sql-1361"><span class="linenos">1361</span></a> <span class="n">do</span> <span class="o">=</span> <span class="s2">""</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">"duplicate"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">" DO "</span> +</span><span id="Generator.onconflict_sql-1362"><a href="#Generator.onconflict_sql-1362"><span class="linenos">1362</span></a> <span class="n">nothing</span> <span class="o">=</span> <span class="s2">"NOTHING"</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">"nothing"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.onconflict_sql-1363"><a href="#Generator.onconflict_sql-1363"><span class="linenos">1363</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.onconflict_sql-1364"><a href="#Generator.onconflict_sql-1364"><span class="linenos">1364</span></a> <span class="n">set_keyword</span> <span class="o">=</span> <span class="s2">"SET "</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">DUPLICATE_KEY_UPDATE_WITH_SET</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.onconflict_sql-1365"><a href="#Generator.onconflict_sql-1365"><span class="linenos">1365</span></a> <span class="k">if</span> <span class="n">expressions</span><span class="p">:</span> +</span><span id="Generator.onconflict_sql-1366"><a href="#Generator.onconflict_sql-1366"><span class="linenos">1366</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"UPDATE </span><span class="si">{</span><span class="n">set_keyword</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.onconflict_sql-1367"><a href="#Generator.onconflict_sql-1367"><span class="linenos">1367</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">conflict</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">constraint</span><span class="si">}{</span><span class="n">key</span><span class="si">}{</span><span class="n">do</span><span class="si">}{</span><span class="n">nothing</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -10399,8 +10481,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.returning_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.returning_sql-1374"><a href="#Generator.returning_sql-1374"><span class="linenos">1374</span></a> <span class="k">def</span> <span class="nf">returning_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Returning</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.returning_sql-1375"><a href="#Generator.returning_sql-1375"><span class="linenos">1375</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="s1">'RETURNING'</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">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.returning_sql-1369"><a href="#Generator.returning_sql-1369"><span class="linenos">1369</span></a> <span class="k">def</span> <span class="nf">returning_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Returning</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.returning_sql-1370"><a href="#Generator.returning_sql-1370"><span class="linenos">1370</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="s1">'RETURNING'</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">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> @@ -10418,20 +10500,20 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.rowformatdelimitedproperty_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.rowformatdelimitedproperty_sql-1377"><a href="#Generator.rowformatdelimitedproperty_sql-1377"><span class="linenos">1377</span></a> <span class="k">def</span> <span class="nf">rowformatdelimitedproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RowFormatDelimitedProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.rowformatdelimitedproperty_sql-1378"><a href="#Generator.rowformatdelimitedproperty_sql-1378"><span class="linenos">1378</span></a> <span class="n">fields</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">"fields"</span><span class="p">)</span> -</span><span id="Generator.rowformatdelimitedproperty_sql-1379"><a href="#Generator.rowformatdelimitedproperty_sql-1379"><span class="linenos">1379</span></a> <span class="n">fields</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" FIELDS TERMINATED BY </span><span class="si">{</span><span class="n">fields</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">fields</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.rowformatdelimitedproperty_sql-1380"><a href="#Generator.rowformatdelimitedproperty_sql-1380"><span class="linenos">1380</span></a> <span class="n">escaped</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">"escaped"</span><span class="p">)</span> -</span><span id="Generator.rowformatdelimitedproperty_sql-1381"><a href="#Generator.rowformatdelimitedproperty_sql-1381"><span class="linenos">1381</span></a> <span class="n">escaped</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" ESCAPED BY </span><span class="si">{</span><span class="n">escaped</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">escaped</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.rowformatdelimitedproperty_sql-1382"><a href="#Generator.rowformatdelimitedproperty_sql-1382"><span class="linenos">1382</span></a> <span class="n">items</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">"collection_items"</span><span class="p">)</span> -</span><span id="Generator.rowformatdelimitedproperty_sql-1383"><a href="#Generator.rowformatdelimitedproperty_sql-1383"><span class="linenos">1383</span></a> <span class="n">items</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" COLLECTION ITEMS TERMINATED BY </span><span class="si">{</span><span class="n">items</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">items</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.rowformatdelimitedproperty_sql-1384"><a href="#Generator.rowformatdelimitedproperty_sql-1384"><span class="linenos">1384</span></a> <span class="n">keys</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">"map_keys"</span><span class="p">)</span> -</span><span id="Generator.rowformatdelimitedproperty_sql-1385"><a href="#Generator.rowformatdelimitedproperty_sql-1385"><span class="linenos">1385</span></a> <span class="n">keys</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" MAP KEYS TERMINATED BY </span><span class="si">{</span><span class="n">keys</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">keys</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.rowformatdelimitedproperty_sql-1386"><a href="#Generator.rowformatdelimitedproperty_sql-1386"><span class="linenos">1386</span></a> <span class="n">lines</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">"lines"</span><span class="p">)</span> -</span><span id="Generator.rowformatdelimitedproperty_sql-1387"><a href="#Generator.rowformatdelimitedproperty_sql-1387"><span class="linenos">1387</span></a> <span class="n">lines</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" LINES TERMINATED BY </span><span class="si">{</span><span class="n">lines</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">lines</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.rowformatdelimitedproperty_sql-1388"><a href="#Generator.rowformatdelimitedproperty_sql-1388"><span class="linenos">1388</span></a> <span class="n">null</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">"null"</span><span class="p">)</span> -</span><span id="Generator.rowformatdelimitedproperty_sql-1389"><a href="#Generator.rowformatdelimitedproperty_sql-1389"><span class="linenos">1389</span></a> <span class="n">null</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" NULL DEFINED AS </span><span class="si">{</span><span class="n">null</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">null</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.rowformatdelimitedproperty_sql-1390"><a href="#Generator.rowformatdelimitedproperty_sql-1390"><span class="linenos">1390</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ROW FORMAT DELIMITED</span><span class="si">{</span><span class="n">fields</span><span class="si">}{</span><span class="n">escaped</span><span class="si">}{</span><span class="n">items</span><span class="si">}{</span><span class="n">keys</span><span class="si">}{</span><span class="n">lines</span><span class="si">}{</span><span class="n">null</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.rowformatdelimitedproperty_sql-1372"><a href="#Generator.rowformatdelimitedproperty_sql-1372"><span class="linenos">1372</span></a> <span class="k">def</span> <span class="nf">rowformatdelimitedproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RowFormatDelimitedProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.rowformatdelimitedproperty_sql-1373"><a href="#Generator.rowformatdelimitedproperty_sql-1373"><span class="linenos">1373</span></a> <span class="n">fields</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">"fields"</span><span class="p">)</span> +</span><span id="Generator.rowformatdelimitedproperty_sql-1374"><a href="#Generator.rowformatdelimitedproperty_sql-1374"><span class="linenos">1374</span></a> <span class="n">fields</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" FIELDS TERMINATED BY </span><span class="si">{</span><span class="n">fields</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">fields</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.rowformatdelimitedproperty_sql-1375"><a href="#Generator.rowformatdelimitedproperty_sql-1375"><span class="linenos">1375</span></a> <span class="n">escaped</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">"escaped"</span><span class="p">)</span> +</span><span id="Generator.rowformatdelimitedproperty_sql-1376"><a href="#Generator.rowformatdelimitedproperty_sql-1376"><span class="linenos">1376</span></a> <span class="n">escaped</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" ESCAPED BY </span><span class="si">{</span><span class="n">escaped</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">escaped</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.rowformatdelimitedproperty_sql-1377"><a href="#Generator.rowformatdelimitedproperty_sql-1377"><span class="linenos">1377</span></a> <span class="n">items</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">"collection_items"</span><span class="p">)</span> +</span><span id="Generator.rowformatdelimitedproperty_sql-1378"><a href="#Generator.rowformatdelimitedproperty_sql-1378"><span class="linenos">1378</span></a> <span class="n">items</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" COLLECTION ITEMS TERMINATED BY </span><span class="si">{</span><span class="n">items</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">items</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.rowformatdelimitedproperty_sql-1379"><a href="#Generator.rowformatdelimitedproperty_sql-1379"><span class="linenos">1379</span></a> <span class="n">keys</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">"map_keys"</span><span class="p">)</span> +</span><span id="Generator.rowformatdelimitedproperty_sql-1380"><a href="#Generator.rowformatdelimitedproperty_sql-1380"><span class="linenos">1380</span></a> <span class="n">keys</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" MAP KEYS TERMINATED BY </span><span class="si">{</span><span class="n">keys</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">keys</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.rowformatdelimitedproperty_sql-1381"><a href="#Generator.rowformatdelimitedproperty_sql-1381"><span class="linenos">1381</span></a> <span class="n">lines</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">"lines"</span><span class="p">)</span> +</span><span id="Generator.rowformatdelimitedproperty_sql-1382"><a href="#Generator.rowformatdelimitedproperty_sql-1382"><span class="linenos">1382</span></a> <span class="n">lines</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" LINES TERMINATED BY </span><span class="si">{</span><span class="n">lines</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">lines</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.rowformatdelimitedproperty_sql-1383"><a href="#Generator.rowformatdelimitedproperty_sql-1383"><span class="linenos">1383</span></a> <span class="n">null</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">"null"</span><span class="p">)</span> +</span><span id="Generator.rowformatdelimitedproperty_sql-1384"><a href="#Generator.rowformatdelimitedproperty_sql-1384"><span class="linenos">1384</span></a> <span class="n">null</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" NULL DEFINED AS </span><span class="si">{</span><span class="n">null</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">null</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.rowformatdelimitedproperty_sql-1385"><a href="#Generator.rowformatdelimitedproperty_sql-1385"><span class="linenos">1385</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ROW FORMAT DELIMITED</span><span class="si">{</span><span class="n">fields</span><span class="si">}{</span><span class="n">escaped</span><span class="si">}{</span><span class="n">items</span><span class="si">}{</span><span class="n">keys</span><span class="si">}{</span><span class="n">lines</span><span class="si">}{</span><span class="n">null</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -10449,8 +10531,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.withtablehint_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.withtablehint_sql-1392"><a href="#Generator.withtablehint_sql-1392"><span class="linenos">1392</span></a> <span class="k">def</span> <span class="nf">withtablehint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">WithTableHint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.withtablehint_sql-1393"><a href="#Generator.withtablehint_sql-1393"><span class="linenos">1393</span></a> <span class="k">return</span> <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">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.withtablehint_sql-1387"><a href="#Generator.withtablehint_sql-1387"><span class="linenos">1387</span></a> <span class="k">def</span> <span class="nf">withtablehint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">WithTableHint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.withtablehint_sql-1388"><a href="#Generator.withtablehint_sql-1388"><span class="linenos">1388</span></a> <span class="k">return</span> <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">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> @@ -10468,11 +10550,33 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.indextablehint_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.indextablehint_sql-1395"><a href="#Generator.indextablehint_sql-1395"><span class="linenos">1395</span></a> <span class="k">def</span> <span class="nf">indextablehint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">IndexTableHint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.indextablehint_sql-1396"><a href="#Generator.indextablehint_sql-1396"><span class="linenos">1396</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="bp">self</span><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"> INDEX"</span> -</span><span id="Generator.indextablehint_sql-1397"><a href="#Generator.indextablehint_sql-1397"><span class="linenos">1397</span></a> <span class="n">target</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"target"</span><span class="p">)</span> -</span><span id="Generator.indextablehint_sql-1398"><a href="#Generator.indextablehint_sql-1398"><span class="linenos">1398</span></a> <span class="n">target</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" FOR </span><span class="si">{</span><span class="n">target</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">target</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.indextablehint_sql-1399"><a href="#Generator.indextablehint_sql-1399"><span class="linenos">1399</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">target</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">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.indextablehint_sql-1390"><a href="#Generator.indextablehint_sql-1390"><span class="linenos">1390</span></a> <span class="k">def</span> <span class="nf">indextablehint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">IndexTableHint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.indextablehint_sql-1391"><a href="#Generator.indextablehint_sql-1391"><span class="linenos">1391</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="bp">self</span><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"> INDEX"</span> +</span><span id="Generator.indextablehint_sql-1392"><a href="#Generator.indextablehint_sql-1392"><span class="linenos">1392</span></a> <span class="n">target</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"target"</span><span class="p">)</span> +</span><span id="Generator.indextablehint_sql-1393"><a href="#Generator.indextablehint_sql-1393"><span class="linenos">1393</span></a> <span class="n">target</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" FOR </span><span class="si">{</span><span class="n">target</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">target</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.indextablehint_sql-1394"><a href="#Generator.indextablehint_sql-1394"><span class="linenos">1394</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">target</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">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> + + + + + </div> + <div id="Generator.historicaldata_sql" class="classattr"> + <input id="Generator.historicaldata_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">historicaldata_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#HistoricalData">sqlglot.expressions.HistoricalData</a></span></span><span class="return-annotation">) -> <span class="nb">str</span>:</span></span> + + <label class="view-source-button" for="Generator.historicaldata_sql-view-source"><span>View Source</span></label> + + </div> + <a class="headerlink" href="#Generator.historicaldata_sql"></a> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.historicaldata_sql-1396"><a href="#Generator.historicaldata_sql-1396"><span class="linenos">1396</span></a> <span class="k">def</span> <span class="nf">historicaldata_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">HistoricalData</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.historicaldata_sql-1397"><a href="#Generator.historicaldata_sql-1397"><span class="linenos">1397</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.historicaldata_sql-1398"><a href="#Generator.historicaldata_sql-1398"><span class="linenos">1398</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.historicaldata_sql-1399"><a href="#Generator.historicaldata_sql-1399"><span class="linenos">1399</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.historicaldata_sql-1400"><a href="#Generator.historicaldata_sql-1400"><span class="linenos">1400</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="s2"> => </span><span class="si">{</span><span class="n">expr</span><span class="si">}</span><span class="s2">)"</span> </span></pre></div> @@ -10490,43 +10594,47 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.table_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.table_sql-1401"><a href="#Generator.table_sql-1401"><span class="linenos">1401</span></a> <span class="k">def</span> <span class="nf">table_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</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">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">" AS "</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.table_sql-1402"><a href="#Generator.table_sql-1402"><span class="linenos">1402</span></a> <span class="n">table</span> <span class="o">=</span> <span class="s2">"."</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> -</span><span id="Generator.table_sql-1403"><a href="#Generator.table_sql-1403"><span class="linenos">1403</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">part</span><span class="p">)</span> -</span><span id="Generator.table_sql-1404"><a href="#Generator.table_sql-1404"><span class="linenos">1404</span></a> <span class="k">for</span> <span class="n">part</span> <span class="ow">in</span> <span class="p">(</span> -</span><span id="Generator.table_sql-1405"><a href="#Generator.table_sql-1405"><span class="linenos">1405</span></a> <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">"catalog"</span><span class="p">),</span> -</span><span id="Generator.table_sql-1406"><a href="#Generator.table_sql-1406"><span class="linenos">1406</span></a> <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">"db"</span><span class="p">),</span> -</span><span id="Generator.table_sql-1407"><a href="#Generator.table_sql-1407"><span class="linenos">1407</span></a> <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">"this"</span><span class="p">),</span> -</span><span id="Generator.table_sql-1408"><a href="#Generator.table_sql-1408"><span class="linenos">1408</span></a> <span class="p">)</span> -</span><span id="Generator.table_sql-1409"><a href="#Generator.table_sql-1409"><span class="linenos">1409</span></a> <span class="k">if</span> <span class="n">part</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> -</span><span id="Generator.table_sql-1410"><a href="#Generator.table_sql-1410"><span class="linenos">1410</span></a> <span class="p">)</span> -</span><span id="Generator.table_sql-1411"><a href="#Generator.table_sql-1411"><span class="linenos">1411</span></a> -</span><span id="Generator.table_sql-1412"><a href="#Generator.table_sql-1412"><span class="linenos">1412</span></a> <span class="n">version</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"version"</span><span class="p">)</span> -</span><span id="Generator.table_sql-1413"><a href="#Generator.table_sql-1413"><span class="linenos">1413</span></a> <span class="n">version</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">version</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">version</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.table_sql-1414"><a href="#Generator.table_sql-1414"><span class="linenos">1414</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.table_sql-1415"><a href="#Generator.table_sql-1415"><span class="linenos">1415</span></a> <span class="n">alias</span> <span class="o">=</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">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.table_sql-1416"><a href="#Generator.table_sql-1416"><span class="linenos">1416</span></a> <span class="n">hints</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">"hints"</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.table_sql-1417"><a href="#Generator.table_sql-1417"><span class="linenos">1417</span></a> <span class="n">hints</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">hints</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">hints</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">TABLE_HINTS</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.table_sql-1418"><a href="#Generator.table_sql-1418"><span class="linenos">1418</span></a> <span class="n">pivots</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">"pivots"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</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.table_sql-1419"><a href="#Generator.table_sql-1419"><span class="linenos">1419</span></a> <span class="n">pivots</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">pivots</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">pivots</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.table_sql-1420"><a href="#Generator.table_sql-1420"><span class="linenos">1420</span></a> <span class="n">joins</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">"joins"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</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><span id="Generator.table_sql-1421"><a href="#Generator.table_sql-1421"><span class="linenos">1421</span></a> <span class="n">laterals</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">"laterals"</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.table_sql-1422"><a href="#Generator.table_sql-1422"><span class="linenos">1422</span></a> -</span><span id="Generator.table_sql-1423"><a href="#Generator.table_sql-1423"><span class="linenos">1423</span></a> <span class="n">file_format</span> <span class="o">=</span> <span class="bp">self</span><span 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.table_sql-1424"><a href="#Generator.table_sql-1424"><span class="linenos">1424</span></a> <span class="k">if</span> <span class="n">file_format</span><span class="p">:</span> -</span><span id="Generator.table_sql-1425"><a href="#Generator.table_sql-1425"><span class="linenos">1425</span></a> <span class="n">pattern</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"pattern"</span><span class="p">)</span> -</span><span id="Generator.table_sql-1426"><a href="#Generator.table_sql-1426"><span class="linenos">1426</span></a> <span class="n">pattern</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">", PATTERN => </span><span class="si">{</span><span class="n">pattern</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">pattern</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.table_sql-1427"><a href="#Generator.table_sql-1427"><span class="linenos">1427</span></a> <span class="n">file_format</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" (FILE_FORMAT => </span><span class="si">{</span><span class="n">file_format</span><span class="si">}{</span><span class="n">pattern</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="Generator.table_sql-1428"><a href="#Generator.table_sql-1428"><span class="linenos">1428</span></a> -</span><span id="Generator.table_sql-1429"><a href="#Generator.table_sql-1429"><span class="linenos">1429</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span 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"</span><span class="p">)</span> -</span><span id="Generator.table_sql-1430"><a href="#Generator.table_sql-1430"><span class="linenos">1430</span></a> <span class="n">index</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AT </span><span class="si">{</span><span class="n">index</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">index</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.table_sql-1431"><a href="#Generator.table_sql-1431"><span class="linenos">1431</span></a> -</span><span id="Generator.table_sql-1432"><a href="#Generator.table_sql-1432"><span class="linenos">1432</span></a> <span class="n">ordinality</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">"ordinality"</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">""</span> -</span><span id="Generator.table_sql-1433"><a href="#Generator.table_sql-1433"><span class="linenos">1433</span></a> <span class="k">if</span> <span class="n">ordinality</span><span class="p">:</span> -</span><span id="Generator.table_sql-1434"><a href="#Generator.table_sql-1434"><span class="linenos">1434</span></a> <span class="n">ordinality</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" WITH ORDINALITY</span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.table_sql-1435"><a href="#Generator.table_sql-1435"><span class="linenos">1435</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator.table_sql-1436"><a href="#Generator.table_sql-1436"><span class="linenos">1436</span></a> -</span><span id="Generator.table_sql-1437"><a href="#Generator.table_sql-1437"><span class="linenos">1437</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">table</span><span class="si">}{</span><span class="n">version</span><span class="si">}{</span><span class="n">file_format</span><span class="si">}{</span><span class="n">alias</span><span class="si">}{</span><span class="n">index</span><span class="si">}{</span><span class="n">hints</span><span class="si">}{</span><span class="n">pivots</span><span class="si">}{</span><span class="n">joins</span><span class="si">}{</span><span class="n">laterals</span><span class="si">}{</span><span class="n">ordinality</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.table_sql-1402"><a href="#Generator.table_sql-1402"><span class="linenos">1402</span></a> <span class="k">def</span> <span class="nf">table_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</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">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">" AS "</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.table_sql-1403"><a href="#Generator.table_sql-1403"><span class="linenos">1403</span></a> <span class="n">table</span> <span class="o">=</span> <span class="s2">"."</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> +</span><span id="Generator.table_sql-1404"><a href="#Generator.table_sql-1404"><span class="linenos">1404</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">part</span><span class="p">)</span> +</span><span id="Generator.table_sql-1405"><a href="#Generator.table_sql-1405"><span class="linenos">1405</span></a> <span class="k">for</span> <span class="n">part</span> <span class="ow">in</span> <span class="p">(</span> +</span><span id="Generator.table_sql-1406"><a href="#Generator.table_sql-1406"><span class="linenos">1406</span></a> <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">"catalog"</span><span class="p">),</span> +</span><span id="Generator.table_sql-1407"><a href="#Generator.table_sql-1407"><span class="linenos">1407</span></a> <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">"db"</span><span class="p">),</span> +</span><span id="Generator.table_sql-1408"><a href="#Generator.table_sql-1408"><span class="linenos">1408</span></a> <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">"this"</span><span class="p">),</span> +</span><span id="Generator.table_sql-1409"><a href="#Generator.table_sql-1409"><span class="linenos">1409</span></a> <span class="p">)</span> +</span><span id="Generator.table_sql-1410"><a href="#Generator.table_sql-1410"><span class="linenos">1410</span></a> <span class="k">if</span> <span class="n">part</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> +</span><span id="Generator.table_sql-1411"><a href="#Generator.table_sql-1411"><span class="linenos">1411</span></a> <span class="p">)</span> +</span><span id="Generator.table_sql-1412"><a href="#Generator.table_sql-1412"><span class="linenos">1412</span></a> +</span><span id="Generator.table_sql-1413"><a href="#Generator.table_sql-1413"><span class="linenos">1413</span></a> <span class="n">version</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"version"</span><span class="p">)</span> +</span><span id="Generator.table_sql-1414"><a href="#Generator.table_sql-1414"><span class="linenos">1414</span></a> <span class="n">version</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">version</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">version</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.table_sql-1415"><a href="#Generator.table_sql-1415"><span class="linenos">1415</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.table_sql-1416"><a href="#Generator.table_sql-1416"><span class="linenos">1416</span></a> <span class="n">alias</span> <span class="o">=</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">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.table_sql-1417"><a href="#Generator.table_sql-1417"><span class="linenos">1417</span></a> <span class="n">hints</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">"hints"</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.table_sql-1418"><a href="#Generator.table_sql-1418"><span class="linenos">1418</span></a> <span class="n">hints</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">hints</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">hints</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">TABLE_HINTS</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.table_sql-1419"><a href="#Generator.table_sql-1419"><span class="linenos">1419</span></a> <span class="n">pivots</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">"pivots"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</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.table_sql-1420"><a href="#Generator.table_sql-1420"><span class="linenos">1420</span></a> <span class="n">pivots</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">pivots</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">pivots</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.table_sql-1421"><a href="#Generator.table_sql-1421"><span class="linenos">1421</span></a> <span class="n">joins</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">"joins"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</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><span id="Generator.table_sql-1422"><a href="#Generator.table_sql-1422"><span class="linenos">1422</span></a> <span class="n">laterals</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">"laterals"</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.table_sql-1423"><a href="#Generator.table_sql-1423"><span class="linenos">1423</span></a> +</span><span id="Generator.table_sql-1424"><a href="#Generator.table_sql-1424"><span class="linenos">1424</span></a> <span class="n">file_format</span> <span class="o">=</span> <span class="bp">self</span><span 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.table_sql-1425"><a href="#Generator.table_sql-1425"><span class="linenos">1425</span></a> <span class="k">if</span> <span class="n">file_format</span><span class="p">:</span> +</span><span id="Generator.table_sql-1426"><a href="#Generator.table_sql-1426"><span class="linenos">1426</span></a> <span class="n">pattern</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"pattern"</span><span class="p">)</span> +</span><span id="Generator.table_sql-1427"><a href="#Generator.table_sql-1427"><span class="linenos">1427</span></a> <span class="n">pattern</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">", PATTERN => </span><span class="si">{</span><span class="n">pattern</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">pattern</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.table_sql-1428"><a href="#Generator.table_sql-1428"><span class="linenos">1428</span></a> <span class="n">file_format</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" (FILE_FORMAT => </span><span class="si">{</span><span class="n">file_format</span><span class="si">}{</span><span class="n">pattern</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Generator.table_sql-1429"><a href="#Generator.table_sql-1429"><span class="linenos">1429</span></a> +</span><span id="Generator.table_sql-1430"><a href="#Generator.table_sql-1430"><span class="linenos">1430</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span 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"</span><span class="p">)</span> +</span><span id="Generator.table_sql-1431"><a href="#Generator.table_sql-1431"><span class="linenos">1431</span></a> <span class="n">index</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AT </span><span class="si">{</span><span class="n">index</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">index</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.table_sql-1432"><a href="#Generator.table_sql-1432"><span class="linenos">1432</span></a> +</span><span id="Generator.table_sql-1433"><a href="#Generator.table_sql-1433"><span class="linenos">1433</span></a> <span class="n">ordinality</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">"ordinality"</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">""</span> +</span><span id="Generator.table_sql-1434"><a href="#Generator.table_sql-1434"><span class="linenos">1434</span></a> <span class="k">if</span> <span class="n">ordinality</span><span class="p">:</span> +</span><span id="Generator.table_sql-1435"><a href="#Generator.table_sql-1435"><span class="linenos">1435</span></a> <span class="n">ordinality</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" WITH ORDINALITY</span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.table_sql-1436"><a href="#Generator.table_sql-1436"><span class="linenos">1436</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator.table_sql-1437"><a href="#Generator.table_sql-1437"><span class="linenos">1437</span></a> +</span><span id="Generator.table_sql-1438"><a href="#Generator.table_sql-1438"><span class="linenos">1438</span></a> <span class="n">when</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"when"</span><span class="p">)</span> +</span><span id="Generator.table_sql-1439"><a href="#Generator.table_sql-1439"><span class="linenos">1439</span></a> <span class="k">if</span> <span class="n">when</span><span class="p">:</span> +</span><span id="Generator.table_sql-1440"><a href="#Generator.table_sql-1440"><span class="linenos">1440</span></a> <span class="n">table</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">table</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">when</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.table_sql-1441"><a href="#Generator.table_sql-1441"><span class="linenos">1441</span></a> +</span><span id="Generator.table_sql-1442"><a href="#Generator.table_sql-1442"><span class="linenos">1442</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">table</span><span class="si">}{</span><span class="n">version</span><span class="si">}{</span><span class="n">file_format</span><span class="si">}{</span><span class="n">alias</span><span class="si">}{</span><span class="n">index</span><span class="si">}{</span><span class="n">hints</span><span class="si">}{</span><span class="n">pivots</span><span class="si">}{</span><span class="n">joins</span><span class="si">}{</span><span class="n">laterals</span><span class="si">}{</span><span class="n">ordinality</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -10544,43 +10652,43 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.tablesample_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.tablesample_sql-1439"><a href="#Generator.tablesample_sql-1439"><span class="linenos">1439</span></a> <span class="k">def</span> <span class="nf">tablesample_sql</span><span class="p">(</span> -</span><span id="Generator.tablesample_sql-1440"><a href="#Generator.tablesample_sql-1440"><span class="linenos">1440</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TableSample</span><span class="p">,</span> <span class="n">seed_prefix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"SEED"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" AS "</span> -</span><span id="Generator.tablesample_sql-1441"><a href="#Generator.tablesample_sql-1441"><span class="linenos">1441</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.tablesample_sql-1442"><a href="#Generator.tablesample_sql-1442"><span class="linenos">1442</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">ALIAS_POST_TABLESAMPLE</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">alias</span><span class="p">:</span> -</span><span id="Generator.tablesample_sql-1443"><a href="#Generator.tablesample_sql-1443"><span class="linenos">1443</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 class="o">.</span><span class="n">copy</span><span class="p">()</span> -</span><span id="Generator.tablesample_sql-1444"><a href="#Generator.tablesample_sql-1444"><span class="linenos">1444</span></a> <span class="n">table</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"alias"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> -</span><span id="Generator.tablesample_sql-1445"><a href="#Generator.tablesample_sql-1445"><span class="linenos">1445</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.tablesample_sql-1446"><a href="#Generator.tablesample_sql-1446"><span class="linenos">1446</span></a> <span class="n">alias</span> <span class="o">=</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="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="w"> </span><span class="s1">'alias'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.tablesample_sql-1447"><a href="#Generator.tablesample_sql-1447"><span class="linenos">1447</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator.tablesample_sql-1448"><a href="#Generator.tablesample_sql-1448"><span class="linenos">1448</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.tablesample_sql-1449"><a href="#Generator.tablesample_sql-1449"><span class="linenos">1449</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator.tablesample_sql-1450"><a href="#Generator.tablesample_sql-1450"><span class="linenos">1450</span></a> -</span><span id="Generator.tablesample_sql-1451"><a href="#Generator.tablesample_sql-1451"><span class="linenos">1451</span></a> <span class="n">method</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"method"</span><span class="p">)</span> -</span><span id="Generator.tablesample_sql-1452"><a href="#Generator.tablesample_sql-1452"><span class="linenos">1452</span></a> <span class="n">method</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">method</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">method</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">TABLESAMPLE_WITH_METHOD</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.tablesample_sql-1453"><a href="#Generator.tablesample_sql-1453"><span class="linenos">1453</span></a> <span class="n">numerator</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"bucket_numerator"</span><span class="p">)</span> -</span><span id="Generator.tablesample_sql-1454"><a href="#Generator.tablesample_sql-1454"><span class="linenos">1454</span></a> <span class="n">denominator</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"bucket_denominator"</span><span class="p">)</span> -</span><span id="Generator.tablesample_sql-1455"><a href="#Generator.tablesample_sql-1455"><span class="linenos">1455</span></a> <span class="n">field</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"bucket_field"</span><span class="p">)</span> -</span><span id="Generator.tablesample_sql-1456"><a href="#Generator.tablesample_sql-1456"><span class="linenos">1456</span></a> <span class="n">field</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" ON </span><span class="si">{</span><span class="n">field</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">field</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.tablesample_sql-1457"><a href="#Generator.tablesample_sql-1457"><span class="linenos">1457</span></a> <span class="n">bucket</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"BUCKET </span><span class="si">{</span><span class="n">numerator</span><span class="si">}</span><span class="s2"> OUT OF </span><span class="si">{</span><span class="n">denominator</span><span class="si">}{</span><span class="n">field</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">numerator</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.tablesample_sql-1458"><a href="#Generator.tablesample_sql-1458"><span class="linenos">1458</span></a> <span class="n">percent</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"percent"</span><span class="p">)</span> -</span><span id="Generator.tablesample_sql-1459"><a href="#Generator.tablesample_sql-1459"><span class="linenos">1459</span></a> <span class="n">percent</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">percent</span><span class="si">}</span><span class="s2"> PERCENT"</span> <span class="k">if</span> <span class="n">percent</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.tablesample_sql-1460"><a href="#Generator.tablesample_sql-1460"><span class="linenos">1460</span></a> <span class="n">rows</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"rows"</span><span class="p">)</span> -</span><span id="Generator.tablesample_sql-1461"><a href="#Generator.tablesample_sql-1461"><span class="linenos">1461</span></a> <span class="n">rows</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">rows</span><span class="si">}</span><span class="s2"> ROWS"</span> <span class="k">if</span> <span class="n">rows</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.tablesample_sql-1462"><a href="#Generator.tablesample_sql-1462"><span class="linenos">1462</span></a> -</span><span id="Generator.tablesample_sql-1463"><a href="#Generator.tablesample_sql-1463"><span class="linenos">1463</span></a> <span class="n">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">"size"</span><span class="p">)</span> -</span><span id="Generator.tablesample_sql-1464"><a href="#Generator.tablesample_sql-1464"><span class="linenos">1464</span></a> <span class="k">if</span> <span class="n">size</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">TABLESAMPLE_SIZE_IS_PERCENT</span><span class="p">:</span> -</span><span id="Generator.tablesample_sql-1465"><a href="#Generator.tablesample_sql-1465"><span class="linenos">1465</span></a> <span class="n">size</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">size</span><span class="si">}</span><span class="s2"> PERCENT"</span> -</span><span id="Generator.tablesample_sql-1466"><a href="#Generator.tablesample_sql-1466"><span class="linenos">1466</span></a> -</span><span id="Generator.tablesample_sql-1467"><a href="#Generator.tablesample_sql-1467"><span class="linenos">1467</span></a> <span class="n">seed</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"seed"</span><span class="p">)</span> -</span><span id="Generator.tablesample_sql-1468"><a href="#Generator.tablesample_sql-1468"><span class="linenos">1468</span></a> <span class="n">seed</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">seed_prefix</span><span class="si">}</span><span class="s2"> (</span><span class="si">{</span><span class="n">seed</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">seed</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.tablesample_sql-1469"><a href="#Generator.tablesample_sql-1469"><span class="linenos">1469</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="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">,</span> <span class="s2">"TABLESAMPLE"</span><span class="p">)</span> -</span><span id="Generator.tablesample_sql-1470"><a href="#Generator.tablesample_sql-1470"><span class="linenos">1470</span></a> -</span><span id="Generator.tablesample_sql-1471"><a href="#Generator.tablesample_sql-1471"><span class="linenos">1471</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">bucket</span><span class="si">}{</span><span class="n">percent</span><span class="si">}{</span><span class="n">rows</span><span class="si">}{</span><span class="n">size</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.tablesample_sql-1472"><a href="#Generator.tablesample_sql-1472"><span class="linenos">1472</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">TABLESAMPLE_REQUIRES_PARENS</span><span class="p">:</span> -</span><span id="Generator.tablesample_sql-1473"><a href="#Generator.tablesample_sql-1473"><span class="linenos">1473</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">expr</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="Generator.tablesample_sql-1474"><a href="#Generator.tablesample_sql-1474"><span class="linenos">1474</span></a> -</span><span id="Generator.tablesample_sql-1475"><a href="#Generator.tablesample_sql-1475"><span class="linenos">1475</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="s2"> </span><span class="si">{</span><span class="n">method</span><span class="si">}{</span><span class="n">expr</span><span class="si">}{</span><span class="n">seed</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.tablesample_sql-1444"><a href="#Generator.tablesample_sql-1444"><span class="linenos">1444</span></a> <span class="k">def</span> <span class="nf">tablesample_sql</span><span class="p">(</span> +</span><span id="Generator.tablesample_sql-1445"><a href="#Generator.tablesample_sql-1445"><span class="linenos">1445</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TableSample</span><span class="p">,</span> <span class="n">seed_prefix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"SEED"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" AS "</span> +</span><span id="Generator.tablesample_sql-1446"><a href="#Generator.tablesample_sql-1446"><span class="linenos">1446</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.tablesample_sql-1447"><a href="#Generator.tablesample_sql-1447"><span class="linenos">1447</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">ALIAS_POST_TABLESAMPLE</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">alias</span><span class="p">:</span> +</span><span id="Generator.tablesample_sql-1448"><a href="#Generator.tablesample_sql-1448"><span class="linenos">1448</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 class="o">.</span><span class="n">copy</span><span class="p">()</span> +</span><span id="Generator.tablesample_sql-1449"><a href="#Generator.tablesample_sql-1449"><span class="linenos">1449</span></a> <span class="n">table</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"alias"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> +</span><span id="Generator.tablesample_sql-1450"><a href="#Generator.tablesample_sql-1450"><span class="linenos">1450</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.tablesample_sql-1451"><a href="#Generator.tablesample_sql-1451"><span class="linenos">1451</span></a> <span class="n">alias</span> <span class="o">=</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="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="w"> </span><span class="s1">'alias'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.tablesample_sql-1452"><a href="#Generator.tablesample_sql-1452"><span class="linenos">1452</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator.tablesample_sql-1453"><a href="#Generator.tablesample_sql-1453"><span class="linenos">1453</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.tablesample_sql-1454"><a href="#Generator.tablesample_sql-1454"><span class="linenos">1454</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator.tablesample_sql-1455"><a href="#Generator.tablesample_sql-1455"><span class="linenos">1455</span></a> +</span><span id="Generator.tablesample_sql-1456"><a href="#Generator.tablesample_sql-1456"><span class="linenos">1456</span></a> <span class="n">method</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"method"</span><span class="p">)</span> +</span><span id="Generator.tablesample_sql-1457"><a href="#Generator.tablesample_sql-1457"><span class="linenos">1457</span></a> <span class="n">method</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">method</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">method</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">TABLESAMPLE_WITH_METHOD</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.tablesample_sql-1458"><a href="#Generator.tablesample_sql-1458"><span class="linenos">1458</span></a> <span class="n">numerator</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"bucket_numerator"</span><span class="p">)</span> +</span><span id="Generator.tablesample_sql-1459"><a href="#Generator.tablesample_sql-1459"><span class="linenos">1459</span></a> <span class="n">denominator</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"bucket_denominator"</span><span class="p">)</span> +</span><span id="Generator.tablesample_sql-1460"><a href="#Generator.tablesample_sql-1460"><span class="linenos">1460</span></a> <span class="n">field</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"bucket_field"</span><span class="p">)</span> +</span><span id="Generator.tablesample_sql-1461"><a href="#Generator.tablesample_sql-1461"><span class="linenos">1461</span></a> <span class="n">field</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" ON </span><span class="si">{</span><span class="n">field</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">field</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.tablesample_sql-1462"><a href="#Generator.tablesample_sql-1462"><span class="linenos">1462</span></a> <span class="n">bucket</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"BUCKET </span><span class="si">{</span><span class="n">numerator</span><span class="si">}</span><span class="s2"> OUT OF </span><span class="si">{</span><span class="n">denominator</span><span class="si">}{</span><span class="n">field</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">numerator</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.tablesample_sql-1463"><a href="#Generator.tablesample_sql-1463"><span class="linenos">1463</span></a> <span class="n">percent</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"percent"</span><span class="p">)</span> +</span><span id="Generator.tablesample_sql-1464"><a href="#Generator.tablesample_sql-1464"><span class="linenos">1464</span></a> <span class="n">percent</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">percent</span><span class="si">}</span><span class="s2"> PERCENT"</span> <span class="k">if</span> <span class="n">percent</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.tablesample_sql-1465"><a href="#Generator.tablesample_sql-1465"><span class="linenos">1465</span></a> <span class="n">rows</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"rows"</span><span class="p">)</span> +</span><span id="Generator.tablesample_sql-1466"><a href="#Generator.tablesample_sql-1466"><span class="linenos">1466</span></a> <span class="n">rows</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">rows</span><span class="si">}</span><span class="s2"> ROWS"</span> <span class="k">if</span> <span class="n">rows</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.tablesample_sql-1467"><a href="#Generator.tablesample_sql-1467"><span class="linenos">1467</span></a> +</span><span id="Generator.tablesample_sql-1468"><a href="#Generator.tablesample_sql-1468"><span class="linenos">1468</span></a> <span class="n">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">"size"</span><span class="p">)</span> +</span><span id="Generator.tablesample_sql-1469"><a href="#Generator.tablesample_sql-1469"><span class="linenos">1469</span></a> <span class="k">if</span> <span class="n">size</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">TABLESAMPLE_SIZE_IS_PERCENT</span><span class="p">:</span> +</span><span id="Generator.tablesample_sql-1470"><a href="#Generator.tablesample_sql-1470"><span class="linenos">1470</span></a> <span class="n">size</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">size</span><span class="si">}</span><span class="s2"> PERCENT"</span> +</span><span id="Generator.tablesample_sql-1471"><a href="#Generator.tablesample_sql-1471"><span class="linenos">1471</span></a> +</span><span id="Generator.tablesample_sql-1472"><a href="#Generator.tablesample_sql-1472"><span class="linenos">1472</span></a> <span class="n">seed</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"seed"</span><span class="p">)</span> +</span><span id="Generator.tablesample_sql-1473"><a href="#Generator.tablesample_sql-1473"><span class="linenos">1473</span></a> <span class="n">seed</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">seed_prefix</span><span class="si">}</span><span class="s2"> (</span><span class="si">{</span><span class="n">seed</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">seed</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.tablesample_sql-1474"><a href="#Generator.tablesample_sql-1474"><span class="linenos">1474</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="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">,</span> <span class="s2">"TABLESAMPLE"</span><span class="p">)</span> +</span><span id="Generator.tablesample_sql-1475"><a href="#Generator.tablesample_sql-1475"><span class="linenos">1475</span></a> +</span><span id="Generator.tablesample_sql-1476"><a href="#Generator.tablesample_sql-1476"><span class="linenos">1476</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">bucket</span><span class="si">}{</span><span class="n">percent</span><span class="si">}{</span><span class="n">rows</span><span class="si">}{</span><span class="n">size</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.tablesample_sql-1477"><a href="#Generator.tablesample_sql-1477"><span class="linenos">1477</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">TABLESAMPLE_REQUIRES_PARENS</span><span class="p">:</span> +</span><span id="Generator.tablesample_sql-1478"><a href="#Generator.tablesample_sql-1478"><span class="linenos">1478</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">expr</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Generator.tablesample_sql-1479"><a href="#Generator.tablesample_sql-1479"><span class="linenos">1479</span></a> +</span><span id="Generator.tablesample_sql-1480"><a href="#Generator.tablesample_sql-1480"><span class="linenos">1480</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="s2"> </span><span class="si">{</span><span class="n">method</span><span class="si">}{</span><span class="n">expr</span><span class="si">}{</span><span class="n">seed</span><span class="si">}{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -10598,31 +10706,31 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.pivot_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.pivot_sql-1477"><a href="#Generator.pivot_sql-1477"><span class="linenos">1477</span></a> <span class="k">def</span> <span class="nf">pivot_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Pivot</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.pivot_sql-1478"><a href="#Generator.pivot_sql-1478"><span class="linenos">1478</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.pivot_sql-1479"><a href="#Generator.pivot_sql-1479"><span class="linenos">1479</span></a> -</span><span id="Generator.pivot_sql-1480"><a href="#Generator.pivot_sql-1480"><span class="linenos">1480</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">:</span> -</span><span id="Generator.pivot_sql-1481"><a href="#Generator.pivot_sql-1481"><span class="linenos">1481</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.pivot_sql-1482"><a href="#Generator.pivot_sql-1482"><span class="linenos">1482</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.pivot_sql-1483"><a href="#Generator.pivot_sql-1483"><span class="linenos">1483</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"UNPIVOT </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.pivot_sql-1482"><a href="#Generator.pivot_sql-1482"><span class="linenos">1482</span></a> <span class="k">def</span> <span class="nf">pivot_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Pivot</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.pivot_sql-1483"><a href="#Generator.pivot_sql-1483"><span class="linenos">1483</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.pivot_sql-1484"><a href="#Generator.pivot_sql-1484"><span class="linenos">1484</span></a> -</span><span id="Generator.pivot_sql-1485"><a href="#Generator.pivot_sql-1485"><span class="linenos">1485</span></a> <span class="n">on</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">seg</span><span class="p">(</span><span class="s1">'ON'</span><span class="p">)</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.pivot_sql-1486"><a href="#Generator.pivot_sql-1486"><span class="linenos">1486</span></a> <span class="n">using</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">"using"</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.pivot_sql-1487"><a href="#Generator.pivot_sql-1487"><span class="linenos">1487</span></a> <span class="n">using</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">seg</span><span class="p">(</span><span class="s1">'USING'</span><span class="p">)</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="k">if</span> <span class="n">using</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.pivot_sql-1488"><a href="#Generator.pivot_sql-1488"><span class="linenos">1488</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.pivot_sql-1489"><a href="#Generator.pivot_sql-1489"><span class="linenos">1489</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PIVOT </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="n">using</span><span class="si">}{</span><span class="n">group</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.pivot_sql-1490"><a href="#Generator.pivot_sql-1490"><span class="linenos">1490</span></a> -</span><span id="Generator.pivot_sql-1491"><a href="#Generator.pivot_sql-1491"><span class="linenos">1491</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.pivot_sql-1492"><a href="#Generator.pivot_sql-1492"><span class="linenos">1492</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.pivot_sql-1493"><a href="#Generator.pivot_sql-1493"><span class="linenos">1493</span></a> <span class="n">unpivot</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">"unpivot"</span><span class="p">)</span> -</span><span id="Generator.pivot_sql-1494"><a href="#Generator.pivot_sql-1494"><span class="linenos">1494</span></a> <span class="n">direction</span> <span class="o">=</span> <span class="s2">"UNPIVOT"</span> <span class="k">if</span> <span class="n">unpivot</span> <span class="k">else</span> <span class="s2">"PIVOT"</span> -</span><span id="Generator.pivot_sql-1495"><a href="#Generator.pivot_sql-1495"><span class="linenos">1495</span></a> <span class="n">field</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"field"</span><span class="p">)</span> -</span><span id="Generator.pivot_sql-1496"><a href="#Generator.pivot_sql-1496"><span class="linenos">1496</span></a> <span class="n">include_nulls</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">"include_nulls"</span><span class="p">)</span> -</span><span id="Generator.pivot_sql-1497"><a href="#Generator.pivot_sql-1497"><span class="linenos">1497</span></a> <span class="k">if</span> <span class="n">include_nulls</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Generator.pivot_sql-1498"><a href="#Generator.pivot_sql-1498"><span class="linenos">1498</span></a> <span class="n">nulls</span> <span class="o">=</span> <span class="s2">" INCLUDE NULLS "</span> <span class="k">if</span> <span class="n">include_nulls</span> <span class="k">else</span> <span class="s2">" EXCLUDE NULLS "</span> -</span><span id="Generator.pivot_sql-1499"><a href="#Generator.pivot_sql-1499"><span class="linenos">1499</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator.pivot_sql-1500"><a href="#Generator.pivot_sql-1500"><span class="linenos">1500</span></a> <span class="n">nulls</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator.pivot_sql-1501"><a href="#Generator.pivot_sql-1501"><span class="linenos">1501</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">direction</span><span class="si">}{</span><span class="n">nulls</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"> FOR </span><span class="si">{</span><span class="n">field</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.pivot_sql-1485"><a href="#Generator.pivot_sql-1485"><span class="linenos">1485</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">:</span> +</span><span id="Generator.pivot_sql-1486"><a href="#Generator.pivot_sql-1486"><span class="linenos">1486</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.pivot_sql-1487"><a href="#Generator.pivot_sql-1487"><span class="linenos">1487</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.pivot_sql-1488"><a href="#Generator.pivot_sql-1488"><span class="linenos">1488</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"UNPIVOT </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.pivot_sql-1489"><a href="#Generator.pivot_sql-1489"><span class="linenos">1489</span></a> +</span><span id="Generator.pivot_sql-1490"><a href="#Generator.pivot_sql-1490"><span class="linenos">1490</span></a> <span class="n">on</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">seg</span><span class="p">(</span><span class="s1">'ON'</span><span class="p">)</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.pivot_sql-1491"><a href="#Generator.pivot_sql-1491"><span class="linenos">1491</span></a> <span class="n">using</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">"using"</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.pivot_sql-1492"><a href="#Generator.pivot_sql-1492"><span class="linenos">1492</span></a> <span class="n">using</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">seg</span><span class="p">(</span><span class="s1">'USING'</span><span class="p">)</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="k">if</span> <span class="n">using</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.pivot_sql-1493"><a href="#Generator.pivot_sql-1493"><span class="linenos">1493</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.pivot_sql-1494"><a href="#Generator.pivot_sql-1494"><span class="linenos">1494</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PIVOT </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="n">using</span><span class="si">}{</span><span class="n">group</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.pivot_sql-1495"><a href="#Generator.pivot_sql-1495"><span class="linenos">1495</span></a> +</span><span id="Generator.pivot_sql-1496"><a href="#Generator.pivot_sql-1496"><span class="linenos">1496</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.pivot_sql-1497"><a href="#Generator.pivot_sql-1497"><span class="linenos">1497</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.pivot_sql-1498"><a href="#Generator.pivot_sql-1498"><span class="linenos">1498</span></a> <span class="n">unpivot</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">"unpivot"</span><span class="p">)</span> +</span><span id="Generator.pivot_sql-1499"><a href="#Generator.pivot_sql-1499"><span class="linenos">1499</span></a> <span class="n">direction</span> <span class="o">=</span> <span class="s2">"UNPIVOT"</span> <span class="k">if</span> <span class="n">unpivot</span> <span class="k">else</span> <span class="s2">"PIVOT"</span> +</span><span id="Generator.pivot_sql-1500"><a href="#Generator.pivot_sql-1500"><span class="linenos">1500</span></a> <span class="n">field</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"field"</span><span class="p">)</span> +</span><span id="Generator.pivot_sql-1501"><a href="#Generator.pivot_sql-1501"><span class="linenos">1501</span></a> <span class="n">include_nulls</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">"include_nulls"</span><span class="p">)</span> +</span><span id="Generator.pivot_sql-1502"><a href="#Generator.pivot_sql-1502"><span class="linenos">1502</span></a> <span class="k">if</span> <span class="n">include_nulls</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Generator.pivot_sql-1503"><a href="#Generator.pivot_sql-1503"><span class="linenos">1503</span></a> <span class="n">nulls</span> <span class="o">=</span> <span class="s2">" INCLUDE NULLS "</span> <span class="k">if</span> <span class="n">include_nulls</span> <span class="k">else</span> <span class="s2">" EXCLUDE NULLS "</span> +</span><span id="Generator.pivot_sql-1504"><a href="#Generator.pivot_sql-1504"><span class="linenos">1504</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator.pivot_sql-1505"><a href="#Generator.pivot_sql-1505"><span class="linenos">1505</span></a> <span class="n">nulls</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator.pivot_sql-1506"><a href="#Generator.pivot_sql-1506"><span class="linenos">1506</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">direction</span><span class="si">}{</span><span class="n">nulls</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"> FOR </span><span class="si">{</span><span class="n">field</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -10640,11 +10748,11 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.version_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.version_sql-1503"><a href="#Generator.version_sql-1503"><span class="linenos">1503</span></a> <span class="k">def</span> <span class="nf">version_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Version</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.version_sql-1504"><a href="#Generator.version_sql-1504"><span class="linenos">1504</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"FOR </span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.version_sql-1505"><a href="#Generator.version_sql-1505"><span class="linenos">1505</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">)</span> -</span><span id="Generator.version_sql-1506"><a href="#Generator.version_sql-1506"><span class="linenos">1506</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.version_sql-1507"><a href="#Generator.version_sql-1507"><span class="linenos">1507</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="s2"> </span><span class="si">{</span><span class="n">expr</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.version_sql-1508"><a href="#Generator.version_sql-1508"><span class="linenos">1508</span></a> <span class="k">def</span> <span class="nf">version_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Version</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.version_sql-1509"><a href="#Generator.version_sql-1509"><span class="linenos">1509</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"FOR </span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.version_sql-1510"><a href="#Generator.version_sql-1510"><span class="linenos">1510</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">)</span> +</span><span id="Generator.version_sql-1511"><a href="#Generator.version_sql-1511"><span class="linenos">1511</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.version_sql-1512"><a href="#Generator.version_sql-1512"><span class="linenos">1512</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="s2"> </span><span class="si">{</span><span class="n">expr</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -10662,8 +10770,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.tuple_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.tuple_sql-1509"><a href="#Generator.tuple_sql-1509"><span class="linenos">1509</span></a> <span class="k">def</span> <span class="nf">tuple_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Tuple</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.tuple_sql-1510"><a href="#Generator.tuple_sql-1510"><span class="linenos">1510</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">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.tuple_sql-1514"><a href="#Generator.tuple_sql-1514"><span class="linenos">1514</span></a> <span class="k">def</span> <span class="nf">tuple_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Tuple</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.tuple_sql-1515"><a href="#Generator.tuple_sql-1515"><span class="linenos">1515</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">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> @@ -10681,20 +10789,20 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.update_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.update_sql-1512"><a href="#Generator.update_sql-1512"><span class="linenos">1512</span></a> <span class="k">def</span> <span class="nf">update_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">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 class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.update_sql-1513"><a href="#Generator.update_sql-1513"><span class="linenos">1513</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.update_sql-1514"><a href="#Generator.update_sql-1514"><span class="linenos">1514</span></a> <span class="n">set_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="kc">True</span><span class="p">)</span> -</span><span id="Generator.update_sql-1515"><a href="#Generator.update_sql-1515"><span class="linenos">1515</span></a> <span class="n">from_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">"from"</span><span class="p">)</span> -</span><span id="Generator.update_sql-1516"><a href="#Generator.update_sql-1516"><span class="linenos">1516</span></a> <span class="n">where_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">"where"</span><span class="p">)</span> -</span><span id="Generator.update_sql-1517"><a href="#Generator.update_sql-1517"><span class="linenos">1517</span></a> <span class="n">returning</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"returning"</span><span class="p">)</span> -</span><span id="Generator.update_sql-1518"><a href="#Generator.update_sql-1518"><span class="linenos">1518</span></a> <span class="n">order</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"order"</span><span class="p">)</span> -</span><span id="Generator.update_sql-1519"><a href="#Generator.update_sql-1519"><span class="linenos">1519</span></a> <span class="n">limit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"limit"</span><span class="p">)</span> -</span><span id="Generator.update_sql-1520"><a href="#Generator.update_sql-1520"><span class="linenos">1520</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">RETURNING_END</span><span class="p">:</span> -</span><span id="Generator.update_sql-1521"><a href="#Generator.update_sql-1521"><span class="linenos">1521</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">from_sql</span><span class="si">}{</span><span class="n">where_sql</span><span class="si">}{</span><span class="n">returning</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.update_sql-1522"><a href="#Generator.update_sql-1522"><span class="linenos">1522</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator.update_sql-1523"><a href="#Generator.update_sql-1523"><span class="linenos">1523</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">returning</span><span class="si">}{</span><span class="n">from_sql</span><span class="si">}{</span><span class="n">where_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.update_sql-1524"><a href="#Generator.update_sql-1524"><span class="linenos">1524</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"UPDATE </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> SET </span><span class="si">{</span><span class="n">set_sql</span><span class="si">}{</span><span class="n">expression_sql</span><span class="si">}{</span><span class="n">order</span><span class="si">}{</span><span class="n">limit</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.update_sql-1525"><a href="#Generator.update_sql-1525"><span class="linenos">1525</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.update_sql-1517"><a href="#Generator.update_sql-1517"><span class="linenos">1517</span></a> <span class="k">def</span> <span class="nf">update_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">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 class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.update_sql-1518"><a href="#Generator.update_sql-1518"><span class="linenos">1518</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.update_sql-1519"><a href="#Generator.update_sql-1519"><span class="linenos">1519</span></a> <span class="n">set_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="kc">True</span><span class="p">)</span> +</span><span id="Generator.update_sql-1520"><a href="#Generator.update_sql-1520"><span class="linenos">1520</span></a> <span class="n">from_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">"from"</span><span class="p">)</span> +</span><span id="Generator.update_sql-1521"><a href="#Generator.update_sql-1521"><span class="linenos">1521</span></a> <span class="n">where_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">"where"</span><span class="p">)</span> +</span><span id="Generator.update_sql-1522"><a href="#Generator.update_sql-1522"><span class="linenos">1522</span></a> <span class="n">returning</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"returning"</span><span class="p">)</span> +</span><span id="Generator.update_sql-1523"><a href="#Generator.update_sql-1523"><span class="linenos">1523</span></a> <span class="n">order</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"order"</span><span class="p">)</span> +</span><span id="Generator.update_sql-1524"><a href="#Generator.update_sql-1524"><span class="linenos">1524</span></a> <span class="n">limit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"limit"</span><span class="p">)</span> +</span><span id="Generator.update_sql-1525"><a href="#Generator.update_sql-1525"><span class="linenos">1525</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">RETURNING_END</span><span class="p">:</span> +</span><span id="Generator.update_sql-1526"><a href="#Generator.update_sql-1526"><span class="linenos">1526</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">from_sql</span><span class="si">}{</span><span class="n">where_sql</span><span class="si">}{</span><span class="n">returning</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.update_sql-1527"><a href="#Generator.update_sql-1527"><span class="linenos">1527</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator.update_sql-1528"><a href="#Generator.update_sql-1528"><span class="linenos">1528</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">returning</span><span class="si">}{</span><span class="n">from_sql</span><span class="si">}{</span><span class="n">where_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.update_sql-1529"><a href="#Generator.update_sql-1529"><span class="linenos">1529</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"UPDATE </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> SET </span><span class="si">{</span><span class="n">set_sql</span><span class="si">}{</span><span class="n">expression_sql</span><span class="si">}{</span><span class="n">order</span><span class="si">}{</span><span class="n">limit</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.update_sql-1530"><a href="#Generator.update_sql-1530"><span class="linenos">1530</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> @@ -10712,47 +10820,47 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.values_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.values_sql-1527"><a href="#Generator.values_sql-1527"><span class="linenos">1527</span></a> <span class="k">def</span> <span class="nf">values_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Values</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.values_sql-1528"><a href="#Generator.values_sql-1528"><span class="linenos">1528</span></a> <span class="c1"># The VALUES clause is still valid in an `INSERT INTO ..` statement, for example</span> -</span><span id="Generator.values_sql-1529"><a href="#Generator.values_sql-1529"><span class="linenos">1529</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">VALUES_AS_TABLE</span> <span class="ow">or</span> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">find_ancestor</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">From</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Join</span><span class="p">):</span> -</span><span id="Generator.values_sql-1530"><a href="#Generator.values_sql-1530"><span class="linenos">1530</span></a> <span class="n">args</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.values_sql-1531"><a href="#Generator.values_sql-1531"><span class="linenos">1531</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.values_sql-1532"><a href="#Generator.values_sql-1532"><span class="linenos">1532</span></a> <span class="n">values</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">seg</span><span class="p">(</span><span class="s1">''</span><span class="p">)</span><span class="si">}{</span><span class="n">args</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.values_sql-1533"><a href="#Generator.values_sql-1533"><span class="linenos">1533</span></a> <span class="n">values</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Generator.values_sql-1534"><a href="#Generator.values_sql-1534"><span class="linenos">1534</span></a> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">values</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="Generator.values_sql-1535"><a href="#Generator.values_sql-1535"><span class="linenos">1535</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">WRAP_DERIVED_VALUES</span> <span class="ow">and</span> <span class="p">(</span><span class="n">alias</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">From</span><span class="p">))</span> -</span><span id="Generator.values_sql-1536"><a href="#Generator.values_sql-1536"><span class="linenos">1536</span></a> <span class="k">else</span> <span class="n">values</span> -</span><span id="Generator.values_sql-1537"><a href="#Generator.values_sql-1537"><span class="linenos">1537</span></a> <span class="p">)</span> -</span><span id="Generator.values_sql-1538"><a href="#Generator.values_sql-1538"><span class="linenos">1538</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">values</span><span class="si">}</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="n">values</span> -</span><span id="Generator.values_sql-1539"><a href="#Generator.values_sql-1539"><span class="linenos">1539</span></a> -</span><span id="Generator.values_sql-1540"><a href="#Generator.values_sql-1540"><span class="linenos">1540</span></a> <span class="c1"># Converts `VALUES...` expression into a series of select unions.</span> -</span><span id="Generator.values_sql-1541"><a href="#Generator.values_sql-1541"><span class="linenos">1541</span></a> <span class="n">alias_node</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">"alias"</span><span class="p">)</span> -</span><span id="Generator.values_sql-1542"><a href="#Generator.values_sql-1542"><span class="linenos">1542</span></a> <span class="n">column_names</span> <span class="o">=</span> <span class="n">alias_node</span> <span class="ow">and</span> <span class="n">alias_node</span><span class="o">.</span><span class="n">columns</span> -</span><span id="Generator.values_sql-1543"><a href="#Generator.values_sql-1543"><span class="linenos">1543</span></a> -</span><span id="Generator.values_sql-1544"><a href="#Generator.values_sql-1544"><span class="linenos">1544</span></a> <span class="n">selects</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Subqueryable</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="Generator.values_sql-1545"><a href="#Generator.values_sql-1545"><span class="linenos">1545</span></a> -</span><span id="Generator.values_sql-1546"><a href="#Generator.values_sql-1546"><span class="linenos">1546</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">tup</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">expressions</span><span class="p">):</span> -</span><span id="Generator.values_sql-1547"><a href="#Generator.values_sql-1547"><span class="linenos">1547</span></a> <span class="n">row</span> <span class="o">=</span> <span class="n">tup</span><span class="o">.</span><span class="n">expressions</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.values_sql-1532"><a href="#Generator.values_sql-1532"><span class="linenos">1532</span></a> <span class="k">def</span> <span class="nf">values_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Values</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.values_sql-1533"><a href="#Generator.values_sql-1533"><span class="linenos">1533</span></a> <span class="c1"># The VALUES clause is still valid in an `INSERT INTO ..` statement, for example</span> +</span><span id="Generator.values_sql-1534"><a href="#Generator.values_sql-1534"><span class="linenos">1534</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">VALUES_AS_TABLE</span> <span class="ow">or</span> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">find_ancestor</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">From</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Join</span><span class="p">):</span> +</span><span id="Generator.values_sql-1535"><a href="#Generator.values_sql-1535"><span class="linenos">1535</span></a> <span class="n">args</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.values_sql-1536"><a href="#Generator.values_sql-1536"><span class="linenos">1536</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.values_sql-1537"><a href="#Generator.values_sql-1537"><span class="linenos">1537</span></a> <span class="n">values</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">seg</span><span class="p">(</span><span class="s1">''</span><span class="p">)</span><span class="si">}{</span><span class="n">args</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.values_sql-1538"><a href="#Generator.values_sql-1538"><span class="linenos">1538</span></a> <span class="n">values</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Generator.values_sql-1539"><a href="#Generator.values_sql-1539"><span class="linenos">1539</span></a> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">values</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Generator.values_sql-1540"><a href="#Generator.values_sql-1540"><span class="linenos">1540</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">WRAP_DERIVED_VALUES</span> <span class="ow">and</span> <span class="p">(</span><span class="n">alias</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">From</span><span class="p">))</span> +</span><span id="Generator.values_sql-1541"><a href="#Generator.values_sql-1541"><span class="linenos">1541</span></a> <span class="k">else</span> <span class="n">values</span> +</span><span id="Generator.values_sql-1542"><a href="#Generator.values_sql-1542"><span class="linenos">1542</span></a> <span class="p">)</span> +</span><span id="Generator.values_sql-1543"><a href="#Generator.values_sql-1543"><span class="linenos">1543</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">values</span><span class="si">}</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="n">values</span> +</span><span id="Generator.values_sql-1544"><a href="#Generator.values_sql-1544"><span class="linenos">1544</span></a> +</span><span id="Generator.values_sql-1545"><a href="#Generator.values_sql-1545"><span class="linenos">1545</span></a> <span class="c1"># Converts `VALUES...` expression into a series of select unions.</span> +</span><span id="Generator.values_sql-1546"><a href="#Generator.values_sql-1546"><span class="linenos">1546</span></a> <span class="n">alias_node</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">"alias"</span><span class="p">)</span> +</span><span id="Generator.values_sql-1547"><a href="#Generator.values_sql-1547"><span class="linenos">1547</span></a> <span class="n">column_names</span> <span class="o">=</span> <span class="n">alias_node</span> <span class="ow">and</span> <span class="n">alias_node</span><span class="o">.</span><span class="n">columns</span> </span><span id="Generator.values_sql-1548"><a href="#Generator.values_sql-1548"><span class="linenos">1548</span></a> -</span><span id="Generator.values_sql-1549"><a href="#Generator.values_sql-1549"><span class="linenos">1549</span></a> <span class="k">if</span> <span class="n">i</span> <span class="o">==</span> <span class="mi">0</span> <span class="ow">and</span> <span class="n">column_names</span><span class="p">:</span> -</span><span id="Generator.values_sql-1550"><a href="#Generator.values_sql-1550"><span class="linenos">1550</span></a> <span class="n">row</span> <span class="o">=</span> <span class="p">[</span> -</span><span id="Generator.values_sql-1551"><a href="#Generator.values_sql-1551"><span class="linenos">1551</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">alias_</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">column_name</span><span class="p">)</span> <span class="k">for</span> <span class="n">value</span><span class="p">,</span> <span class="n">column_name</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">row</span><span class="p">,</span> <span class="n">column_names</span><span class="p">)</span> -</span><span id="Generator.values_sql-1552"><a href="#Generator.values_sql-1552"><span class="linenos">1552</span></a> <span class="p">]</span> +</span><span id="Generator.values_sql-1549"><a href="#Generator.values_sql-1549"><span class="linenos">1549</span></a> <span class="n">selects</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Subqueryable</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="Generator.values_sql-1550"><a href="#Generator.values_sql-1550"><span class="linenos">1550</span></a> +</span><span id="Generator.values_sql-1551"><a href="#Generator.values_sql-1551"><span class="linenos">1551</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">tup</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">expressions</span><span class="p">):</span> +</span><span id="Generator.values_sql-1552"><a href="#Generator.values_sql-1552"><span class="linenos">1552</span></a> <span class="n">row</span> <span class="o">=</span> <span class="n">tup</span><span class="o">.</span><span class="n">expressions</span> </span><span id="Generator.values_sql-1553"><a href="#Generator.values_sql-1553"><span class="linenos">1553</span></a> -</span><span id="Generator.values_sql-1554"><a href="#Generator.values_sql-1554"><span class="linenos">1554</span></a> <span class="n">selects</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">row</span><span class="p">))</span> -</span><span id="Generator.values_sql-1555"><a href="#Generator.values_sql-1555"><span class="linenos">1555</span></a> -</span><span id="Generator.values_sql-1556"><a href="#Generator.values_sql-1556"><span class="linenos">1556</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.values_sql-1557"><a href="#Generator.values_sql-1557"><span class="linenos">1557</span></a> <span class="c1"># This may result in poor performance for large-cardinality `VALUES` tables, due to</span> -</span><span id="Generator.values_sql-1558"><a href="#Generator.values_sql-1558"><span class="linenos">1558</span></a> <span class="c1"># the deep nesting of the resulting exp.Unions. If this is a problem, either increase</span> -</span><span id="Generator.values_sql-1559"><a href="#Generator.values_sql-1559"><span class="linenos">1559</span></a> <span class="c1"># `sys.setrecursionlimit` to avoid RecursionErrors, or don't set `pretty`.</span> -</span><span id="Generator.values_sql-1560"><a href="#Generator.values_sql-1560"><span class="linenos">1560</span></a> <span class="n">subqueryable</span> <span class="o">=</span> <span class="n">reduce</span><span class="p">(</span><span class="k">lambda</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">union</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">distinct</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">),</span> <span class="n">selects</span><span class="p">)</span> -</span><span id="Generator.values_sql-1561"><a href="#Generator.values_sql-1561"><span class="linenos">1561</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">subquery_sql</span><span class="p">(</span> -</span><span id="Generator.values_sql-1562"><a href="#Generator.values_sql-1562"><span class="linenos">1562</span></a> <span class="n">subqueryable</span><span class="o">.</span><span class="n">subquery</span><span class="p">(</span><span class="n">alias_node</span> <span class="ow">and</span> <span class="n">alias_node</span><span class="o">.</span><span class="n">this</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.values_sql-1563"><a href="#Generator.values_sql-1563"><span class="linenos">1563</span></a> <span class="p">)</span> -</span><span id="Generator.values_sql-1564"><a href="#Generator.values_sql-1564"><span class="linenos">1564</span></a> -</span><span id="Generator.values_sql-1565"><a href="#Generator.values_sql-1565"><span class="linenos">1565</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="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">alias_node</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="k">if</span> <span class="n">alias_node</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.values_sql-1566"><a href="#Generator.values_sql-1566"><span class="linenos">1566</span></a> <span class="n">unions</span> <span class="o">=</span> <span class="s2">" UNION ALL "</span><span class="o">.</span><span class="n">join</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">select</span><span class="p">)</span> <span class="k">for</span> <span class="n">select</span> <span class="ow">in</span> <span class="n">selects</span><span class="p">)</span> -</span><span id="Generator.values_sql-1567"><a href="#Generator.values_sql-1567"><span class="linenos">1567</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">unions</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.values_sql-1554"><a href="#Generator.values_sql-1554"><span class="linenos">1554</span></a> <span class="k">if</span> <span class="n">i</span> <span class="o">==</span> <span class="mi">0</span> <span class="ow">and</span> <span class="n">column_names</span><span class="p">:</span> +</span><span id="Generator.values_sql-1555"><a href="#Generator.values_sql-1555"><span class="linenos">1555</span></a> <span class="n">row</span> <span class="o">=</span> <span class="p">[</span> +</span><span id="Generator.values_sql-1556"><a href="#Generator.values_sql-1556"><span class="linenos">1556</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">alias_</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">column_name</span><span class="p">)</span> <span class="k">for</span> <span class="n">value</span><span class="p">,</span> <span class="n">column_name</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">row</span><span class="p">,</span> <span class="n">column_names</span><span class="p">)</span> +</span><span id="Generator.values_sql-1557"><a href="#Generator.values_sql-1557"><span class="linenos">1557</span></a> <span class="p">]</span> +</span><span id="Generator.values_sql-1558"><a href="#Generator.values_sql-1558"><span class="linenos">1558</span></a> +</span><span id="Generator.values_sql-1559"><a href="#Generator.values_sql-1559"><span class="linenos">1559</span></a> <span class="n">selects</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">row</span><span class="p">))</span> +</span><span id="Generator.values_sql-1560"><a href="#Generator.values_sql-1560"><span class="linenos">1560</span></a> +</span><span id="Generator.values_sql-1561"><a href="#Generator.values_sql-1561"><span class="linenos">1561</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.values_sql-1562"><a href="#Generator.values_sql-1562"><span class="linenos">1562</span></a> <span class="c1"># This may result in poor performance for large-cardinality `VALUES` tables, due to</span> +</span><span id="Generator.values_sql-1563"><a href="#Generator.values_sql-1563"><span class="linenos">1563</span></a> <span class="c1"># the deep nesting of the resulting exp.Unions. If this is a problem, either increase</span> +</span><span id="Generator.values_sql-1564"><a href="#Generator.values_sql-1564"><span class="linenos">1564</span></a> <span class="c1"># `sys.setrecursionlimit` to avoid RecursionErrors, or don't set `pretty`.</span> +</span><span id="Generator.values_sql-1565"><a href="#Generator.values_sql-1565"><span class="linenos">1565</span></a> <span class="n">subqueryable</span> <span class="o">=</span> <span class="n">reduce</span><span class="p">(</span><span class="k">lambda</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">union</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">distinct</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">),</span> <span class="n">selects</span><span class="p">)</span> +</span><span id="Generator.values_sql-1566"><a href="#Generator.values_sql-1566"><span class="linenos">1566</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">subquery_sql</span><span class="p">(</span> +</span><span id="Generator.values_sql-1567"><a href="#Generator.values_sql-1567"><span class="linenos">1567</span></a> <span class="n">subqueryable</span><span class="o">.</span><span class="n">subquery</span><span class="p">(</span><span class="n">alias_node</span> <span class="ow">and</span> <span class="n">alias_node</span><span class="o">.</span><span class="n">this</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.values_sql-1568"><a href="#Generator.values_sql-1568"><span class="linenos">1568</span></a> <span class="p">)</span> +</span><span id="Generator.values_sql-1569"><a href="#Generator.values_sql-1569"><span class="linenos">1569</span></a> +</span><span id="Generator.values_sql-1570"><a href="#Generator.values_sql-1570"><span class="linenos">1570</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="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">alias_node</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="k">if</span> <span class="n">alias_node</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.values_sql-1571"><a href="#Generator.values_sql-1571"><span class="linenos">1571</span></a> <span class="n">unions</span> <span class="o">=</span> <span class="s2">" UNION ALL "</span><span class="o">.</span><span class="n">join</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">select</span><span class="p">)</span> <span class="k">for</span> <span class="n">select</span> <span class="ow">in</span> <span class="n">selects</span><span class="p">)</span> +</span><span id="Generator.values_sql-1572"><a href="#Generator.values_sql-1572"><span class="linenos">1572</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">unions</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -10770,8 +10878,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.var_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.var_sql-1569"><a href="#Generator.var_sql-1569"><span class="linenos">1569</span></a> <span class="k">def</span> <span class="nf">var_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Var</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.var_sql-1570"><a href="#Generator.var_sql-1570"><span class="linenos">1570</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">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.var_sql-1574"><a href="#Generator.var_sql-1574"><span class="linenos">1574</span></a> <span class="k">def</span> <span class="nf">var_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Var</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.var_sql-1575"><a href="#Generator.var_sql-1575"><span class="linenos">1575</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">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> </span></pre></div> @@ -10789,10 +10897,10 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.into_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.into_sql-1572"><a href="#Generator.into_sql-1572"><span class="linenos">1572</span></a> <span class="k">def</span> <span class="nf">into_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Into</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.into_sql-1573"><a href="#Generator.into_sql-1573"><span class="linenos">1573</span></a> <span class="n">temporary</span> <span class="o">=</span> <span class="s2">" TEMPORARY"</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">"temporary"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.into_sql-1574"><a href="#Generator.into_sql-1574"><span class="linenos">1574</span></a> <span class="n">unlogged</span> <span class="o">=</span> <span class="s2">" UNLOGGED"</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">"unlogged"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.into_sql-1575"><a href="#Generator.into_sql-1575"><span class="linenos">1575</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="s1">'INTO'</span><span class="p">)</span><span class="si">}{</span><span class="n">temporary</span><span class="w"> </span><span class="ow">or</span><span class="w"> </span><span class="n">unlogged</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.into_sql-1577"><a href="#Generator.into_sql-1577"><span class="linenos">1577</span></a> <span class="k">def</span> <span class="nf">into_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Into</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.into_sql-1578"><a href="#Generator.into_sql-1578"><span class="linenos">1578</span></a> <span class="n">temporary</span> <span class="o">=</span> <span class="s2">" TEMPORARY"</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">"temporary"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.into_sql-1579"><a href="#Generator.into_sql-1579"><span class="linenos">1579</span></a> <span class="n">unlogged</span> <span class="o">=</span> <span class="s2">" UNLOGGED"</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">"unlogged"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.into_sql-1580"><a href="#Generator.into_sql-1580"><span class="linenos">1580</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="s1">'INTO'</span><span class="p">)</span><span class="si">}{</span><span class="n">temporary</span><span class="w"> </span><span class="ow">or</span><span class="w"> </span><span class="n">unlogged</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> @@ -10810,8 +10918,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.from_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.from_sql-1577"><a href="#Generator.from_sql-1577"><span class="linenos">1577</span></a> <span class="k">def</span> <span class="nf">from_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">From</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.from_sql-1578"><a href="#Generator.from_sql-1578"><span class="linenos">1578</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="s1">'FROM'</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">'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.from_sql-1582"><a href="#Generator.from_sql-1582"><span class="linenos">1582</span></a> <span class="k">def</span> <span class="nf">from_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">From</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.from_sql-1583"><a href="#Generator.from_sql-1583"><span class="linenos">1583</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="s1">'FROM'</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">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -10829,43 +10937,43 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.group_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.group_sql-1580"><a href="#Generator.group_sql-1580"><span class="linenos">1580</span></a> <span class="k">def</span> <span class="nf">group_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Group</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.group_sql-1581"><a href="#Generator.group_sql-1581"><span class="linenos">1581</span></a> <span class="n">group_by</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">op_expressions</span><span class="p">(</span><span class="s2">"GROUP BY"</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> -</span><span id="Generator.group_sql-1582"><a href="#Generator.group_sql-1582"><span class="linenos">1582</span></a> -</span><span id="Generator.group_sql-1583"><a href="#Generator.group_sql-1583"><span class="linenos">1583</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">"all"</span><span class="p">):</span> -</span><span id="Generator.group_sql-1584"><a href="#Generator.group_sql-1584"><span class="linenos">1584</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">group_by</span><span class="si">}</span><span class="s2"> ALL"</span> -</span><span id="Generator.group_sql-1585"><a href="#Generator.group_sql-1585"><span class="linenos">1585</span></a> -</span><span id="Generator.group_sql-1586"><a href="#Generator.group_sql-1586"><span class="linenos">1586</span></a> <span class="n">grouping_sets</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">"grouping_sets"</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> -</span><span id="Generator.group_sql-1587"><a href="#Generator.group_sql-1587"><span class="linenos">1587</span></a> <span class="n">grouping_sets</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Generator.group_sql-1588"><a href="#Generator.group_sql-1588"><span class="linenos">1588</span></a> <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="s1">'GROUPING SETS'</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">wrap</span><span class="p">(</span><span class="n">grouping_sets</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">grouping_sets</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.group_sql-1589"><a href="#Generator.group_sql-1589"><span class="linenos">1589</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.group_sql-1585"><a href="#Generator.group_sql-1585"><span class="linenos">1585</span></a> <span class="k">def</span> <span class="nf">group_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Group</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.group_sql-1586"><a href="#Generator.group_sql-1586"><span class="linenos">1586</span></a> <span class="n">group_by</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">op_expressions</span><span class="p">(</span><span class="s2">"GROUP BY"</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> +</span><span id="Generator.group_sql-1587"><a href="#Generator.group_sql-1587"><span class="linenos">1587</span></a> +</span><span id="Generator.group_sql-1588"><a href="#Generator.group_sql-1588"><span class="linenos">1588</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">"all"</span><span class="p">):</span> +</span><span id="Generator.group_sql-1589"><a href="#Generator.group_sql-1589"><span class="linenos">1589</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">group_by</span><span class="si">}</span><span class="s2"> ALL"</span> </span><span id="Generator.group_sql-1590"><a href="#Generator.group_sql-1590"><span class="linenos">1590</span></a> -</span><span id="Generator.group_sql-1591"><a href="#Generator.group_sql-1591"><span class="linenos">1591</span></a> <span class="n">cube</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">"cube"</span><span class="p">,</span> <span class="p">[])</span> -</span><span id="Generator.group_sql-1592"><a href="#Generator.group_sql-1592"><span class="linenos">1592</span></a> <span class="k">if</span> <span class="n">seq_get</span><span class="p">(</span><span class="n">cube</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> <span class="ow">is</span> <span class="kc">True</span><span class="p">:</span> -</span><span id="Generator.group_sql-1593"><a href="#Generator.group_sql-1593"><span class="linenos">1593</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">group_by</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">'WITH CUBE'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.group_sql-1594"><a href="#Generator.group_sql-1594"><span class="linenos">1594</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator.group_sql-1595"><a href="#Generator.group_sql-1595"><span class="linenos">1595</span></a> <span class="n">cube_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">"cube"</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> -</span><span id="Generator.group_sql-1596"><a href="#Generator.group_sql-1596"><span class="linenos">1596</span></a> <span class="n">cube_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">seg</span><span class="p">(</span><span class="s1">'CUBE'</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">wrap</span><span class="p">(</span><span class="n">cube_sql</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">cube_sql</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.group_sql-1597"><a href="#Generator.group_sql-1597"><span class="linenos">1597</span></a> -</span><span id="Generator.group_sql-1598"><a href="#Generator.group_sql-1598"><span class="linenos">1598</span></a> <span class="n">rollup</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">"rollup"</span><span class="p">,</span> <span class="p">[])</span> -</span><span id="Generator.group_sql-1599"><a href="#Generator.group_sql-1599"><span class="linenos">1599</span></a> <span class="k">if</span> <span class="n">seq_get</span><span class="p">(</span><span class="n">rollup</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> <span class="ow">is</span> <span class="kc">True</span><span class="p">:</span> -</span><span id="Generator.group_sql-1600"><a href="#Generator.group_sql-1600"><span class="linenos">1600</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">group_by</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">'WITH ROLLUP'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.group_sql-1601"><a href="#Generator.group_sql-1601"><span class="linenos">1601</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator.group_sql-1602"><a href="#Generator.group_sql-1602"><span class="linenos">1602</span></a> <span class="n">rollup_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">"rollup"</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> -</span><span id="Generator.group_sql-1603"><a href="#Generator.group_sql-1603"><span class="linenos">1603</span></a> <span class="n">rollup_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">seg</span><span class="p">(</span><span class="s1">'ROLLUP'</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">wrap</span><span class="p">(</span><span class="n">rollup_sql</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">rollup_sql</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.group_sql-1604"><a href="#Generator.group_sql-1604"><span class="linenos">1604</span></a> -</span><span id="Generator.group_sql-1605"><a href="#Generator.group_sql-1605"><span class="linenos">1605</span></a> <span class="n">groupings</span> <span class="o">=</span> <span class="n">csv</span><span class="p">(</span> -</span><span id="Generator.group_sql-1606"><a href="#Generator.group_sql-1606"><span class="linenos">1606</span></a> <span class="n">grouping_sets</span><span class="p">,</span> -</span><span id="Generator.group_sql-1607"><a href="#Generator.group_sql-1607"><span class="linenos">1607</span></a> <span class="n">cube_sql</span><span class="p">,</span> -</span><span id="Generator.group_sql-1608"><a href="#Generator.group_sql-1608"><span class="linenos">1608</span></a> <span class="n">rollup_sql</span><span class="p">,</span> -</span><span id="Generator.group_sql-1609"><a href="#Generator.group_sql-1609"><span class="linenos">1609</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s2">"WITH TOTALS"</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">"totals"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span><span class="p">,</span> -</span><span id="Generator.group_sql-1610"><a href="#Generator.group_sql-1610"><span class="linenos">1610</span></a> <span class="n">sep</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">GROUPINGS_SEP</span><span class="p">,</span> -</span><span id="Generator.group_sql-1611"><a href="#Generator.group_sql-1611"><span class="linenos">1611</span></a> <span class="p">)</span> -</span><span id="Generator.group_sql-1612"><a href="#Generator.group_sql-1612"><span class="linenos">1612</span></a> -</span><span id="Generator.group_sql-1613"><a href="#Generator.group_sql-1613"><span class="linenos">1613</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">"expressions"</span><span class="p">)</span> <span class="ow">and</span> <span class="n">groupings</span><span class="p">:</span> -</span><span id="Generator.group_sql-1614"><a href="#Generator.group_sql-1614"><span class="linenos">1614</span></a> <span class="n">group_by</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">group_by</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">GROUPINGS_SEP</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.group_sql-1615"><a href="#Generator.group_sql-1615"><span class="linenos">1615</span></a> -</span><span id="Generator.group_sql-1616"><a href="#Generator.group_sql-1616"><span class="linenos">1616</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">group_by</span><span class="si">}{</span><span class="n">groupings</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.group_sql-1591"><a href="#Generator.group_sql-1591"><span class="linenos">1591</span></a> <span class="n">grouping_sets</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">"grouping_sets"</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</span><span id="Generator.group_sql-1592"><a href="#Generator.group_sql-1592"><span class="linenos">1592</span></a> <span class="n">grouping_sets</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Generator.group_sql-1593"><a href="#Generator.group_sql-1593"><span class="linenos">1593</span></a> <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="s1">'GROUPING SETS'</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">wrap</span><span class="p">(</span><span class="n">grouping_sets</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">grouping_sets</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.group_sql-1594"><a href="#Generator.group_sql-1594"><span class="linenos">1594</span></a> <span class="p">)</span> +</span><span id="Generator.group_sql-1595"><a href="#Generator.group_sql-1595"><span class="linenos">1595</span></a> +</span><span id="Generator.group_sql-1596"><a href="#Generator.group_sql-1596"><span class="linenos">1596</span></a> <span class="n">cube</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">"cube"</span><span class="p">,</span> <span class="p">[])</span> +</span><span id="Generator.group_sql-1597"><a href="#Generator.group_sql-1597"><span class="linenos">1597</span></a> <span class="k">if</span> <span class="n">seq_get</span><span class="p">(</span><span class="n">cube</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> <span class="ow">is</span> <span class="kc">True</span><span class="p">:</span> +</span><span id="Generator.group_sql-1598"><a href="#Generator.group_sql-1598"><span class="linenos">1598</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">group_by</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">'WITH CUBE'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.group_sql-1599"><a href="#Generator.group_sql-1599"><span class="linenos">1599</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator.group_sql-1600"><a href="#Generator.group_sql-1600"><span class="linenos">1600</span></a> <span class="n">cube_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">"cube"</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</span><span id="Generator.group_sql-1601"><a href="#Generator.group_sql-1601"><span class="linenos">1601</span></a> <span class="n">cube_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">seg</span><span class="p">(</span><span class="s1">'CUBE'</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">wrap</span><span class="p">(</span><span class="n">cube_sql</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">cube_sql</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.group_sql-1602"><a href="#Generator.group_sql-1602"><span class="linenos">1602</span></a> +</span><span id="Generator.group_sql-1603"><a href="#Generator.group_sql-1603"><span class="linenos">1603</span></a> <span class="n">rollup</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">"rollup"</span><span class="p">,</span> <span class="p">[])</span> +</span><span id="Generator.group_sql-1604"><a href="#Generator.group_sql-1604"><span class="linenos">1604</span></a> <span class="k">if</span> <span class="n">seq_get</span><span class="p">(</span><span class="n">rollup</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> <span class="ow">is</span> <span class="kc">True</span><span class="p">:</span> +</span><span id="Generator.group_sql-1605"><a href="#Generator.group_sql-1605"><span class="linenos">1605</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">group_by</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">'WITH ROLLUP'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.group_sql-1606"><a href="#Generator.group_sql-1606"><span class="linenos">1606</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator.group_sql-1607"><a href="#Generator.group_sql-1607"><span class="linenos">1607</span></a> <span class="n">rollup_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">"rollup"</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</span><span id="Generator.group_sql-1608"><a href="#Generator.group_sql-1608"><span class="linenos">1608</span></a> <span class="n">rollup_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">seg</span><span class="p">(</span><span class="s1">'ROLLUP'</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">wrap</span><span class="p">(</span><span class="n">rollup_sql</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">rollup_sql</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.group_sql-1609"><a href="#Generator.group_sql-1609"><span class="linenos">1609</span></a> +</span><span id="Generator.group_sql-1610"><a href="#Generator.group_sql-1610"><span class="linenos">1610</span></a> <span class="n">groupings</span> <span class="o">=</span> <span class="n">csv</span><span class="p">(</span> +</span><span id="Generator.group_sql-1611"><a href="#Generator.group_sql-1611"><span class="linenos">1611</span></a> <span class="n">grouping_sets</span><span class="p">,</span> +</span><span id="Generator.group_sql-1612"><a href="#Generator.group_sql-1612"><span class="linenos">1612</span></a> <span class="n">cube_sql</span><span class="p">,</span> +</span><span id="Generator.group_sql-1613"><a href="#Generator.group_sql-1613"><span class="linenos">1613</span></a> <span class="n">rollup_sql</span><span class="p">,</span> +</span><span id="Generator.group_sql-1614"><a href="#Generator.group_sql-1614"><span class="linenos">1614</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s2">"WITH TOTALS"</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">"totals"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span><span class="p">,</span> +</span><span id="Generator.group_sql-1615"><a href="#Generator.group_sql-1615"><span class="linenos">1615</span></a> <span class="n">sep</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">GROUPINGS_SEP</span><span class="p">,</span> +</span><span id="Generator.group_sql-1616"><a href="#Generator.group_sql-1616"><span class="linenos">1616</span></a> <span class="p">)</span> +</span><span id="Generator.group_sql-1617"><a href="#Generator.group_sql-1617"><span class="linenos">1617</span></a> +</span><span id="Generator.group_sql-1618"><a href="#Generator.group_sql-1618"><span class="linenos">1618</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">"expressions"</span><span class="p">)</span> <span class="ow">and</span> <span class="n">groupings</span><span class="p">:</span> +</span><span id="Generator.group_sql-1619"><a href="#Generator.group_sql-1619"><span class="linenos">1619</span></a> <span class="n">group_by</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">group_by</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">GROUPINGS_SEP</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.group_sql-1620"><a href="#Generator.group_sql-1620"><span class="linenos">1620</span></a> +</span><span id="Generator.group_sql-1621"><a href="#Generator.group_sql-1621"><span class="linenos">1621</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">group_by</span><span class="si">}{</span><span class="n">groupings</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -10883,9 +10991,9 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.having_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.having_sql-1618"><a href="#Generator.having_sql-1618"><span class="linenos">1618</span></a> <span class="k">def</span> <span class="nf">having_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Having</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.having_sql-1619"><a href="#Generator.having_sql-1619"><span class="linenos">1619</span></a> <span class="n">this</span> <span class="o">=</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><span id="Generator.having_sql-1620"><a href="#Generator.having_sql-1620"><span class="linenos">1620</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="s1">'HAVING'</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="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.having_sql-1623"><a href="#Generator.having_sql-1623"><span class="linenos">1623</span></a> <span class="k">def</span> <span class="nf">having_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Having</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.having_sql-1624"><a href="#Generator.having_sql-1624"><span class="linenos">1624</span></a> <span class="n">this</span> <span class="o">=</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><span id="Generator.having_sql-1625"><a href="#Generator.having_sql-1625"><span class="linenos">1625</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="s1">'HAVING'</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="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -10903,12 +11011,12 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.connect_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.connect_sql-1622"><a href="#Generator.connect_sql-1622"><span class="linenos">1622</span></a> <span class="k">def</span> <span class="nf">connect_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Connect</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.connect_sql-1623"><a href="#Generator.connect_sql-1623"><span class="linenos">1623</span></a> <span class="n">start</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"start"</span><span class="p">)</span> -</span><span id="Generator.connect_sql-1624"><a href="#Generator.connect_sql-1624"><span class="linenos">1624</span></a> <span class="n">start</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="sa">f</span><span class="s2">"START WITH </span><span class="si">{</span><span class="n">start</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> <span class="k">if</span> <span class="n">start</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.connect_sql-1625"><a href="#Generator.connect_sql-1625"><span class="linenos">1625</span></a> <span class="n">connect</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"connect"</span><span class="p">)</span> -</span><span id="Generator.connect_sql-1626"><a href="#Generator.connect_sql-1626"><span class="linenos">1626</span></a> <span class="n">connect</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="sa">f</span><span class="s2">"CONNECT BY </span><span class="si">{</span><span class="n">connect</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="Generator.connect_sql-1627"><a href="#Generator.connect_sql-1627"><span class="linenos">1627</span></a> <span class="k">return</span> <span class="n">start</span> <span class="o">+</span> <span class="n">connect</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.connect_sql-1627"><a href="#Generator.connect_sql-1627"><span class="linenos">1627</span></a> <span class="k">def</span> <span class="nf">connect_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Connect</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.connect_sql-1628"><a href="#Generator.connect_sql-1628"><span class="linenos">1628</span></a> <span class="n">start</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"start"</span><span class="p">)</span> +</span><span id="Generator.connect_sql-1629"><a href="#Generator.connect_sql-1629"><span class="linenos">1629</span></a> <span class="n">start</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="sa">f</span><span class="s2">"START WITH </span><span class="si">{</span><span class="n">start</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> <span class="k">if</span> <span class="n">start</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.connect_sql-1630"><a href="#Generator.connect_sql-1630"><span class="linenos">1630</span></a> <span class="n">connect</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"connect"</span><span class="p">)</span> +</span><span id="Generator.connect_sql-1631"><a href="#Generator.connect_sql-1631"><span class="linenos">1631</span></a> <span class="n">connect</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="sa">f</span><span class="s2">"CONNECT BY </span><span class="si">{</span><span class="n">connect</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="Generator.connect_sql-1632"><a href="#Generator.connect_sql-1632"><span class="linenos">1632</span></a> <span class="k">return</span> <span class="n">start</span> <span class="o">+</span> <span class="n">connect</span> </span></pre></div> @@ -10926,8 +11034,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.prior_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.prior_sql-1629"><a href="#Generator.prior_sql-1629"><span class="linenos">1629</span></a> <span class="k">def</span> <span class="nf">prior_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Prior</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.prior_sql-1630"><a href="#Generator.prior_sql-1630"><span class="linenos">1630</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PRIOR </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.prior_sql-1634"><a href="#Generator.prior_sql-1634"><span class="linenos">1634</span></a> <span class="k">def</span> <span class="nf">prior_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Prior</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.prior_sql-1635"><a href="#Generator.prior_sql-1635"><span class="linenos">1635</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PRIOR </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> @@ -10945,43 +11053,43 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.join_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.join_sql-1632"><a href="#Generator.join_sql-1632"><span class="linenos">1632</span></a> <span class="k">def</span> <span class="nf">join_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Join</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.join_sql-1633"><a href="#Generator.join_sql-1633"><span class="linenos">1633</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">SEMI_ANTI_JOIN_WITH_SIDE</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">kind</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">"SEMI"</span><span class="p">,</span> <span class="s2">"ANTI"</span><span class="p">):</span> -</span><span id="Generator.join_sql-1634"><a href="#Generator.join_sql-1634"><span class="linenos">1634</span></a> <span class="n">side</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Generator.join_sql-1635"><a href="#Generator.join_sql-1635"><span class="linenos">1635</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator.join_sql-1636"><a href="#Generator.join_sql-1636"><span class="linenos">1636</span></a> <span class="n">side</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">side</span> -</span><span id="Generator.join_sql-1637"><a href="#Generator.join_sql-1637"><span class="linenos">1637</span></a> -</span><span id="Generator.join_sql-1638"><a href="#Generator.join_sql-1638"><span class="linenos">1638</span></a> <span class="n">op_sql</span> <span class="o">=</span> <span class="s2">" "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> -</span><span id="Generator.join_sql-1639"><a href="#Generator.join_sql-1639"><span class="linenos">1639</span></a> <span class="n">op</span> -</span><span id="Generator.join_sql-1640"><a href="#Generator.join_sql-1640"><span class="linenos">1640</span></a> <span class="k">for</span> <span class="n">op</span> <span class="ow">in</span> <span class="p">(</span> -</span><span id="Generator.join_sql-1641"><a href="#Generator.join_sql-1641"><span class="linenos">1641</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">method</span><span class="p">,</span> -</span><span id="Generator.join_sql-1642"><a href="#Generator.join_sql-1642"><span class="linenos">1642</span></a> <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">"global"</span><span class="p">)</span> <span class="k">else</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Generator.join_sql-1643"><a href="#Generator.join_sql-1643"><span class="linenos">1643</span></a> <span class="n">side</span><span class="p">,</span> -</span><span id="Generator.join_sql-1644"><a href="#Generator.join_sql-1644"><span class="linenos">1644</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">kind</span><span class="p">,</span> -</span><span id="Generator.join_sql-1645"><a href="#Generator.join_sql-1645"><span class="linenos">1645</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">hint</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">JOIN_HINTS</span> <span class="k">else</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Generator.join_sql-1646"><a href="#Generator.join_sql-1646"><span class="linenos">1646</span></a> <span class="p">)</span> -</span><span id="Generator.join_sql-1647"><a href="#Generator.join_sql-1647"><span class="linenos">1647</span></a> <span class="k">if</span> <span class="n">op</span> -</span><span id="Generator.join_sql-1648"><a href="#Generator.join_sql-1648"><span class="linenos">1648</span></a> <span class="p">)</span> -</span><span id="Generator.join_sql-1649"><a href="#Generator.join_sql-1649"><span class="linenos">1649</span></a> <span class="n">on_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">"on"</span><span class="p">)</span> -</span><span id="Generator.join_sql-1650"><a href="#Generator.join_sql-1650"><span class="linenos">1650</span></a> <span class="n">using</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">"using"</span><span class="p">)</span> -</span><span id="Generator.join_sql-1651"><a href="#Generator.join_sql-1651"><span class="linenos">1651</span></a> -</span><span id="Generator.join_sql-1652"><a href="#Generator.join_sql-1652"><span class="linenos">1652</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">on_sql</span> <span class="ow">and</span> <span class="n">using</span><span class="p">:</span> -</span><span id="Generator.join_sql-1653"><a href="#Generator.join_sql-1653"><span class="linenos">1653</span></a> <span class="n">on_sql</span> <span class="o">=</span> <span class="n">csv</span><span class="p">(</span><span class="o">*</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">column</span><span class="p">)</span> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">using</span><span class="p">))</span> -</span><span id="Generator.join_sql-1654"><a href="#Generator.join_sql-1654"><span class="linenos">1654</span></a> -</span><span id="Generator.join_sql-1655"><a href="#Generator.join_sql-1655"><span class="linenos">1655</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> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.join_sql-1637"><a href="#Generator.join_sql-1637"><span class="linenos">1637</span></a> <span class="k">def</span> <span class="nf">join_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Join</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.join_sql-1638"><a href="#Generator.join_sql-1638"><span class="linenos">1638</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">SEMI_ANTI_JOIN_WITH_SIDE</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">kind</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">"SEMI"</span><span class="p">,</span> <span class="s2">"ANTI"</span><span class="p">):</span> +</span><span id="Generator.join_sql-1639"><a href="#Generator.join_sql-1639"><span class="linenos">1639</span></a> <span class="n">side</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Generator.join_sql-1640"><a href="#Generator.join_sql-1640"><span class="linenos">1640</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator.join_sql-1641"><a href="#Generator.join_sql-1641"><span class="linenos">1641</span></a> <span class="n">side</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">side</span> +</span><span id="Generator.join_sql-1642"><a href="#Generator.join_sql-1642"><span class="linenos">1642</span></a> +</span><span id="Generator.join_sql-1643"><a href="#Generator.join_sql-1643"><span class="linenos">1643</span></a> <span class="n">op_sql</span> <span class="o">=</span> <span class="s2">" "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> +</span><span id="Generator.join_sql-1644"><a href="#Generator.join_sql-1644"><span class="linenos">1644</span></a> <span class="n">op</span> +</span><span id="Generator.join_sql-1645"><a href="#Generator.join_sql-1645"><span class="linenos">1645</span></a> <span class="k">for</span> <span class="n">op</span> <span class="ow">in</span> <span class="p">(</span> +</span><span id="Generator.join_sql-1646"><a href="#Generator.join_sql-1646"><span class="linenos">1646</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">method</span><span class="p">,</span> +</span><span id="Generator.join_sql-1647"><a href="#Generator.join_sql-1647"><span class="linenos">1647</span></a> <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">"global"</span><span class="p">)</span> <span class="k">else</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Generator.join_sql-1648"><a href="#Generator.join_sql-1648"><span class="linenos">1648</span></a> <span class="n">side</span><span class="p">,</span> +</span><span id="Generator.join_sql-1649"><a href="#Generator.join_sql-1649"><span class="linenos">1649</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">kind</span><span class="p">,</span> +</span><span id="Generator.join_sql-1650"><a href="#Generator.join_sql-1650"><span class="linenos">1650</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">hint</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">JOIN_HINTS</span> <span class="k">else</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Generator.join_sql-1651"><a href="#Generator.join_sql-1651"><span class="linenos">1651</span></a> <span class="p">)</span> +</span><span id="Generator.join_sql-1652"><a href="#Generator.join_sql-1652"><span class="linenos">1652</span></a> <span class="k">if</span> <span class="n">op</span> +</span><span id="Generator.join_sql-1653"><a href="#Generator.join_sql-1653"><span class="linenos">1653</span></a> <span class="p">)</span> +</span><span id="Generator.join_sql-1654"><a href="#Generator.join_sql-1654"><span class="linenos">1654</span></a> <span class="n">on_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">"on"</span><span class="p">)</span> +</span><span id="Generator.join_sql-1655"><a href="#Generator.join_sql-1655"><span class="linenos">1655</span></a> <span class="n">using</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">"using"</span><span class="p">)</span> </span><span id="Generator.join_sql-1656"><a href="#Generator.join_sql-1656"><span class="linenos">1656</span></a> -</span><span id="Generator.join_sql-1657"><a href="#Generator.join_sql-1657"><span class="linenos">1657</span></a> <span class="k">if</span> <span class="n">on_sql</span><span class="p">:</span> -</span><span id="Generator.join_sql-1658"><a href="#Generator.join_sql-1658"><span class="linenos">1658</span></a> <span class="n">on_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="n">on_sql</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><span id="Generator.join_sql-1659"><a href="#Generator.join_sql-1659"><span class="linenos">1659</span></a> <span class="n">space</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">" "</span> <span class="o">*</span> <span class="bp">self</span><span class="o">.</span><span class="n">pad</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><span id="Generator.join_sql-1660"><a href="#Generator.join_sql-1660"><span class="linenos">1660</span></a> <span class="k">if</span> <span class="n">using</span><span class="p">:</span> -</span><span id="Generator.join_sql-1661"><a href="#Generator.join_sql-1661"><span class="linenos">1661</span></a> <span class="n">on_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">space</span><span class="si">}</span><span class="s2">USING (</span><span class="si">{</span><span class="n">on_sql</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="Generator.join_sql-1662"><a href="#Generator.join_sql-1662"><span class="linenos">1662</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator.join_sql-1663"><a href="#Generator.join_sql-1663"><span class="linenos">1663</span></a> <span class="n">on_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">space</span><span class="si">}</span><span class="s2">ON </span><span class="si">{</span><span class="n">on_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.join_sql-1664"><a href="#Generator.join_sql-1664"><span class="linenos">1664</span></a> <span class="k">elif</span> <span class="ow">not</span> <span class="n">op_sql</span><span class="p">:</span> -</span><span id="Generator.join_sql-1665"><a href="#Generator.join_sql-1665"><span class="linenos">1665</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">", </span><span class="si">{</span><span class="n">this_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.join_sql-1666"><a href="#Generator.join_sql-1666"><span class="linenos">1666</span></a> -</span><span id="Generator.join_sql-1667"><a href="#Generator.join_sql-1667"><span class="linenos">1667</span></a> <span class="n">op_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">op_sql</span><span class="si">}</span><span class="s2"> JOIN"</span> <span class="k">if</span> <span class="n">op_sql</span> <span class="k">else</span> <span class="s2">"JOIN"</span> -</span><span id="Generator.join_sql-1668"><a href="#Generator.join_sql-1668"><span class="linenos">1668</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_sql</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">this_sql</span><span class="si">}{</span><span class="n">on_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.join_sql-1657"><a href="#Generator.join_sql-1657"><span class="linenos">1657</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">on_sql</span> <span class="ow">and</span> <span class="n">using</span><span class="p">:</span> +</span><span id="Generator.join_sql-1658"><a href="#Generator.join_sql-1658"><span class="linenos">1658</span></a> <span class="n">on_sql</span> <span class="o">=</span> <span class="n">csv</span><span class="p">(</span><span class="o">*</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">column</span><span class="p">)</span> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">using</span><span class="p">))</span> +</span><span id="Generator.join_sql-1659"><a href="#Generator.join_sql-1659"><span class="linenos">1659</span></a> +</span><span id="Generator.join_sql-1660"><a href="#Generator.join_sql-1660"><span class="linenos">1660</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.join_sql-1661"><a href="#Generator.join_sql-1661"><span class="linenos">1661</span></a> +</span><span id="Generator.join_sql-1662"><a href="#Generator.join_sql-1662"><span class="linenos">1662</span></a> <span class="k">if</span> <span class="n">on_sql</span><span class="p">:</span> +</span><span id="Generator.join_sql-1663"><a href="#Generator.join_sql-1663"><span class="linenos">1663</span></a> <span class="n">on_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="n">on_sql</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><span id="Generator.join_sql-1664"><a href="#Generator.join_sql-1664"><span class="linenos">1664</span></a> <span class="n">space</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">" "</span> <span class="o">*</span> <span class="bp">self</span><span class="o">.</span><span class="n">pad</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><span id="Generator.join_sql-1665"><a href="#Generator.join_sql-1665"><span class="linenos">1665</span></a> <span class="k">if</span> <span class="n">using</span><span class="p">:</span> +</span><span id="Generator.join_sql-1666"><a href="#Generator.join_sql-1666"><span class="linenos">1666</span></a> <span class="n">on_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">space</span><span class="si">}</span><span class="s2">USING (</span><span class="si">{</span><span class="n">on_sql</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Generator.join_sql-1667"><a href="#Generator.join_sql-1667"><span class="linenos">1667</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator.join_sql-1668"><a href="#Generator.join_sql-1668"><span class="linenos">1668</span></a> <span class="n">on_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">space</span><span class="si">}</span><span class="s2">ON </span><span class="si">{</span><span class="n">on_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.join_sql-1669"><a href="#Generator.join_sql-1669"><span class="linenos">1669</span></a> <span class="k">elif</span> <span class="ow">not</span> <span class="n">op_sql</span><span class="p">:</span> +</span><span id="Generator.join_sql-1670"><a href="#Generator.join_sql-1670"><span class="linenos">1670</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">", </span><span class="si">{</span><span class="n">this_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.join_sql-1671"><a href="#Generator.join_sql-1671"><span class="linenos">1671</span></a> +</span><span id="Generator.join_sql-1672"><a href="#Generator.join_sql-1672"><span class="linenos">1672</span></a> <span class="n">op_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">op_sql</span><span class="si">}</span><span class="s2"> JOIN"</span> <span class="k">if</span> <span class="n">op_sql</span> <span class="k">else</span> <span class="s2">"JOIN"</span> +</span><span id="Generator.join_sql-1673"><a href="#Generator.join_sql-1673"><span class="linenos">1673</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_sql</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">this_sql</span><span class="si">}{</span><span class="n">on_sql</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -10999,10 +11107,10 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.lambda_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.lambda_sql-1670"><a href="#Generator.lambda_sql-1670"><span class="linenos">1670</span></a> <span class="k">def</span> <span class="nf">lambda_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Lambda</span><span class="p">,</span> <span class="n">arrow_sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"->"</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.lambda_sql-1671"><a href="#Generator.lambda_sql-1671"><span class="linenos">1671</span></a> <span class="n">args</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.lambda_sql-1672"><a href="#Generator.lambda_sql-1672"><span class="linenos">1672</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="n">args</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">args</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">","</span><span class="p">))</span> <span class="o">></span> <span class="mi">1</span> <span class="k">else</span> <span class="n">args</span> -</span><span id="Generator.lambda_sql-1673"><a href="#Generator.lambda_sql-1673"><span class="linenos">1673</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">args</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">arrow_sep</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.lambda_sql-1675"><a href="#Generator.lambda_sql-1675"><span class="linenos">1675</span></a> <span class="k">def</span> <span class="nf">lambda_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Lambda</span><span class="p">,</span> <span class="n">arrow_sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"->"</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.lambda_sql-1676"><a href="#Generator.lambda_sql-1676"><span class="linenos">1676</span></a> <span class="n">args</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.lambda_sql-1677"><a href="#Generator.lambda_sql-1677"><span class="linenos">1677</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="n">args</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">args</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">","</span><span class="p">))</span> <span class="o">></span> <span class="mi">1</span> <span class="k">else</span> <span class="n">args</span> +</span><span id="Generator.lambda_sql-1678"><a href="#Generator.lambda_sql-1678"><span class="linenos">1678</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">args</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">arrow_sep</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> @@ -11020,20 +11128,20 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.lateral_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.lateral_sql-1675"><a href="#Generator.lateral_sql-1675"><span class="linenos">1675</span></a> <span class="k">def</span> <span class="nf">lateral_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Lateral</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.lateral_sql-1676"><a href="#Generator.lateral_sql-1676"><span class="linenos">1676</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.lateral_sql-1677"><a href="#Generator.lateral_sql-1677"><span class="linenos">1677</span></a> -</span><span id="Generator.lateral_sql-1678"><a href="#Generator.lateral_sql-1678"><span class="linenos">1678</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">"view"</span><span class="p">):</span> -</span><span id="Generator.lateral_sql-1679"><a href="#Generator.lateral_sql-1679"><span class="linenos">1679</span></a> <span class="n">alias</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">"alias"</span><span class="p">]</span> -</span><span id="Generator.lateral_sql-1680"><a href="#Generator.lateral_sql-1680"><span class="linenos">1680</span></a> <span class="n">columns</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">alias</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"columns"</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.lateral_sql-1681"><a href="#Generator.lateral_sql-1681"><span class="linenos">1681</span></a> <span class="n">table</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">alias</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alias</span><span class="o">.</span><span class="n">name</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.lateral_sql-1682"><a href="#Generator.lateral_sql-1682"><span class="linenos">1682</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="n">columns</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">columns</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.lateral_sql-1683"><a href="#Generator.lateral_sql-1683"><span class="linenos">1683</span></a> <span class="n">op_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="sa">f</span><span class="s2">"LATERAL VIEW</span><span class="si">{</span><span class="s1">' OUTER'</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">'outer'</span><span class="p">)</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.lateral_sql-1684"><a href="#Generator.lateral_sql-1684"><span class="linenos">1684</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">op_sql</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="n">this</span><span class="si">}{</span><span class="n">table</span><span class="si">}{</span><span class="n">columns</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.lateral_sql-1685"><a href="#Generator.lateral_sql-1685"><span class="linenos">1685</span></a> -</span><span id="Generator.lateral_sql-1686"><a href="#Generator.lateral_sql-1686"><span class="linenos">1686</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.lateral_sql-1687"><a href="#Generator.lateral_sql-1687"><span class="linenos">1687</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.lateral_sql-1688"><a href="#Generator.lateral_sql-1688"><span class="linenos">1688</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"LATERAL </span><span class="si">{</span><span class="n">this</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.lateral_sql-1680"><a href="#Generator.lateral_sql-1680"><span class="linenos">1680</span></a> <span class="k">def</span> <span class="nf">lateral_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Lateral</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.lateral_sql-1681"><a href="#Generator.lateral_sql-1681"><span class="linenos">1681</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.lateral_sql-1682"><a href="#Generator.lateral_sql-1682"><span class="linenos">1682</span></a> +</span><span id="Generator.lateral_sql-1683"><a href="#Generator.lateral_sql-1683"><span class="linenos">1683</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">"view"</span><span class="p">):</span> +</span><span id="Generator.lateral_sql-1684"><a href="#Generator.lateral_sql-1684"><span class="linenos">1684</span></a> <span class="n">alias</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">"alias"</span><span class="p">]</span> +</span><span id="Generator.lateral_sql-1685"><a href="#Generator.lateral_sql-1685"><span class="linenos">1685</span></a> <span class="n">columns</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">alias</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"columns"</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.lateral_sql-1686"><a href="#Generator.lateral_sql-1686"><span class="linenos">1686</span></a> <span class="n">table</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">alias</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alias</span><span class="o">.</span><span class="n">name</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.lateral_sql-1687"><a href="#Generator.lateral_sql-1687"><span class="linenos">1687</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="n">columns</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">columns</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.lateral_sql-1688"><a href="#Generator.lateral_sql-1688"><span class="linenos">1688</span></a> <span class="n">op_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="sa">f</span><span class="s2">"LATERAL VIEW</span><span class="si">{</span><span class="s1">' OUTER'</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">'outer'</span><span class="p">)</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.lateral_sql-1689"><a href="#Generator.lateral_sql-1689"><span class="linenos">1689</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">op_sql</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="n">this</span><span class="si">}{</span><span class="n">table</span><span class="si">}{</span><span class="n">columns</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.lateral_sql-1690"><a href="#Generator.lateral_sql-1690"><span class="linenos">1690</span></a> +</span><span id="Generator.lateral_sql-1691"><a href="#Generator.lateral_sql-1691"><span class="linenos">1691</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.lateral_sql-1692"><a href="#Generator.lateral_sql-1692"><span class="linenos">1692</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.lateral_sql-1693"><a href="#Generator.lateral_sql-1693"><span class="linenos">1693</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"LATERAL </span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -11051,18 +11159,18 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.limit_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.limit_sql-1690"><a href="#Generator.limit_sql-1690"><span class="linenos">1690</span></a> <span class="k">def</span> <span class="nf">limit_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">,</span> <span class="n">top</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.limit_sql-1691"><a href="#Generator.limit_sql-1691"><span class="linenos">1691</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.limit_sql-1692"><a href="#Generator.limit_sql-1692"><span class="linenos">1692</span></a> -</span><span id="Generator.limit_sql-1693"><a href="#Generator.limit_sql-1693"><span class="linenos">1693</span></a> <span class="n">args</span> <span class="o">=</span> <span class="p">[</span> -</span><span id="Generator.limit_sql-1694"><a href="#Generator.limit_sql-1694"><span class="linenos">1694</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_simplify_unless_literal</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">LIMIT_ONLY_LITERALS</span> <span class="k">else</span> <span class="n">e</span> -</span><span id="Generator.limit_sql-1695"><a href="#Generator.limit_sql-1695"><span class="linenos">1695</span></a> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</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">get</span><span class="p">(</span><span class="n">k</span><span class="p">)</span> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">"offset"</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">))</span> -</span><span id="Generator.limit_sql-1696"><a href="#Generator.limit_sql-1696"><span class="linenos">1696</span></a> <span class="k">if</span> <span class="n">e</span> -</span><span id="Generator.limit_sql-1697"><a href="#Generator.limit_sql-1697"><span class="linenos">1697</span></a> <span class="p">]</span> -</span><span id="Generator.limit_sql-1698"><a href="#Generator.limit_sql-1698"><span class="linenos">1698</span></a> -</span><span id="Generator.limit_sql-1699"><a href="#Generator.limit_sql-1699"><span class="linenos">1699</span></a> <span class="n">args_sql</span> <span class="o">=</span> <span class="s2">", "</span><span class="o">.</span><span class="n">join</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">args</span><span class="p">)</span> -</span><span id="Generator.limit_sql-1700"><a href="#Generator.limit_sql-1700"><span class="linenos">1700</span></a> <span class="n">args_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">args_sql</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="nb">any</span><span class="p">(</span><span class="n">top</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">e</span><span class="o">.</span><span class="n">is_number</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">args</span><span class="p">)</span> <span class="k">else</span> <span class="n">args_sql</span> -</span><span id="Generator.limit_sql-1701"><a href="#Generator.limit_sql-1701"><span class="linenos">1701</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="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'TOP'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">top</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">'LIMIT'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">args_sql</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.limit_sql-1695"><a href="#Generator.limit_sql-1695"><span class="linenos">1695</span></a> <span class="k">def</span> <span class="nf">limit_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">,</span> <span class="n">top</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.limit_sql-1696"><a href="#Generator.limit_sql-1696"><span class="linenos">1696</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.limit_sql-1697"><a href="#Generator.limit_sql-1697"><span class="linenos">1697</span></a> +</span><span id="Generator.limit_sql-1698"><a href="#Generator.limit_sql-1698"><span class="linenos">1698</span></a> <span class="n">args</span> <span class="o">=</span> <span class="p">[</span> +</span><span id="Generator.limit_sql-1699"><a href="#Generator.limit_sql-1699"><span class="linenos">1699</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_simplify_unless_literal</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">LIMIT_ONLY_LITERALS</span> <span class="k">else</span> <span class="n">e</span> +</span><span id="Generator.limit_sql-1700"><a href="#Generator.limit_sql-1700"><span class="linenos">1700</span></a> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</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">get</span><span class="p">(</span><span class="n">k</span><span class="p">)</span> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">"offset"</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">))</span> +</span><span id="Generator.limit_sql-1701"><a href="#Generator.limit_sql-1701"><span class="linenos">1701</span></a> <span class="k">if</span> <span class="n">e</span> +</span><span id="Generator.limit_sql-1702"><a href="#Generator.limit_sql-1702"><span class="linenos">1702</span></a> <span class="p">]</span> +</span><span id="Generator.limit_sql-1703"><a href="#Generator.limit_sql-1703"><span class="linenos">1703</span></a> +</span><span id="Generator.limit_sql-1704"><a href="#Generator.limit_sql-1704"><span class="linenos">1704</span></a> <span class="n">args_sql</span> <span class="o">=</span> <span class="s2">", "</span><span class="o">.</span><span class="n">join</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">args</span><span class="p">)</span> +</span><span id="Generator.limit_sql-1705"><a href="#Generator.limit_sql-1705"><span class="linenos">1705</span></a> <span class="n">args_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">args_sql</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="nb">any</span><span class="p">(</span><span class="n">top</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">e</span><span class="o">.</span><span class="n">is_number</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">args</span><span class="p">)</span> <span class="k">else</span> <span class="n">args_sql</span> +</span><span id="Generator.limit_sql-1706"><a href="#Generator.limit_sql-1706"><span class="linenos">1706</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="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'TOP'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">top</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">'LIMIT'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">args_sql</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -11080,13 +11188,13 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.offset_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.offset_sql-1703"><a href="#Generator.offset_sql-1703"><span class="linenos">1703</span></a> <span class="k">def</span> <span class="nf">offset_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Offset</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.offset_sql-1704"><a href="#Generator.offset_sql-1704"><span class="linenos">1704</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.offset_sql-1705"><a href="#Generator.offset_sql-1705"><span class="linenos">1705</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span> -</span><span id="Generator.offset_sql-1706"><a href="#Generator.offset_sql-1706"><span class="linenos">1706</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Generator.offset_sql-1707"><a href="#Generator.offset_sql-1707"><span class="linenos">1707</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_simplify_unless_literal</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">LIMIT_ONLY_LITERALS</span> <span class="k">else</span> <span class="n">expression</span> -</span><span id="Generator.offset_sql-1708"><a href="#Generator.offset_sql-1708"><span class="linenos">1708</span></a> <span class="p">)</span> -</span><span id="Generator.offset_sql-1709"><a href="#Generator.offset_sql-1709"><span class="linenos">1709</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="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'OFFSET'</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="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.offset_sql-1708"><a href="#Generator.offset_sql-1708"><span class="linenos">1708</span></a> <span class="k">def</span> <span class="nf">offset_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Offset</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.offset_sql-1709"><a href="#Generator.offset_sql-1709"><span class="linenos">1709</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.offset_sql-1710"><a href="#Generator.offset_sql-1710"><span class="linenos">1710</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span> +</span><span id="Generator.offset_sql-1711"><a href="#Generator.offset_sql-1711"><span class="linenos">1711</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Generator.offset_sql-1712"><a href="#Generator.offset_sql-1712"><span class="linenos">1712</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_simplify_unless_literal</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">LIMIT_ONLY_LITERALS</span> <span class="k">else</span> <span class="n">expression</span> +</span><span id="Generator.offset_sql-1713"><a href="#Generator.offset_sql-1713"><span class="linenos">1713</span></a> <span class="p">)</span> +</span><span id="Generator.offset_sql-1714"><a href="#Generator.offset_sql-1714"><span class="linenos">1714</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="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'OFFSET'</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="si">}</span><span class="s2">"</span> </span></pre></div> @@ -11104,15 +11212,15 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.setitem_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.setitem_sql-1711"><a href="#Generator.setitem_sql-1711"><span class="linenos">1711</span></a> <span class="k">def</span> <span class="nf">setitem_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SetItem</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.setitem_sql-1712"><a href="#Generator.setitem_sql-1712"><span class="linenos">1712</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.setitem_sql-1713"><a href="#Generator.setitem_sql-1713"><span class="linenos">1713</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.setitem_sql-1714"><a href="#Generator.setitem_sql-1714"><span class="linenos">1714</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.setitem_sql-1715"><a href="#Generator.setitem_sql-1715"><span class="linenos">1715</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.setitem_sql-1716"><a href="#Generator.setitem_sql-1716"><span class="linenos">1716</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.setitem_sql-1717"><a href="#Generator.setitem_sql-1717"><span class="linenos">1717</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.setitem_sql-1718"><a href="#Generator.setitem_sql-1718"><span class="linenos">1718</span></a> <span class="n">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">"global"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.setitem_sql-1719"><a href="#Generator.setitem_sql-1719"><span class="linenos">1719</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">global_</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">expressions</span><span class="si">}{</span><span class="n">collate</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.setitem_sql-1716"><a href="#Generator.setitem_sql-1716"><span class="linenos">1716</span></a> <span class="k">def</span> <span class="nf">setitem_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SetItem</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.setitem_sql-1717"><a href="#Generator.setitem_sql-1717"><span class="linenos">1717</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.setitem_sql-1718"><a href="#Generator.setitem_sql-1718"><span class="linenos">1718</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.setitem_sql-1719"><a href="#Generator.setitem_sql-1719"><span class="linenos">1719</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.setitem_sql-1720"><a href="#Generator.setitem_sql-1720"><span class="linenos">1720</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.setitem_sql-1721"><a href="#Generator.setitem_sql-1721"><span class="linenos">1721</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.setitem_sql-1722"><a href="#Generator.setitem_sql-1722"><span class="linenos">1722</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.setitem_sql-1723"><a href="#Generator.setitem_sql-1723"><span class="linenos">1723</span></a> <span class="n">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">"global"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.setitem_sql-1724"><a href="#Generator.setitem_sql-1724"><span class="linenos">1724</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">global_</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">expressions</span><span class="si">}{</span><span class="n">collate</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -11130,12 +11238,12 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.set_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.set_sql-1721"><a href="#Generator.set_sql-1721"><span class="linenos">1721</span></a> <span class="k">def</span> <span class="nf">set_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Set</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.set_sql-1722"><a href="#Generator.set_sql-1722"><span class="linenos">1722</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Generator.set_sql-1723"><a href="#Generator.set_sql-1723"><span class="linenos">1723</span></a> <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 class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.set_sql-1724"><a href="#Generator.set_sql-1724"><span class="linenos">1724</span></a> <span class="p">)</span> -</span><span id="Generator.set_sql-1725"><a href="#Generator.set_sql-1725"><span class="linenos">1725</span></a> <span class="n">tag</span> <span class="o">=</span> <span class="s2">" TAG"</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">"tag"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.set_sql-1726"><a href="#Generator.set_sql-1726"><span class="linenos">1726</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="s1">'UNSET'</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">'unset'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">'SET'</span><span class="si">}{</span><span class="n">tag</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.set_sql-1726"><a href="#Generator.set_sql-1726"><span class="linenos">1726</span></a> <span class="k">def</span> <span class="nf">set_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Set</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.set_sql-1727"><a href="#Generator.set_sql-1727"><span class="linenos">1727</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Generator.set_sql-1728"><a href="#Generator.set_sql-1728"><span class="linenos">1728</span></a> <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 class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.set_sql-1729"><a href="#Generator.set_sql-1729"><span class="linenos">1729</span></a> <span class="p">)</span> +</span><span id="Generator.set_sql-1730"><a href="#Generator.set_sql-1730"><span class="linenos">1730</span></a> <span class="n">tag</span> <span class="o">=</span> <span class="s2">" TAG"</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">"tag"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.set_sql-1731"><a href="#Generator.set_sql-1731"><span class="linenos">1731</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="s1">'UNSET'</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">'unset'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">'SET'</span><span class="si">}{</span><span class="n">tag</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -11153,8 +11261,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.pragma_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.pragma_sql-1728"><a href="#Generator.pragma_sql-1728"><span class="linenos">1728</span></a> <span class="k">def</span> <span class="nf">pragma_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Pragma</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.pragma_sql-1729"><a href="#Generator.pragma_sql-1729"><span class="linenos">1729</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PRAGMA </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.pragma_sql-1733"><a href="#Generator.pragma_sql-1733"><span class="linenos">1733</span></a> <span class="k">def</span> <span class="nf">pragma_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Pragma</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.pragma_sql-1734"><a href="#Generator.pragma_sql-1734"><span class="linenos">1734</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PRAGMA </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> @@ -11172,23 +11280,23 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.lock_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.lock_sql-1731"><a href="#Generator.lock_sql-1731"><span class="linenos">1731</span></a> <span class="k">def</span> <span class="nf">lock_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Lock</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.lock_sql-1732"><a href="#Generator.lock_sql-1732"><span class="linenos">1732</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">LOCKING_READS_SUPPORTED</span><span class="p">:</span> -</span><span id="Generator.lock_sql-1733"><a href="#Generator.lock_sql-1733"><span class="linenos">1733</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Locking reads using 'FOR UPDATE/SHARE' are not supported"</span><span class="p">)</span> -</span><span id="Generator.lock_sql-1734"><a href="#Generator.lock_sql-1734"><span class="linenos">1734</span></a> <span class="k">return</span> <span class="s2">""</span> -</span><span id="Generator.lock_sql-1735"><a href="#Generator.lock_sql-1735"><span class="linenos">1735</span></a> -</span><span id="Generator.lock_sql-1736"><a href="#Generator.lock_sql-1736"><span class="linenos">1736</span></a> <span class="n">lock_type</span> <span class="o">=</span> <span class="s2">"FOR UPDATE"</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">"update"</span><span class="p">]</span> <span class="k">else</span> <span class="s2">"FOR SHARE"</span> -</span><span id="Generator.lock_sql-1737"><a href="#Generator.lock_sql-1737"><span class="linenos">1737</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.lock_sql-1738"><a href="#Generator.lock_sql-1738"><span class="linenos">1738</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" OF </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.lock_sql-1739"><a href="#Generator.lock_sql-1739"><span class="linenos">1739</span></a> <span class="n">wait</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">"wait"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.lock_sql-1736"><a href="#Generator.lock_sql-1736"><span class="linenos">1736</span></a> <span class="k">def</span> <span class="nf">lock_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Lock</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.lock_sql-1737"><a href="#Generator.lock_sql-1737"><span class="linenos">1737</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">LOCKING_READS_SUPPORTED</span><span class="p">:</span> +</span><span id="Generator.lock_sql-1738"><a href="#Generator.lock_sql-1738"><span class="linenos">1738</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Locking reads using 'FOR UPDATE/SHARE' are not supported"</span><span class="p">)</span> +</span><span id="Generator.lock_sql-1739"><a href="#Generator.lock_sql-1739"><span class="linenos">1739</span></a> <span class="k">return</span> <span class="s2">""</span> </span><span id="Generator.lock_sql-1740"><a href="#Generator.lock_sql-1740"><span class="linenos">1740</span></a> -</span><span id="Generator.lock_sql-1741"><a href="#Generator.lock_sql-1741"><span class="linenos">1741</span></a> <span class="k">if</span> <span class="n">wait</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Generator.lock_sql-1742"><a href="#Generator.lock_sql-1742"><span class="linenos">1742</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">wait</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="p">):</span> -</span><span id="Generator.lock_sql-1743"><a href="#Generator.lock_sql-1743"><span class="linenos">1743</span></a> <span class="n">wait</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" WAIT </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">wait</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.lock_sql-1744"><a href="#Generator.lock_sql-1744"><span class="linenos">1744</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator.lock_sql-1745"><a href="#Generator.lock_sql-1745"><span class="linenos">1745</span></a> <span class="n">wait</span> <span class="o">=</span> <span class="s2">" NOWAIT"</span> <span class="k">if</span> <span class="n">wait</span> <span class="k">else</span> <span class="s2">" SKIP LOCKED"</span> -</span><span id="Generator.lock_sql-1746"><a href="#Generator.lock_sql-1746"><span class="linenos">1746</span></a> -</span><span id="Generator.lock_sql-1747"><a href="#Generator.lock_sql-1747"><span class="linenos">1747</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">lock_type</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}{</span><span class="n">wait</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.lock_sql-1741"><a href="#Generator.lock_sql-1741"><span class="linenos">1741</span></a> <span class="n">lock_type</span> <span class="o">=</span> <span class="s2">"FOR UPDATE"</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">"update"</span><span class="p">]</span> <span class="k">else</span> <span class="s2">"FOR SHARE"</span> +</span><span id="Generator.lock_sql-1742"><a href="#Generator.lock_sql-1742"><span class="linenos">1742</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.lock_sql-1743"><a href="#Generator.lock_sql-1743"><span class="linenos">1743</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" OF </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.lock_sql-1744"><a href="#Generator.lock_sql-1744"><span class="linenos">1744</span></a> <span class="n">wait</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">"wait"</span><span class="p">)</span> +</span><span id="Generator.lock_sql-1745"><a href="#Generator.lock_sql-1745"><span class="linenos">1745</span></a> +</span><span id="Generator.lock_sql-1746"><a href="#Generator.lock_sql-1746"><span class="linenos">1746</span></a> <span class="k">if</span> <span class="n">wait</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Generator.lock_sql-1747"><a href="#Generator.lock_sql-1747"><span class="linenos">1747</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">wait</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="p">):</span> +</span><span id="Generator.lock_sql-1748"><a href="#Generator.lock_sql-1748"><span class="linenos">1748</span></a> <span class="n">wait</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" WAIT </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">wait</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.lock_sql-1749"><a href="#Generator.lock_sql-1749"><span class="linenos">1749</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator.lock_sql-1750"><a href="#Generator.lock_sql-1750"><span class="linenos">1750</span></a> <span class="n">wait</span> <span class="o">=</span> <span class="s2">" NOWAIT"</span> <span class="k">if</span> <span class="n">wait</span> <span class="k">else</span> <span class="s2">" SKIP LOCKED"</span> +</span><span id="Generator.lock_sql-1751"><a href="#Generator.lock_sql-1751"><span class="linenos">1751</span></a> +</span><span id="Generator.lock_sql-1752"><a href="#Generator.lock_sql-1752"><span class="linenos">1752</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">lock_type</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}{</span><span class="n">wait</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> @@ -11206,11 +11314,11 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.literal_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.literal_sql-1749"><a href="#Generator.literal_sql-1749"><span class="linenos">1749</span></a> <span class="k">def</span> <span class="nf">literal_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.literal_sql-1750"><a href="#Generator.literal_sql-1750"><span class="linenos">1750</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="ow">or</span> <span class="s2">""</span> -</span><span id="Generator.literal_sql-1751"><a href="#Generator.literal_sql-1751"><span class="linenos">1751</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">is_string</span><span class="p">:</span> -</span><span id="Generator.literal_sql-1752"><a href="#Generator.literal_sql-1752"><span class="linenos">1752</span></a> <span class="n">text</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">dialect</span><span class="o">.</span><span class="n">QUOTE_START</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">escape_str</span><span class="p">(</span><span class="n">text</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">QUOTE_END</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.literal_sql-1753"><a href="#Generator.literal_sql-1753"><span class="linenos">1753</span></a> <span class="k">return</span> <span class="n">text</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.literal_sql-1754"><a href="#Generator.literal_sql-1754"><span class="linenos">1754</span></a> <span class="k">def</span> <span class="nf">literal_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.literal_sql-1755"><a href="#Generator.literal_sql-1755"><span class="linenos">1755</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="ow">or</span> <span class="s2">""</span> +</span><span id="Generator.literal_sql-1756"><a href="#Generator.literal_sql-1756"><span class="linenos">1756</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">is_string</span><span class="p">:</span> +</span><span id="Generator.literal_sql-1757"><a href="#Generator.literal_sql-1757"><span class="linenos">1757</span></a> <span class="n">text</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">dialect</span><span class="o">.</span><span class="n">QUOTE_START</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">escape_str</span><span class="p">(</span><span class="n">text</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">QUOTE_END</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.literal_sql-1758"><a href="#Generator.literal_sql-1758"><span class="linenos">1758</span></a> <span class="k">return</span> <span class="n">text</span> </span></pre></div> @@ -11228,13 +11336,13 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.escape_str"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.escape_str-1755"><a href="#Generator.escape_str-1755"><span class="linenos">1755</span></a> <span class="k">def</span> <span class="nf">escape_str</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">text</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.escape_str-1756"><a href="#Generator.escape_str-1756"><span class="linenos">1756</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">text</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">QUOTE_END</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_escaped_quote_end</span><span class="p">)</span> -</span><span id="Generator.escape_str-1757"><a href="#Generator.escape_str-1757"><span class="linenos">1757</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">INVERSE_ESCAPE_SEQUENCES</span><span class="p">:</span> -</span><span id="Generator.escape_str-1758"><a href="#Generator.escape_str-1758"><span class="linenos">1758</span></a> <span class="n">text</span> <span class="o">=</span> <span class="s2">""</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">INVERSE_ESCAPE_SEQUENCES</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">ch</span><span class="p">,</span> <span class="n">ch</span><span class="p">)</span> <span class="k">for</span> <span class="n">ch</span> <span class="ow">in</span> <span class="n">text</span><span class="p">)</span> -</span><span id="Generator.escape_str-1759"><a href="#Generator.escape_str-1759"><span class="linenos">1759</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span><span class="p">:</span> -</span><span id="Generator.escape_str-1760"><a href="#Generator.escape_str-1760"><span class="linenos">1760</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">text</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">SENTINEL_LINE_BREAK</span><span class="p">)</span> -</span><span id="Generator.escape_str-1761"><a href="#Generator.escape_str-1761"><span class="linenos">1761</span></a> <span class="k">return</span> <span class="n">text</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.escape_str-1760"><a href="#Generator.escape_str-1760"><span class="linenos">1760</span></a> <span class="k">def</span> <span class="nf">escape_str</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">text</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.escape_str-1761"><a href="#Generator.escape_str-1761"><span class="linenos">1761</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">text</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">QUOTE_END</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_escaped_quote_end</span><span class="p">)</span> +</span><span id="Generator.escape_str-1762"><a href="#Generator.escape_str-1762"><span class="linenos">1762</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">INVERSE_ESCAPE_SEQUENCES</span><span class="p">:</span> +</span><span id="Generator.escape_str-1763"><a href="#Generator.escape_str-1763"><span class="linenos">1763</span></a> <span class="n">text</span> <span class="o">=</span> <span class="s2">""</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">INVERSE_ESCAPE_SEQUENCES</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">ch</span><span class="p">,</span> <span class="n">ch</span><span class="p">)</span> <span class="k">for</span> <span class="n">ch</span> <span class="ow">in</span> <span class="n">text</span><span class="p">)</span> +</span><span id="Generator.escape_str-1764"><a href="#Generator.escape_str-1764"><span class="linenos">1764</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span><span class="p">:</span> +</span><span id="Generator.escape_str-1765"><a href="#Generator.escape_str-1765"><span class="linenos">1765</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">text</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">SENTINEL_LINE_BREAK</span><span class="p">)</span> +</span><span id="Generator.escape_str-1766"><a href="#Generator.escape_str-1766"><span class="linenos">1766</span></a> <span class="k">return</span> <span class="n">text</span> </span></pre></div> @@ -11252,18 +11360,18 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.loaddata_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.loaddata_sql-1763"><a href="#Generator.loaddata_sql-1763"><span class="linenos">1763</span></a> <span class="k">def</span> <span class="nf">loaddata_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">LoadData</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.loaddata_sql-1764"><a href="#Generator.loaddata_sql-1764"><span class="linenos">1764</span></a> <span class="n">local</span> <span class="o">=</span> <span class="s2">" LOCAL"</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">"local"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.loaddata_sql-1765"><a href="#Generator.loaddata_sql-1765"><span class="linenos">1765</span></a> <span class="n">inpath</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" INPATH </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">'inpath'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.loaddata_sql-1766"><a href="#Generator.loaddata_sql-1766"><span class="linenos">1766</span></a> <span class="n">overwrite</span> <span class="o">=</span> <span class="s2">" OVERWRITE"</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">"overwrite"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.loaddata_sql-1767"><a href="#Generator.loaddata_sql-1767"><span class="linenos">1767</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" INTO TABLE </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.loaddata_sql-1768"><a href="#Generator.loaddata_sql-1768"><span class="linenos">1768</span></a> <span class="n">partition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"partition"</span><span class="p">)</span> -</span><span id="Generator.loaddata_sql-1769"><a href="#Generator.loaddata_sql-1769"><span class="linenos">1769</span></a> <span class="n">partition</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">partition</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">partition</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.loaddata_sql-1770"><a href="#Generator.loaddata_sql-1770"><span class="linenos">1770</span></a> <span class="n">input_format</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"input_format"</span><span class="p">)</span> -</span><span id="Generator.loaddata_sql-1771"><a href="#Generator.loaddata_sql-1771"><span class="linenos">1771</span></a> <span class="n">input_format</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" INPUTFORMAT </span><span class="si">{</span><span class="n">input_format</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">input_format</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.loaddata_sql-1772"><a href="#Generator.loaddata_sql-1772"><span class="linenos">1772</span></a> <span class="n">serde</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"serde"</span><span class="p">)</span> -</span><span id="Generator.loaddata_sql-1773"><a href="#Generator.loaddata_sql-1773"><span class="linenos">1773</span></a> <span class="n">serde</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" SERDE </span><span class="si">{</span><span class="n">serde</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">serde</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.loaddata_sql-1774"><a href="#Generator.loaddata_sql-1774"><span class="linenos">1774</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"LOAD DATA</span><span class="si">{</span><span class="n">local</span><span class="si">}{</span><span class="n">inpath</span><span class="si">}{</span><span class="n">overwrite</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="n">partition</span><span class="si">}{</span><span class="n">input_format</span><span class="si">}{</span><span class="n">serde</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.loaddata_sql-1768"><a href="#Generator.loaddata_sql-1768"><span class="linenos">1768</span></a> <span class="k">def</span> <span class="nf">loaddata_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">LoadData</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.loaddata_sql-1769"><a href="#Generator.loaddata_sql-1769"><span class="linenos">1769</span></a> <span class="n">local</span> <span class="o">=</span> <span class="s2">" LOCAL"</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">"local"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.loaddata_sql-1770"><a href="#Generator.loaddata_sql-1770"><span class="linenos">1770</span></a> <span class="n">inpath</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" INPATH </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">'inpath'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.loaddata_sql-1771"><a href="#Generator.loaddata_sql-1771"><span class="linenos">1771</span></a> <span class="n">overwrite</span> <span class="o">=</span> <span class="s2">" OVERWRITE"</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">"overwrite"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.loaddata_sql-1772"><a href="#Generator.loaddata_sql-1772"><span class="linenos">1772</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" INTO TABLE </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.loaddata_sql-1773"><a href="#Generator.loaddata_sql-1773"><span class="linenos">1773</span></a> <span class="n">partition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"partition"</span><span class="p">)</span> +</span><span id="Generator.loaddata_sql-1774"><a href="#Generator.loaddata_sql-1774"><span class="linenos">1774</span></a> <span class="n">partition</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">partition</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">partition</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.loaddata_sql-1775"><a href="#Generator.loaddata_sql-1775"><span class="linenos">1775</span></a> <span class="n">input_format</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"input_format"</span><span class="p">)</span> +</span><span id="Generator.loaddata_sql-1776"><a href="#Generator.loaddata_sql-1776"><span class="linenos">1776</span></a> <span class="n">input_format</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" INPUTFORMAT </span><span class="si">{</span><span class="n">input_format</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">input_format</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.loaddata_sql-1777"><a href="#Generator.loaddata_sql-1777"><span class="linenos">1777</span></a> <span class="n">serde</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"serde"</span><span class="p">)</span> +</span><span id="Generator.loaddata_sql-1778"><a href="#Generator.loaddata_sql-1778"><span class="linenos">1778</span></a> <span class="n">serde</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" SERDE </span><span class="si">{</span><span class="n">serde</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">serde</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.loaddata_sql-1779"><a href="#Generator.loaddata_sql-1779"><span class="linenos">1779</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"LOAD DATA</span><span class="si">{</span><span class="n">local</span><span class="si">}{</span><span class="n">inpath</span><span class="si">}{</span><span class="n">overwrite</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="n">partition</span><span class="si">}{</span><span class="n">input_format</span><span class="si">}{</span><span class="n">serde</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -11281,8 +11389,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.null_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.null_sql-1776"><a href="#Generator.null_sql-1776"><span class="linenos">1776</span></a> <span class="k">def</span> <span class="nf">null_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">_</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.null_sql-1777"><a href="#Generator.null_sql-1777"><span class="linenos">1777</span></a> <span class="k">return</span> <span class="s2">"NULL"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.null_sql-1781"><a href="#Generator.null_sql-1781"><span class="linenos">1781</span></a> <span class="k">def</span> <span class="nf">null_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">_</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.null_sql-1782"><a href="#Generator.null_sql-1782"><span class="linenos">1782</span></a> <span class="k">return</span> <span class="s2">"NULL"</span> </span></pre></div> @@ -11300,8 +11408,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.boolean_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.boolean_sql-1779"><a href="#Generator.boolean_sql-1779"><span class="linenos">1779</span></a> <span class="k">def</span> <span class="nf">boolean_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</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 class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.boolean_sql-1780"><a href="#Generator.boolean_sql-1780"><span class="linenos">1780</span></a> <span class="k">return</span> <span class="s2">"TRUE"</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">"FALSE"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.boolean_sql-1784"><a href="#Generator.boolean_sql-1784"><span class="linenos">1784</span></a> <span class="k">def</span> <span class="nf">boolean_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</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 class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.boolean_sql-1785"><a href="#Generator.boolean_sql-1785"><span class="linenos">1785</span></a> <span class="k">return</span> <span class="s2">"TRUE"</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">"FALSE"</span> </span></pre></div> @@ -11319,10 +11427,10 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.order_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.order_sql-1782"><a href="#Generator.order_sql-1782"><span class="linenos">1782</span></a> <span class="k">def</span> <span class="nf">order_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Order</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.order_sql-1783"><a href="#Generator.order_sql-1783"><span class="linenos">1783</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.order_sql-1784"><a href="#Generator.order_sql-1784"><span class="linenos">1784</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="n">this</span> -</span><span id="Generator.order_sql-1785"><a href="#Generator.order_sql-1785"><span class="linenos">1785</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">op_expressions</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="s2">ORDER BY"</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">this</span> <span class="ow">or</span> <span class="n">flat</span><span class="p">)</span> <span class="c1"># type: ignore</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.order_sql-1787"><a href="#Generator.order_sql-1787"><span class="linenos">1787</span></a> <span class="k">def</span> <span class="nf">order_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Order</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.order_sql-1788"><a href="#Generator.order_sql-1788"><span class="linenos">1788</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.order_sql-1789"><a href="#Generator.order_sql-1789"><span class="linenos">1789</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="n">this</span> +</span><span id="Generator.order_sql-1790"><a href="#Generator.order_sql-1790"><span class="linenos">1790</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">op_expressions</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="s2">ORDER BY"</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">this</span> <span class="ow">or</span> <span class="n">flat</span><span class="p">)</span> <span class="c1"># type: ignore</span> </span></pre></div> @@ -11340,8 +11448,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.cluster_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.cluster_sql-1787"><a href="#Generator.cluster_sql-1787"><span class="linenos">1787</span></a> <span class="k">def</span> <span class="nf">cluster_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cluster</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.cluster_sql-1788"><a href="#Generator.cluster_sql-1788"><span class="linenos">1788</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">op_expressions</span><span class="p">(</span><span class="s2">"CLUSTER BY"</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.cluster_sql-1792"><a href="#Generator.cluster_sql-1792"><span class="linenos">1792</span></a> <span class="k">def</span> <span class="nf">cluster_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cluster</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.cluster_sql-1793"><a href="#Generator.cluster_sql-1793"><span class="linenos">1793</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">op_expressions</span><span class="p">(</span><span class="s2">"CLUSTER BY"</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> </span></pre></div> @@ -11359,8 +11467,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.distribute_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.distribute_sql-1790"><a href="#Generator.distribute_sql-1790"><span class="linenos">1790</span></a> <span class="k">def</span> <span class="nf">distribute_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Distribute</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.distribute_sql-1791"><a href="#Generator.distribute_sql-1791"><span class="linenos">1791</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">op_expressions</span><span class="p">(</span><span class="s2">"DISTRIBUTE BY"</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.distribute_sql-1795"><a href="#Generator.distribute_sql-1795"><span class="linenos">1795</span></a> <span class="k">def</span> <span class="nf">distribute_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Distribute</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.distribute_sql-1796"><a href="#Generator.distribute_sql-1796"><span class="linenos">1796</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">op_expressions</span><span class="p">(</span><span class="s2">"DISTRIBUTE BY"</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> </span></pre></div> @@ -11378,8 +11486,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.sort_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.sort_sql-1793"><a href="#Generator.sort_sql-1793"><span class="linenos">1793</span></a> <span class="k">def</span> <span class="nf">sort_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Sort</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.sort_sql-1794"><a href="#Generator.sort_sql-1794"><span class="linenos">1794</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">op_expressions</span><span class="p">(</span><span class="s2">"SORT BY"</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.sort_sql-1798"><a href="#Generator.sort_sql-1798"><span class="linenos">1798</span></a> <span class="k">def</span> <span class="nf">sort_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Sort</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.sort_sql-1799"><a href="#Generator.sort_sql-1799"><span class="linenos">1799</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">op_expressions</span><span class="p">(</span><span class="s2">"SORT BY"</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> </span></pre></div> @@ -11397,38 +11505,38 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.ordered_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.ordered_sql-1796"><a href="#Generator.ordered_sql-1796"><span class="linenos">1796</span></a> <span class="k">def</span> <span class="nf">ordered_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Ordered</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.ordered_sql-1797"><a href="#Generator.ordered_sql-1797"><span class="linenos">1797</span></a> <span class="n">desc</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">"desc"</span><span class="p">)</span> -</span><span id="Generator.ordered_sql-1798"><a href="#Generator.ordered_sql-1798"><span class="linenos">1798</span></a> <span class="n">asc</span> <span class="o">=</span> <span class="ow">not</span> <span class="n">desc</span> -</span><span id="Generator.ordered_sql-1799"><a href="#Generator.ordered_sql-1799"><span class="linenos">1799</span></a> -</span><span id="Generator.ordered_sql-1800"><a href="#Generator.ordered_sql-1800"><span class="linenos">1800</span></a> <span class="n">nulls_first</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">"nulls_first"</span><span class="p">)</span> -</span><span id="Generator.ordered_sql-1801"><a href="#Generator.ordered_sql-1801"><span class="linenos">1801</span></a> <span class="n">nulls_last</span> <span class="o">=</span> <span class="ow">not</span> <span class="n">nulls_first</span> -</span><span id="Generator.ordered_sql-1802"><a href="#Generator.ordered_sql-1802"><span class="linenos">1802</span></a> <span class="n">nulls_are_large</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">NULL_ORDERING</span> <span class="o">==</span> <span class="s2">"nulls_are_large"</span> -</span><span id="Generator.ordered_sql-1803"><a href="#Generator.ordered_sql-1803"><span class="linenos">1803</span></a> <span class="n">nulls_are_small</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">NULL_ORDERING</span> <span class="o">==</span> <span class="s2">"nulls_are_small"</span> -</span><span id="Generator.ordered_sql-1804"><a href="#Generator.ordered_sql-1804"><span class="linenos">1804</span></a> <span class="n">nulls_are_last</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">NULL_ORDERING</span> <span class="o">==</span> <span class="s2">"nulls_are_last"</span> -</span><span id="Generator.ordered_sql-1805"><a href="#Generator.ordered_sql-1805"><span class="linenos">1805</span></a> -</span><span id="Generator.ordered_sql-1806"><a href="#Generator.ordered_sql-1806"><span class="linenos">1806</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.ordered_sql-1807"><a href="#Generator.ordered_sql-1807"><span class="linenos">1807</span></a> -</span><span id="Generator.ordered_sql-1808"><a href="#Generator.ordered_sql-1808"><span class="linenos">1808</span></a> <span class="n">sort_order</span> <span class="o">=</span> <span class="s2">" DESC"</span> <span class="k">if</span> <span class="n">desc</span> <span class="k">else</span> <span class="p">(</span><span class="s2">" ASC"</span> <span class="k">if</span> <span class="n">desc</span> <span class="ow">is</span> <span class="kc">False</span> <span class="k">else</span> <span class="s2">""</span><span class="p">)</span> -</span><span id="Generator.ordered_sql-1809"><a href="#Generator.ordered_sql-1809"><span class="linenos">1809</span></a> <span class="n">nulls_sort_change</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator.ordered_sql-1810"><a href="#Generator.ordered_sql-1810"><span class="linenos">1810</span></a> <span class="k">if</span> <span class="n">nulls_first</span> <span class="ow">and</span> <span class="p">(</span> -</span><span id="Generator.ordered_sql-1811"><a href="#Generator.ordered_sql-1811"><span class="linenos">1811</span></a> <span class="p">(</span><span class="n">asc</span> <span class="ow">and</span> <span class="n">nulls_are_large</span><span class="p">)</span> <span class="ow">or</span> <span class="p">(</span><span class="n">desc</span> <span class="ow">and</span> <span class="n">nulls_are_small</span><span class="p">)</span> <span class="ow">or</span> <span class="n">nulls_are_last</span> -</span><span id="Generator.ordered_sql-1812"><a href="#Generator.ordered_sql-1812"><span class="linenos">1812</span></a> <span class="p">):</span> -</span><span id="Generator.ordered_sql-1813"><a href="#Generator.ordered_sql-1813"><span class="linenos">1813</span></a> <span class="n">nulls_sort_change</span> <span class="o">=</span> <span class="s2">" NULLS FIRST"</span> -</span><span id="Generator.ordered_sql-1814"><a href="#Generator.ordered_sql-1814"><span class="linenos">1814</span></a> <span class="k">elif</span> <span class="p">(</span> -</span><span id="Generator.ordered_sql-1815"><a href="#Generator.ordered_sql-1815"><span class="linenos">1815</span></a> <span class="n">nulls_last</span> -</span><span id="Generator.ordered_sql-1816"><a href="#Generator.ordered_sql-1816"><span class="linenos">1816</span></a> <span class="ow">and</span> <span class="p">((</span><span class="n">asc</span> <span class="ow">and</span> <span class="n">nulls_are_small</span><span class="p">)</span> <span class="ow">or</span> <span class="p">(</span><span class="n">desc</span> <span class="ow">and</span> <span class="n">nulls_are_large</span><span class="p">))</span> -</span><span id="Generator.ordered_sql-1817"><a href="#Generator.ordered_sql-1817"><span class="linenos">1817</span></a> <span class="ow">and</span> <span class="ow">not</span> <span class="n">nulls_are_last</span> -</span><span id="Generator.ordered_sql-1818"><a href="#Generator.ordered_sql-1818"><span class="linenos">1818</span></a> <span class="p">):</span> -</span><span id="Generator.ordered_sql-1819"><a href="#Generator.ordered_sql-1819"><span class="linenos">1819</span></a> <span class="n">nulls_sort_change</span> <span class="o">=</span> <span class="s2">" NULLS LAST"</span> -</span><span id="Generator.ordered_sql-1820"><a href="#Generator.ordered_sql-1820"><span class="linenos">1820</span></a> -</span><span id="Generator.ordered_sql-1821"><a href="#Generator.ordered_sql-1821"><span class="linenos">1821</span></a> <span class="c1"># If the NULLS FIRST/LAST clause is unsupported, we add another sort key to simulate it</span> -</span><span id="Generator.ordered_sql-1822"><a href="#Generator.ordered_sql-1822"><span class="linenos">1822</span></a> <span class="k">if</span> <span class="n">nulls_sort_change</span> <span class="ow">and</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">NULL_ORDERING_SUPPORTED</span><span class="p">:</span> -</span><span id="Generator.ordered_sql-1823"><a href="#Generator.ordered_sql-1823"><span class="linenos">1823</span></a> <span class="n">null_sort_order</span> <span class="o">=</span> <span class="s2">" DESC"</span> <span class="k">if</span> <span class="n">nulls_sort_change</span> <span class="o">==</span> <span class="s2">" NULLS FIRST"</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.ordered_sql-1824"><a href="#Generator.ordered_sql-1824"><span class="linenos">1824</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"CASE WHEN </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> IS NULL THEN 1 ELSE 0 END</span><span class="si">{</span><span class="n">null_sort_order</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">"</span> -</span><span id="Generator.ordered_sql-1825"><a href="#Generator.ordered_sql-1825"><span class="linenos">1825</span></a> <span class="n">nulls_sort_change</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator.ordered_sql-1826"><a href="#Generator.ordered_sql-1826"><span class="linenos">1826</span></a> -</span><span id="Generator.ordered_sql-1827"><a href="#Generator.ordered_sql-1827"><span class="linenos">1827</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">sort_order</span><span class="si">}{</span><span class="n">nulls_sort_change</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.ordered_sql-1801"><a href="#Generator.ordered_sql-1801"><span class="linenos">1801</span></a> <span class="k">def</span> <span class="nf">ordered_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Ordered</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.ordered_sql-1802"><a href="#Generator.ordered_sql-1802"><span class="linenos">1802</span></a> <span class="n">desc</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">"desc"</span><span class="p">)</span> +</span><span id="Generator.ordered_sql-1803"><a href="#Generator.ordered_sql-1803"><span class="linenos">1803</span></a> <span class="n">asc</span> <span class="o">=</span> <span class="ow">not</span> <span class="n">desc</span> +</span><span id="Generator.ordered_sql-1804"><a href="#Generator.ordered_sql-1804"><span class="linenos">1804</span></a> +</span><span id="Generator.ordered_sql-1805"><a href="#Generator.ordered_sql-1805"><span class="linenos">1805</span></a> <span class="n">nulls_first</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">"nulls_first"</span><span class="p">)</span> +</span><span id="Generator.ordered_sql-1806"><a href="#Generator.ordered_sql-1806"><span class="linenos">1806</span></a> <span class="n">nulls_last</span> <span class="o">=</span> <span class="ow">not</span> <span class="n">nulls_first</span> +</span><span id="Generator.ordered_sql-1807"><a href="#Generator.ordered_sql-1807"><span class="linenos">1807</span></a> <span class="n">nulls_are_large</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">NULL_ORDERING</span> <span class="o">==</span> <span class="s2">"nulls_are_large"</span> +</span><span id="Generator.ordered_sql-1808"><a href="#Generator.ordered_sql-1808"><span class="linenos">1808</span></a> <span class="n">nulls_are_small</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">NULL_ORDERING</span> <span class="o">==</span> <span class="s2">"nulls_are_small"</span> +</span><span id="Generator.ordered_sql-1809"><a href="#Generator.ordered_sql-1809"><span class="linenos">1809</span></a> <span class="n">nulls_are_last</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">NULL_ORDERING</span> <span class="o">==</span> <span class="s2">"nulls_are_last"</span> +</span><span id="Generator.ordered_sql-1810"><a href="#Generator.ordered_sql-1810"><span class="linenos">1810</span></a> +</span><span id="Generator.ordered_sql-1811"><a href="#Generator.ordered_sql-1811"><span class="linenos">1811</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.ordered_sql-1812"><a href="#Generator.ordered_sql-1812"><span class="linenos">1812</span></a> +</span><span id="Generator.ordered_sql-1813"><a href="#Generator.ordered_sql-1813"><span class="linenos">1813</span></a> <span class="n">sort_order</span> <span class="o">=</span> <span class="s2">" DESC"</span> <span class="k">if</span> <span class="n">desc</span> <span class="k">else</span> <span class="p">(</span><span class="s2">" ASC"</span> <span class="k">if</span> <span class="n">desc</span> <span class="ow">is</span> <span class="kc">False</span> <span class="k">else</span> <span class="s2">""</span><span class="p">)</span> +</span><span id="Generator.ordered_sql-1814"><a href="#Generator.ordered_sql-1814"><span class="linenos">1814</span></a> <span class="n">nulls_sort_change</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator.ordered_sql-1815"><a href="#Generator.ordered_sql-1815"><span class="linenos">1815</span></a> <span class="k">if</span> <span class="n">nulls_first</span> <span class="ow">and</span> <span class="p">(</span> +</span><span id="Generator.ordered_sql-1816"><a href="#Generator.ordered_sql-1816"><span class="linenos">1816</span></a> <span class="p">(</span><span class="n">asc</span> <span class="ow">and</span> <span class="n">nulls_are_large</span><span class="p">)</span> <span class="ow">or</span> <span class="p">(</span><span class="n">desc</span> <span class="ow">and</span> <span class="n">nulls_are_small</span><span class="p">)</span> <span class="ow">or</span> <span class="n">nulls_are_last</span> +</span><span id="Generator.ordered_sql-1817"><a href="#Generator.ordered_sql-1817"><span class="linenos">1817</span></a> <span class="p">):</span> +</span><span id="Generator.ordered_sql-1818"><a href="#Generator.ordered_sql-1818"><span class="linenos">1818</span></a> <span class="n">nulls_sort_change</span> <span class="o">=</span> <span class="s2">" NULLS FIRST"</span> +</span><span id="Generator.ordered_sql-1819"><a href="#Generator.ordered_sql-1819"><span class="linenos">1819</span></a> <span class="k">elif</span> <span class="p">(</span> +</span><span id="Generator.ordered_sql-1820"><a href="#Generator.ordered_sql-1820"><span class="linenos">1820</span></a> <span class="n">nulls_last</span> +</span><span id="Generator.ordered_sql-1821"><a href="#Generator.ordered_sql-1821"><span class="linenos">1821</span></a> <span class="ow">and</span> <span class="p">((</span><span class="n">asc</span> <span class="ow">and</span> <span class="n">nulls_are_small</span><span class="p">)</span> <span class="ow">or</span> <span class="p">(</span><span class="n">desc</span> <span class="ow">and</span> <span class="n">nulls_are_large</span><span class="p">))</span> +</span><span id="Generator.ordered_sql-1822"><a href="#Generator.ordered_sql-1822"><span class="linenos">1822</span></a> <span class="ow">and</span> <span class="ow">not</span> <span class="n">nulls_are_last</span> +</span><span id="Generator.ordered_sql-1823"><a href="#Generator.ordered_sql-1823"><span class="linenos">1823</span></a> <span class="p">):</span> +</span><span id="Generator.ordered_sql-1824"><a href="#Generator.ordered_sql-1824"><span class="linenos">1824</span></a> <span class="n">nulls_sort_change</span> <span class="o">=</span> <span class="s2">" NULLS LAST"</span> +</span><span id="Generator.ordered_sql-1825"><a href="#Generator.ordered_sql-1825"><span class="linenos">1825</span></a> +</span><span id="Generator.ordered_sql-1826"><a href="#Generator.ordered_sql-1826"><span class="linenos">1826</span></a> <span class="c1"># If the NULLS FIRST/LAST clause is unsupported, we add another sort key to simulate it</span> +</span><span id="Generator.ordered_sql-1827"><a href="#Generator.ordered_sql-1827"><span class="linenos">1827</span></a> <span class="k">if</span> <span class="n">nulls_sort_change</span> <span class="ow">and</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">NULL_ORDERING_SUPPORTED</span><span class="p">:</span> +</span><span id="Generator.ordered_sql-1828"><a href="#Generator.ordered_sql-1828"><span class="linenos">1828</span></a> <span class="n">null_sort_order</span> <span class="o">=</span> <span class="s2">" DESC"</span> <span class="k">if</span> <span class="n">nulls_sort_change</span> <span class="o">==</span> <span class="s2">" NULLS FIRST"</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.ordered_sql-1829"><a href="#Generator.ordered_sql-1829"><span class="linenos">1829</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"CASE WHEN </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> IS NULL THEN 1 ELSE 0 END</span><span class="si">{</span><span class="n">null_sort_order</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">"</span> +</span><span id="Generator.ordered_sql-1830"><a href="#Generator.ordered_sql-1830"><span class="linenos">1830</span></a> <span class="n">nulls_sort_change</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator.ordered_sql-1831"><a href="#Generator.ordered_sql-1831"><span class="linenos">1831</span></a> +</span><span id="Generator.ordered_sql-1832"><a href="#Generator.ordered_sql-1832"><span class="linenos">1832</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">sort_order</span><span class="si">}{</span><span class="n">nulls_sort_change</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -11446,37 +11554,37 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.matchrecognize_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.matchrecognize_sql-1829"><a href="#Generator.matchrecognize_sql-1829"><span class="linenos">1829</span></a> <span class="k">def</span> <span class="nf">matchrecognize_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">MatchRecognize</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.matchrecognize_sql-1830"><a href="#Generator.matchrecognize_sql-1830"><span class="linenos">1830</span></a> <span class="n">partition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">partition_by_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Generator.matchrecognize_sql-1831"><a href="#Generator.matchrecognize_sql-1831"><span class="linenos">1831</span></a> <span class="n">order</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"order"</span><span class="p">)</span> -</span><span id="Generator.matchrecognize_sql-1832"><a href="#Generator.matchrecognize_sql-1832"><span class="linenos">1832</span></a> <span class="n">measures</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">"measures"</span><span class="p">)</span> -</span><span id="Generator.matchrecognize_sql-1833"><a href="#Generator.matchrecognize_sql-1833"><span class="linenos">1833</span></a> <span class="n">measures</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="sa">f</span><span class="s2">"MEASURES</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">measures</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> <span class="k">if</span> <span class="n">measures</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.matchrecognize_sql-1834"><a href="#Generator.matchrecognize_sql-1834"><span class="linenos">1834</span></a> <span class="n">rows</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"rows"</span><span class="p">)</span> -</span><span id="Generator.matchrecognize_sql-1835"><a href="#Generator.matchrecognize_sql-1835"><span class="linenos">1835</span></a> <span class="n">rows</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">rows</span><span class="p">)</span> <span class="k">if</span> <span class="n">rows</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.matchrecognize_sql-1836"><a href="#Generator.matchrecognize_sql-1836"><span class="linenos">1836</span></a> <span class="n">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">"after"</span><span class="p">)</span> -</span><span id="Generator.matchrecognize_sql-1837"><a href="#Generator.matchrecognize_sql-1837"><span class="linenos">1837</span></a> <span class="n">after</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">after</span><span class="p">)</span> <span class="k">if</span> <span class="n">after</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.matchrecognize_sql-1838"><a href="#Generator.matchrecognize_sql-1838"><span class="linenos">1838</span></a> <span class="n">pattern</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"pattern"</span><span class="p">)</span> -</span><span id="Generator.matchrecognize_sql-1839"><a href="#Generator.matchrecognize_sql-1839"><span class="linenos">1839</span></a> <span class="n">pattern</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="sa">f</span><span class="s2">"PATTERN (</span><span class="si">{</span><span class="n">pattern</span><span class="si">}</span><span class="s2">)"</span><span class="p">)</span> <span class="k">if</span> <span class="n">pattern</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.matchrecognize_sql-1840"><a href="#Generator.matchrecognize_sql-1840"><span class="linenos">1840</span></a> <span class="n">definition_sqls</span> <span class="o">=</span> <span class="p">[</span> -</span><span id="Generator.matchrecognize_sql-1841"><a href="#Generator.matchrecognize_sql-1841"><span class="linenos">1841</span></a> <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">definition</span><span class="p">,</span><span class="w"> </span><span class="s1">'alias'</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">definition</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.matchrecognize_sql-1842"><a href="#Generator.matchrecognize_sql-1842"><span class="linenos">1842</span></a> <span class="k">for</span> <span class="n">definition</span> <span class="ow">in</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">"define"</span><span class="p">,</span> <span class="p">[])</span> -</span><span id="Generator.matchrecognize_sql-1843"><a href="#Generator.matchrecognize_sql-1843"><span class="linenos">1843</span></a> <span class="p">]</span> -</span><span id="Generator.matchrecognize_sql-1844"><a href="#Generator.matchrecognize_sql-1844"><span class="linenos">1844</span></a> <span class="n">definitions</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">sqls</span><span class="o">=</span><span class="n">definition_sqls</span><span class="p">)</span> -</span><span id="Generator.matchrecognize_sql-1845"><a href="#Generator.matchrecognize_sql-1845"><span class="linenos">1845</span></a> <span class="n">define</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="sa">f</span><span class="s2">"DEFINE</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">definitions</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> <span class="k">if</span> <span class="n">definitions</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.matchrecognize_sql-1846"><a href="#Generator.matchrecognize_sql-1846"><span class="linenos">1846</span></a> <span class="n">body</span> <span class="o">=</span> <span class="s2">""</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> -</span><span id="Generator.matchrecognize_sql-1847"><a href="#Generator.matchrecognize_sql-1847"><span class="linenos">1847</span></a> <span class="p">(</span> -</span><span id="Generator.matchrecognize_sql-1848"><a href="#Generator.matchrecognize_sql-1848"><span class="linenos">1848</span></a> <span class="n">partition</span><span class="p">,</span> -</span><span id="Generator.matchrecognize_sql-1849"><a href="#Generator.matchrecognize_sql-1849"><span class="linenos">1849</span></a> <span class="n">order</span><span class="p">,</span> -</span><span id="Generator.matchrecognize_sql-1850"><a href="#Generator.matchrecognize_sql-1850"><span class="linenos">1850</span></a> <span class="n">measures</span><span class="p">,</span> -</span><span id="Generator.matchrecognize_sql-1851"><a href="#Generator.matchrecognize_sql-1851"><span class="linenos">1851</span></a> <span class="n">rows</span><span class="p">,</span> -</span><span id="Generator.matchrecognize_sql-1852"><a href="#Generator.matchrecognize_sql-1852"><span class="linenos">1852</span></a> <span class="n">after</span><span class="p">,</span> -</span><span id="Generator.matchrecognize_sql-1853"><a href="#Generator.matchrecognize_sql-1853"><span class="linenos">1853</span></a> <span class="n">pattern</span><span class="p">,</span> -</span><span id="Generator.matchrecognize_sql-1854"><a href="#Generator.matchrecognize_sql-1854"><span class="linenos">1854</span></a> <span class="n">define</span><span class="p">,</span> -</span><span id="Generator.matchrecognize_sql-1855"><a href="#Generator.matchrecognize_sql-1855"><span class="linenos">1855</span></a> <span class="p">)</span> -</span><span id="Generator.matchrecognize_sql-1856"><a href="#Generator.matchrecognize_sql-1856"><span class="linenos">1856</span></a> <span class="p">)</span> -</span><span id="Generator.matchrecognize_sql-1857"><a href="#Generator.matchrecognize_sql-1857"><span class="linenos">1857</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.matchrecognize_sql-1858"><a href="#Generator.matchrecognize_sql-1858"><span class="linenos">1858</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </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.matchrecognize_sql-1859"><a href="#Generator.matchrecognize_sql-1859"><span class="linenos">1859</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="s1">'MATCH_RECOGNIZE'</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">wrap</span><span class="p">(</span><span class="n">body</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.matchrecognize_sql-1834"><a href="#Generator.matchrecognize_sql-1834"><span class="linenos">1834</span></a> <span class="k">def</span> <span class="nf">matchrecognize_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">MatchRecognize</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.matchrecognize_sql-1835"><a href="#Generator.matchrecognize_sql-1835"><span class="linenos">1835</span></a> <span class="n">partition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">partition_by_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Generator.matchrecognize_sql-1836"><a href="#Generator.matchrecognize_sql-1836"><span class="linenos">1836</span></a> <span class="n">order</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"order"</span><span class="p">)</span> +</span><span id="Generator.matchrecognize_sql-1837"><a href="#Generator.matchrecognize_sql-1837"><span class="linenos">1837</span></a> <span class="n">measures</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">"measures"</span><span class="p">)</span> +</span><span id="Generator.matchrecognize_sql-1838"><a href="#Generator.matchrecognize_sql-1838"><span class="linenos">1838</span></a> <span class="n">measures</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="sa">f</span><span class="s2">"MEASURES</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">measures</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> <span class="k">if</span> <span class="n">measures</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.matchrecognize_sql-1839"><a href="#Generator.matchrecognize_sql-1839"><span class="linenos">1839</span></a> <span class="n">rows</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"rows"</span><span class="p">)</span> +</span><span id="Generator.matchrecognize_sql-1840"><a href="#Generator.matchrecognize_sql-1840"><span class="linenos">1840</span></a> <span class="n">rows</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">rows</span><span class="p">)</span> <span class="k">if</span> <span class="n">rows</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.matchrecognize_sql-1841"><a href="#Generator.matchrecognize_sql-1841"><span class="linenos">1841</span></a> <span class="n">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">"after"</span><span class="p">)</span> +</span><span id="Generator.matchrecognize_sql-1842"><a href="#Generator.matchrecognize_sql-1842"><span class="linenos">1842</span></a> <span class="n">after</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">after</span><span class="p">)</span> <span class="k">if</span> <span class="n">after</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.matchrecognize_sql-1843"><a href="#Generator.matchrecognize_sql-1843"><span class="linenos">1843</span></a> <span class="n">pattern</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"pattern"</span><span class="p">)</span> +</span><span id="Generator.matchrecognize_sql-1844"><a href="#Generator.matchrecognize_sql-1844"><span class="linenos">1844</span></a> <span class="n">pattern</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="sa">f</span><span class="s2">"PATTERN (</span><span class="si">{</span><span class="n">pattern</span><span class="si">}</span><span class="s2">)"</span><span class="p">)</span> <span class="k">if</span> <span class="n">pattern</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.matchrecognize_sql-1845"><a href="#Generator.matchrecognize_sql-1845"><span class="linenos">1845</span></a> <span class="n">definition_sqls</span> <span class="o">=</span> <span class="p">[</span> +</span><span id="Generator.matchrecognize_sql-1846"><a href="#Generator.matchrecognize_sql-1846"><span class="linenos">1846</span></a> <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">definition</span><span class="p">,</span><span class="w"> </span><span class="s1">'alias'</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">definition</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.matchrecognize_sql-1847"><a href="#Generator.matchrecognize_sql-1847"><span class="linenos">1847</span></a> <span class="k">for</span> <span class="n">definition</span> <span class="ow">in</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">"define"</span><span class="p">,</span> <span class="p">[])</span> +</span><span id="Generator.matchrecognize_sql-1848"><a href="#Generator.matchrecognize_sql-1848"><span class="linenos">1848</span></a> <span class="p">]</span> +</span><span id="Generator.matchrecognize_sql-1849"><a href="#Generator.matchrecognize_sql-1849"><span class="linenos">1849</span></a> <span class="n">definitions</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">sqls</span><span class="o">=</span><span class="n">definition_sqls</span><span class="p">)</span> +</span><span id="Generator.matchrecognize_sql-1850"><a href="#Generator.matchrecognize_sql-1850"><span class="linenos">1850</span></a> <span class="n">define</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="sa">f</span><span class="s2">"DEFINE</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">definitions</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> <span class="k">if</span> <span class="n">definitions</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.matchrecognize_sql-1851"><a href="#Generator.matchrecognize_sql-1851"><span class="linenos">1851</span></a> <span class="n">body</span> <span class="o">=</span> <span class="s2">""</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> +</span><span id="Generator.matchrecognize_sql-1852"><a href="#Generator.matchrecognize_sql-1852"><span class="linenos">1852</span></a> <span class="p">(</span> +</span><span id="Generator.matchrecognize_sql-1853"><a href="#Generator.matchrecognize_sql-1853"><span class="linenos">1853</span></a> <span class="n">partition</span><span class="p">,</span> +</span><span id="Generator.matchrecognize_sql-1854"><a href="#Generator.matchrecognize_sql-1854"><span class="linenos">1854</span></a> <span class="n">order</span><span class="p">,</span> +</span><span id="Generator.matchrecognize_sql-1855"><a href="#Generator.matchrecognize_sql-1855"><span class="linenos">1855</span></a> <span class="n">measures</span><span class="p">,</span> +</span><span id="Generator.matchrecognize_sql-1856"><a href="#Generator.matchrecognize_sql-1856"><span class="linenos">1856</span></a> <span class="n">rows</span><span class="p">,</span> +</span><span id="Generator.matchrecognize_sql-1857"><a href="#Generator.matchrecognize_sql-1857"><span class="linenos">1857</span></a> <span class="n">after</span><span class="p">,</span> +</span><span id="Generator.matchrecognize_sql-1858"><a href="#Generator.matchrecognize_sql-1858"><span class="linenos">1858</span></a> <span class="n">pattern</span><span class="p">,</span> +</span><span id="Generator.matchrecognize_sql-1859"><a href="#Generator.matchrecognize_sql-1859"><span class="linenos">1859</span></a> <span class="n">define</span><span class="p">,</span> +</span><span id="Generator.matchrecognize_sql-1860"><a href="#Generator.matchrecognize_sql-1860"><span class="linenos">1860</span></a> <span class="p">)</span> +</span><span id="Generator.matchrecognize_sql-1861"><a href="#Generator.matchrecognize_sql-1861"><span class="linenos">1861</span></a> <span class="p">)</span> +</span><span id="Generator.matchrecognize_sql-1862"><a href="#Generator.matchrecognize_sql-1862"><span class="linenos">1862</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.matchrecognize_sql-1863"><a href="#Generator.matchrecognize_sql-1863"><span class="linenos">1863</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </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.matchrecognize_sql-1864"><a href="#Generator.matchrecognize_sql-1864"><span class="linenos">1864</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="s1">'MATCH_RECOGNIZE'</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">wrap</span><span class="p">(</span><span class="n">body</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> @@ -11494,40 +11602,40 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.query_modifiers"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.query_modifiers-1861"><a href="#Generator.query_modifiers-1861"><span class="linenos">1861</span></a> <span class="k">def</span> <span class="nf">query_modifiers</span><span class="p">(</span><span class="bp">self</span><span 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">sqls</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.query_modifiers-1862"><a href="#Generator.query_modifiers-1862"><span class="linenos">1862</span></a> <span class="n">limit</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">Fetch</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">]</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">"limit"</span><span class="p">)</span> -</span><span id="Generator.query_modifiers-1863"><a href="#Generator.query_modifiers-1863"><span class="linenos">1863</span></a> -</span><span id="Generator.query_modifiers-1864"><a href="#Generator.query_modifiers-1864"><span class="linenos">1864</span></a> <span class="c1"># If the limit is generated as TOP, we need to ensure it's not generated twice</span> -</span><span id="Generator.query_modifiers-1865"><a href="#Generator.query_modifiers-1865"><span class="linenos">1865</span></a> <span class="n">with_offset_limit_modifiers</span> <span class="o">=</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">limit</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">)</span> <span class="ow">or</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">LIMIT_IS_TOP</span> -</span><span id="Generator.query_modifiers-1866"><a href="#Generator.query_modifiers-1866"><span class="linenos">1866</span></a> -</span><span id="Generator.query_modifiers-1867"><a href="#Generator.query_modifiers-1867"><span class="linenos">1867</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">LIMIT_FETCH</span> <span class="o">==</span> <span class="s2">"LIMIT"</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">limit</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span><span class="p">):</span> -</span><span id="Generator.query_modifiers-1868"><a href="#Generator.query_modifiers-1868"><span class="linenos">1868</span></a> <span class="n">limit</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">(</span><span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">maybe_copy</span><span class="p">(</span><span class="n">limit</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">"count"</span><span class="p">)))</span> -</span><span id="Generator.query_modifiers-1869"><a href="#Generator.query_modifiers-1869"><span class="linenos">1869</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">LIMIT_FETCH</span> <span class="o">==</span> <span class="s2">"FETCH"</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">limit</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">):</span> -</span><span id="Generator.query_modifiers-1870"><a href="#Generator.query_modifiers-1870"><span class="linenos">1870</span></a> <span class="n">limit</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span><span class="p">(</span><span class="n">direction</span><span class="o">=</span><span class="s2">"FIRST"</span><span class="p">,</span> <span class="n">count</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">maybe_copy</span><span class="p">(</span><span class="n">limit</span><span class="o">.</span><span class="n">expression</span><span class="p">))</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.query_modifiers-1866"><a href="#Generator.query_modifiers-1866"><span class="linenos">1866</span></a> <span class="k">def</span> <span class="nf">query_modifiers</span><span class="p">(</span><span class="bp">self</span><span 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">sqls</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.query_modifiers-1867"><a href="#Generator.query_modifiers-1867"><span class="linenos">1867</span></a> <span class="n">limit</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">Fetch</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">]</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">"limit"</span><span class="p">)</span> +</span><span id="Generator.query_modifiers-1868"><a href="#Generator.query_modifiers-1868"><span class="linenos">1868</span></a> +</span><span id="Generator.query_modifiers-1869"><a href="#Generator.query_modifiers-1869"><span class="linenos">1869</span></a> <span class="c1"># If the limit is generated as TOP, we need to ensure it's not generated twice</span> +</span><span id="Generator.query_modifiers-1870"><a href="#Generator.query_modifiers-1870"><span class="linenos">1870</span></a> <span class="n">with_offset_limit_modifiers</span> <span class="o">=</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">limit</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">)</span> <span class="ow">or</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">LIMIT_IS_TOP</span> </span><span id="Generator.query_modifiers-1871"><a href="#Generator.query_modifiers-1871"><span class="linenos">1871</span></a> -</span><span id="Generator.query_modifiers-1872"><a href="#Generator.query_modifiers-1872"><span class="linenos">1872</span></a> <span class="n">fetch</span> <span class="o">=</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">limit</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span><span class="p">)</span> -</span><span id="Generator.query_modifiers-1873"><a href="#Generator.query_modifiers-1873"><span class="linenos">1873</span></a> -</span><span id="Generator.query_modifiers-1874"><a href="#Generator.query_modifiers-1874"><span class="linenos">1874</span></a> <span class="n">offset_limit_modifiers</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Generator.query_modifiers-1875"><a href="#Generator.query_modifiers-1875"><span class="linenos">1875</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">offset_limit_modifiers</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">fetch</span><span class="p">,</span> <span class="n">limit</span><span class="p">)</span> -</span><span id="Generator.query_modifiers-1876"><a href="#Generator.query_modifiers-1876"><span class="linenos">1876</span></a> <span class="k">if</span> <span class="n">with_offset_limit_modifiers</span> -</span><span id="Generator.query_modifiers-1877"><a href="#Generator.query_modifiers-1877"><span class="linenos">1877</span></a> <span class="k">else</span> <span class="p">[]</span> -</span><span id="Generator.query_modifiers-1878"><a href="#Generator.query_modifiers-1878"><span class="linenos">1878</span></a> <span class="p">)</span> -</span><span id="Generator.query_modifiers-1879"><a href="#Generator.query_modifiers-1879"><span class="linenos">1879</span></a> -</span><span id="Generator.query_modifiers-1880"><a href="#Generator.query_modifiers-1880"><span class="linenos">1880</span></a> <span class="k">return</span> <span class="n">csv</span><span class="p">(</span> -</span><span id="Generator.query_modifiers-1881"><a href="#Generator.query_modifiers-1881"><span class="linenos">1881</span></a> <span class="o">*</span><span class="n">sqls</span><span class="p">,</span> -</span><span id="Generator.query_modifiers-1882"><a href="#Generator.query_modifiers-1882"><span class="linenos">1882</span></a> <span class="o">*</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">join</span><span class="p">)</span> <span class="k">for</span> <span class="n">join</span> <span class="ow">in</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">"joins"</span><span class="p">)</span> <span class="ow">or</span> <span class="p">[]],</span> -</span><span id="Generator.query_modifiers-1883"><a href="#Generator.query_modifiers-1883"><span class="linenos">1883</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">"connect"</span><span class="p">),</span> -</span><span id="Generator.query_modifiers-1884"><a href="#Generator.query_modifiers-1884"><span class="linenos">1884</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">"match"</span><span class="p">),</span> -</span><span id="Generator.query_modifiers-1885"><a href="#Generator.query_modifiers-1885"><span class="linenos">1885</span></a> <span class="o">*</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">lateral</span><span class="p">)</span> <span class="k">for</span> <span class="n">lateral</span> <span class="ow">in</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">"laterals"</span><span class="p">)</span> <span class="ow">or</span> <span class="p">[]],</span> -</span><span id="Generator.query_modifiers-1886"><a href="#Generator.query_modifiers-1886"><span class="linenos">1886</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">"where"</span><span class="p">),</span> -</span><span id="Generator.query_modifiers-1887"><a href="#Generator.query_modifiers-1887"><span class="linenos">1887</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">"group"</span><span class="p">),</span> -</span><span id="Generator.query_modifiers-1888"><a href="#Generator.query_modifiers-1888"><span class="linenos">1888</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">"having"</span><span class="p">),</span> -</span><span id="Generator.query_modifiers-1889"><a href="#Generator.query_modifiers-1889"><span class="linenos">1889</span></a> <span class="o">*</span><span class="bp">self</span><span class="o">.</span><span class="n">after_having_modifiers</span><span class="p">(</span><span class="n">expression</span><span class="p">),</span> -</span><span id="Generator.query_modifiers-1890"><a href="#Generator.query_modifiers-1890"><span class="linenos">1890</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">"order"</span><span class="p">),</span> -</span><span id="Generator.query_modifiers-1891"><a href="#Generator.query_modifiers-1891"><span class="linenos">1891</span></a> <span class="o">*</span><span class="n">offset_limit_modifiers</span><span class="p">,</span> -</span><span id="Generator.query_modifiers-1892"><a href="#Generator.query_modifiers-1892"><span class="linenos">1892</span></a> <span class="o">*</span><span class="bp">self</span><span class="o">.</span><span class="n">after_limit_modifiers</span><span class="p">(</span><span class="n">expression</span><span class="p">),</span> -</span><span id="Generator.query_modifiers-1893"><a href="#Generator.query_modifiers-1893"><span class="linenos">1893</span></a> <span class="n">sep</span><span class="o">=</span><span class="s2">""</span><span class="p">,</span> -</span><span id="Generator.query_modifiers-1894"><a href="#Generator.query_modifiers-1894"><span class="linenos">1894</span></a> <span class="p">)</span> +</span><span id="Generator.query_modifiers-1872"><a href="#Generator.query_modifiers-1872"><span class="linenos">1872</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">LIMIT_FETCH</span> <span class="o">==</span> <span class="s2">"LIMIT"</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">limit</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span><span class="p">):</span> +</span><span id="Generator.query_modifiers-1873"><a href="#Generator.query_modifiers-1873"><span class="linenos">1873</span></a> <span class="n">limit</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">(</span><span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">maybe_copy</span><span class="p">(</span><span class="n">limit</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">"count"</span><span class="p">)))</span> +</span><span id="Generator.query_modifiers-1874"><a href="#Generator.query_modifiers-1874"><span class="linenos">1874</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">LIMIT_FETCH</span> <span class="o">==</span> <span class="s2">"FETCH"</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">limit</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">):</span> +</span><span id="Generator.query_modifiers-1875"><a href="#Generator.query_modifiers-1875"><span class="linenos">1875</span></a> <span class="n">limit</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span><span class="p">(</span><span class="n">direction</span><span class="o">=</span><span class="s2">"FIRST"</span><span class="p">,</span> <span class="n">count</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">maybe_copy</span><span class="p">(</span><span class="n">limit</span><span class="o">.</span><span class="n">expression</span><span class="p">))</span> +</span><span id="Generator.query_modifiers-1876"><a href="#Generator.query_modifiers-1876"><span class="linenos">1876</span></a> +</span><span id="Generator.query_modifiers-1877"><a href="#Generator.query_modifiers-1877"><span class="linenos">1877</span></a> <span class="n">fetch</span> <span class="o">=</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">limit</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span><span class="p">)</span> +</span><span id="Generator.query_modifiers-1878"><a href="#Generator.query_modifiers-1878"><span class="linenos">1878</span></a> +</span><span id="Generator.query_modifiers-1879"><a href="#Generator.query_modifiers-1879"><span class="linenos">1879</span></a> <span class="n">offset_limit_modifiers</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Generator.query_modifiers-1880"><a href="#Generator.query_modifiers-1880"><span class="linenos">1880</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">offset_limit_modifiers</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">fetch</span><span class="p">,</span> <span class="n">limit</span><span class="p">)</span> +</span><span id="Generator.query_modifiers-1881"><a href="#Generator.query_modifiers-1881"><span class="linenos">1881</span></a> <span class="k">if</span> <span class="n">with_offset_limit_modifiers</span> +</span><span id="Generator.query_modifiers-1882"><a href="#Generator.query_modifiers-1882"><span class="linenos">1882</span></a> <span class="k">else</span> <span class="p">[]</span> +</span><span id="Generator.query_modifiers-1883"><a href="#Generator.query_modifiers-1883"><span class="linenos">1883</span></a> <span class="p">)</span> +</span><span id="Generator.query_modifiers-1884"><a href="#Generator.query_modifiers-1884"><span class="linenos">1884</span></a> +</span><span id="Generator.query_modifiers-1885"><a href="#Generator.query_modifiers-1885"><span class="linenos">1885</span></a> <span class="k">return</span> <span class="n">csv</span><span class="p">(</span> +</span><span id="Generator.query_modifiers-1886"><a href="#Generator.query_modifiers-1886"><span class="linenos">1886</span></a> <span class="o">*</span><span class="n">sqls</span><span class="p">,</span> +</span><span id="Generator.query_modifiers-1887"><a href="#Generator.query_modifiers-1887"><span class="linenos">1887</span></a> <span class="o">*</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">join</span><span class="p">)</span> <span class="k">for</span> <span class="n">join</span> <span class="ow">in</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">"joins"</span><span class="p">)</span> <span class="ow">or</span> <span class="p">[]],</span> +</span><span id="Generator.query_modifiers-1888"><a href="#Generator.query_modifiers-1888"><span class="linenos">1888</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">"connect"</span><span class="p">),</span> +</span><span id="Generator.query_modifiers-1889"><a href="#Generator.query_modifiers-1889"><span class="linenos">1889</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">"match"</span><span class="p">),</span> +</span><span id="Generator.query_modifiers-1890"><a href="#Generator.query_modifiers-1890"><span class="linenos">1890</span></a> <span class="o">*</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">lateral</span><span class="p">)</span> <span class="k">for</span> <span class="n">lateral</span> <span class="ow">in</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">"laterals"</span><span class="p">)</span> <span class="ow">or</span> <span class="p">[]],</span> +</span><span id="Generator.query_modifiers-1891"><a href="#Generator.query_modifiers-1891"><span class="linenos">1891</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">"where"</span><span class="p">),</span> +</span><span id="Generator.query_modifiers-1892"><a href="#Generator.query_modifiers-1892"><span class="linenos">1892</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">"group"</span><span class="p">),</span> +</span><span id="Generator.query_modifiers-1893"><a href="#Generator.query_modifiers-1893"><span class="linenos">1893</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">"having"</span><span class="p">),</span> +</span><span id="Generator.query_modifiers-1894"><a href="#Generator.query_modifiers-1894"><span class="linenos">1894</span></a> <span class="o">*</span><span class="bp">self</span><span class="o">.</span><span class="n">after_having_modifiers</span><span class="p">(</span><span class="n">expression</span><span class="p">),</span> +</span><span id="Generator.query_modifiers-1895"><a href="#Generator.query_modifiers-1895"><span class="linenos">1895</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">"order"</span><span class="p">),</span> +</span><span id="Generator.query_modifiers-1896"><a href="#Generator.query_modifiers-1896"><span class="linenos">1896</span></a> <span class="o">*</span><span class="n">offset_limit_modifiers</span><span class="p">,</span> +</span><span id="Generator.query_modifiers-1897"><a href="#Generator.query_modifiers-1897"><span class="linenos">1897</span></a> <span class="o">*</span><span class="bp">self</span><span class="o">.</span><span class="n">after_limit_modifiers</span><span class="p">(</span><span class="n">expression</span><span class="p">),</span> +</span><span id="Generator.query_modifiers-1898"><a href="#Generator.query_modifiers-1898"><span class="linenos">1898</span></a> <span class="n">sep</span><span class="o">=</span><span class="s2">""</span><span class="p">,</span> +</span><span id="Generator.query_modifiers-1899"><a href="#Generator.query_modifiers-1899"><span class="linenos">1899</span></a> <span class="p">)</span> </span></pre></div> @@ -11545,13 +11653,13 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.offset_limit_modifiers"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.offset_limit_modifiers-1896"><a href="#Generator.offset_limit_modifiers-1896"><span class="linenos">1896</span></a> <span class="k">def</span> <span class="nf">offset_limit_modifiers</span><span class="p">(</span> -</span><span id="Generator.offset_limit_modifiers-1897"><a href="#Generator.offset_limit_modifiers-1897"><span class="linenos">1897</span></a> <span class="bp">self</span><span 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">fetch</span><span class="p">:</span> <span class="nb">bool</span><span class="p">,</span> <span class="n">limit</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">Fetch</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">]</span> -</span><span id="Generator.offset_limit_modifiers-1898"><a href="#Generator.offset_limit_modifiers-1898"><span class="linenos">1898</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> -</span><span id="Generator.offset_limit_modifiers-1899"><a href="#Generator.offset_limit_modifiers-1899"><span class="linenos">1899</span></a> <span class="k">return</span> <span class="p">[</span> -</span><span id="Generator.offset_limit_modifiers-1900"><a href="#Generator.offset_limit_modifiers-1900"><span class="linenos">1900</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">"offset"</span><span class="p">)</span> <span class="k">if</span> <span class="n">fetch</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">limit</span><span class="p">),</span> -</span><span id="Generator.offset_limit_modifiers-1901"><a href="#Generator.offset_limit_modifiers-1901"><span class="linenos">1901</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">limit</span><span class="p">)</span> <span class="k">if</span> <span class="n">fetch</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">expression</span><span class="p">,</span> <span class="s2">"offset"</span><span class="p">),</span> -</span><span id="Generator.offset_limit_modifiers-1902"><a href="#Generator.offset_limit_modifiers-1902"><span class="linenos">1902</span></a> <span class="p">]</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.offset_limit_modifiers-1901"><a href="#Generator.offset_limit_modifiers-1901"><span class="linenos">1901</span></a> <span class="k">def</span> <span class="nf">offset_limit_modifiers</span><span class="p">(</span> +</span><span id="Generator.offset_limit_modifiers-1902"><a href="#Generator.offset_limit_modifiers-1902"><span class="linenos">1902</span></a> <span class="bp">self</span><span 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">fetch</span><span class="p">:</span> <span class="nb">bool</span><span class="p">,</span> <span class="n">limit</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">Fetch</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">]</span> +</span><span id="Generator.offset_limit_modifiers-1903"><a href="#Generator.offset_limit_modifiers-1903"><span class="linenos">1903</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> +</span><span id="Generator.offset_limit_modifiers-1904"><a href="#Generator.offset_limit_modifiers-1904"><span class="linenos">1904</span></a> <span class="k">return</span> <span class="p">[</span> +</span><span id="Generator.offset_limit_modifiers-1905"><a href="#Generator.offset_limit_modifiers-1905"><span class="linenos">1905</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">"offset"</span><span class="p">)</span> <span class="k">if</span> <span class="n">fetch</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">limit</span><span class="p">),</span> +</span><span id="Generator.offset_limit_modifiers-1906"><a href="#Generator.offset_limit_modifiers-1906"><span class="linenos">1906</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">limit</span><span class="p">)</span> <span class="k">if</span> <span class="n">fetch</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">expression</span><span class="p">,</span> <span class="s2">"offset"</span><span class="p">),</span> +</span><span id="Generator.offset_limit_modifiers-1907"><a href="#Generator.offset_limit_modifiers-1907"><span class="linenos">1907</span></a> <span class="p">]</span> </span></pre></div> @@ -11569,16 +11677,16 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.after_having_modifiers"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.after_having_modifiers-1904"><a href="#Generator.after_having_modifiers-1904"><span class="linenos">1904</span></a> <span class="k">def</span> <span class="nf">after_having_modifiers</span><span class="p">(</span><span class="bp">self</span><span 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">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> -</span><span id="Generator.after_having_modifiers-1905"><a href="#Generator.after_having_modifiers-1905"><span class="linenos">1905</span></a> <span class="k">return</span> <span class="p">[</span> -</span><span id="Generator.after_having_modifiers-1906"><a href="#Generator.after_having_modifiers-1906"><span class="linenos">1906</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">"qualify"</span><span class="p">),</span> -</span><span id="Generator.after_having_modifiers-1907"><a href="#Generator.after_having_modifiers-1907"><span class="linenos">1907</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s2">"WINDOW "</span><span class="p">)</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">"windows"</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.after_having_modifiers-1908"><a href="#Generator.after_having_modifiers-1908"><span class="linenos">1908</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">"windows"</span><span class="p">)</span> -</span><span id="Generator.after_having_modifiers-1909"><a href="#Generator.after_having_modifiers-1909"><span class="linenos">1909</span></a> <span class="k">else</span> <span class="s2">""</span><span class="p">,</span> -</span><span id="Generator.after_having_modifiers-1910"><a href="#Generator.after_having_modifiers-1910"><span class="linenos">1910</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">"distribute"</span><span class="p">),</span> -</span><span id="Generator.after_having_modifiers-1911"><a href="#Generator.after_having_modifiers-1911"><span class="linenos">1911</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">"sort"</span><span class="p">),</span> -</span><span id="Generator.after_having_modifiers-1912"><a href="#Generator.after_having_modifiers-1912"><span class="linenos">1912</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">"cluster"</span><span class="p">),</span> -</span><span id="Generator.after_having_modifiers-1913"><a href="#Generator.after_having_modifiers-1913"><span class="linenos">1913</span></a> <span class="p">]</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.after_having_modifiers-1909"><a href="#Generator.after_having_modifiers-1909"><span class="linenos">1909</span></a> <span class="k">def</span> <span class="nf">after_having_modifiers</span><span class="p">(</span><span class="bp">self</span><span 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">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> +</span><span id="Generator.after_having_modifiers-1910"><a href="#Generator.after_having_modifiers-1910"><span class="linenos">1910</span></a> <span class="k">return</span> <span class="p">[</span> +</span><span id="Generator.after_having_modifiers-1911"><a href="#Generator.after_having_modifiers-1911"><span class="linenos">1911</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">"qualify"</span><span class="p">),</span> +</span><span id="Generator.after_having_modifiers-1912"><a href="#Generator.after_having_modifiers-1912"><span class="linenos">1912</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s2">"WINDOW "</span><span class="p">)</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">"windows"</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.after_having_modifiers-1913"><a href="#Generator.after_having_modifiers-1913"><span class="linenos">1913</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">"windows"</span><span class="p">)</span> +</span><span id="Generator.after_having_modifiers-1914"><a href="#Generator.after_having_modifiers-1914"><span class="linenos">1914</span></a> <span class="k">else</span> <span class="s2">""</span><span class="p">,</span> +</span><span id="Generator.after_having_modifiers-1915"><a href="#Generator.after_having_modifiers-1915"><span class="linenos">1915</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">"distribute"</span><span class="p">),</span> +</span><span id="Generator.after_having_modifiers-1916"><a href="#Generator.after_having_modifiers-1916"><span class="linenos">1916</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">"sort"</span><span class="p">),</span> +</span><span id="Generator.after_having_modifiers-1917"><a href="#Generator.after_having_modifiers-1917"><span class="linenos">1917</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">"cluster"</span><span class="p">),</span> +</span><span id="Generator.after_having_modifiers-1918"><a href="#Generator.after_having_modifiers-1918"><span class="linenos">1918</span></a> <span class="p">]</span> </span></pre></div> @@ -11596,10 +11704,10 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.after_limit_modifiers"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.after_limit_modifiers-1915"><a href="#Generator.after_limit_modifiers-1915"><span class="linenos">1915</span></a> <span class="k">def</span> <span class="nf">after_limit_modifiers</span><span class="p">(</span><span class="bp">self</span><span 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">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> -</span><span id="Generator.after_limit_modifiers-1916"><a href="#Generator.after_limit_modifiers-1916"><span class="linenos">1916</span></a> <span class="n">locks</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">"locks"</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.after_limit_modifiers-1917"><a href="#Generator.after_limit_modifiers-1917"><span class="linenos">1917</span></a> <span class="n">locks</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">locks</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">locks</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.after_limit_modifiers-1918"><a href="#Generator.after_limit_modifiers-1918"><span class="linenos">1918</span></a> <span class="k">return</span> <span class="p">[</span><span class="n">locks</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">"sample"</span><span class="p">)]</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.after_limit_modifiers-1920"><a href="#Generator.after_limit_modifiers-1920"><span class="linenos">1920</span></a> <span class="k">def</span> <span class="nf">after_limit_modifiers</span><span class="p">(</span><span class="bp">self</span><span 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">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> +</span><span id="Generator.after_limit_modifiers-1921"><a href="#Generator.after_limit_modifiers-1921"><span class="linenos">1921</span></a> <span class="n">locks</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">"locks"</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.after_limit_modifiers-1922"><a href="#Generator.after_limit_modifiers-1922"><span class="linenos">1922</span></a> <span class="n">locks</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">locks</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">locks</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.after_limit_modifiers-1923"><a href="#Generator.after_limit_modifiers-1923"><span class="linenos">1923</span></a> <span class="k">return</span> <span class="p">[</span><span class="n">locks</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">"sample"</span><span class="p">)]</span> </span></pre></div> @@ -11617,52 +11725,52 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.select_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.select_sql-1920"><a href="#Generator.select_sql-1920"><span class="linenos">1920</span></a> <span class="k">def</span> <span class="nf">select_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.select_sql-1921"><a href="#Generator.select_sql-1921"><span class="linenos">1921</span></a> <span class="n">hint</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"hint"</span><span class="p">)</span> -</span><span id="Generator.select_sql-1922"><a href="#Generator.select_sql-1922"><span class="linenos">1922</span></a> <span class="n">distinct</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"distinct"</span><span class="p">)</span> -</span><span id="Generator.select_sql-1923"><a href="#Generator.select_sql-1923"><span class="linenos">1923</span></a> <span class="n">distinct</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">distinct</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">distinct</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.select_sql-1924"><a href="#Generator.select_sql-1924"><span class="linenos">1924</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 class="o">.</span><span class="n">upper</span><span class="p">()</span> -</span><span id="Generator.select_sql-1925"><a href="#Generator.select_sql-1925"><span class="linenos">1925</span></a> <span class="n">limit</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">"limit"</span><span class="p">)</span> -</span><span id="Generator.select_sql-1926"><a href="#Generator.select_sql-1926"><span class="linenos">1926</span></a> <span class="n">top</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Generator.select_sql-1927"><a href="#Generator.select_sql-1927"><span class="linenos">1927</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">limit_sql</span><span class="p">(</span><span class="n">limit</span><span class="p">,</span> <span class="n">top</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator.select_sql-1928"><a href="#Generator.select_sql-1928"><span class="linenos">1928</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">limit</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">LIMIT_IS_TOP</span> -</span><span id="Generator.select_sql-1929"><a href="#Generator.select_sql-1929"><span class="linenos">1929</span></a> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.select_sql-1930"><a href="#Generator.select_sql-1930"><span class="linenos">1930</span></a> <span class="p">)</span> -</span><span id="Generator.select_sql-1931"><a href="#Generator.select_sql-1931"><span class="linenos">1931</span></a> -</span><span id="Generator.select_sql-1932"><a href="#Generator.select_sql-1932"><span class="linenos">1932</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.select_sql-1933"><a href="#Generator.select_sql-1933"><span class="linenos">1933</span></a> -</span><span id="Generator.select_sql-1934"><a href="#Generator.select_sql-1934"><span class="linenos">1934</span></a> <span class="k">if</span> <span class="n">kind</span><span class="p">:</span> -</span><span id="Generator.select_sql-1935"><a href="#Generator.select_sql-1935"><span class="linenos">1935</span></a> <span class="k">if</span> <span class="n">kind</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">SELECT_KINDS</span><span class="p">:</span> -</span><span id="Generator.select_sql-1936"><a href="#Generator.select_sql-1936"><span class="linenos">1936</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.select_sql-1937"><a href="#Generator.select_sql-1937"><span class="linenos">1937</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator.select_sql-1938"><a href="#Generator.select_sql-1938"><span class="linenos">1938</span></a> <span class="k">if</span> <span class="n">kind</span> <span class="o">==</span> <span class="s2">"STRUCT"</span><span class="p">:</span> -</span><span id="Generator.select_sql-1939"><a href="#Generator.select_sql-1939"><span class="linenos">1939</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><span id="Generator.select_sql-1940"><a href="#Generator.select_sql-1940"><span class="linenos">1940</span></a> <span class="n">sqls</span><span class="o">=</span><span class="p">[</span> -</span><span id="Generator.select_sql-1941"><a href="#Generator.select_sql-1941"><span class="linenos">1941</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span> -</span><span id="Generator.select_sql-1942"><a href="#Generator.select_sql-1942"><span class="linenos">1942</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Struct</span><span class="p">(</span> -</span><span id="Generator.select_sql-1943"><a href="#Generator.select_sql-1943"><span class="linenos">1943</span></a> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span> -</span><span id="Generator.select_sql-1944"><a href="#Generator.select_sql-1944"><span class="linenos">1944</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">column</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">output_name</span><span class="p">)</span><span class="o">.</span><span class="n">eq</span><span class="p">(</span> -</span><span id="Generator.select_sql-1945"><a href="#Generator.select_sql-1945"><span class="linenos">1945</span></a> <span class="n">e</span><span class="o">.</span><span class="n">this</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">Alias</span><span class="p">)</span> <span class="k">else</span> <span class="n">e</span> -</span><span id="Generator.select_sql-1946"><a href="#Generator.select_sql-1946"><span class="linenos">1946</span></a> <span class="p">)</span> -</span><span id="Generator.select_sql-1947"><a href="#Generator.select_sql-1947"><span class="linenos">1947</span></a> <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">expressions</span> -</span><span id="Generator.select_sql-1948"><a href="#Generator.select_sql-1948"><span class="linenos">1948</span></a> <span class="p">]</span> -</span><span id="Generator.select_sql-1949"><a href="#Generator.select_sql-1949"><span class="linenos">1949</span></a> <span class="p">)</span> -</span><span id="Generator.select_sql-1950"><a href="#Generator.select_sql-1950"><span class="linenos">1950</span></a> <span class="p">)</span> -</span><span id="Generator.select_sql-1951"><a href="#Generator.select_sql-1951"><span class="linenos">1951</span></a> <span class="p">]</span> -</span><span id="Generator.select_sql-1952"><a href="#Generator.select_sql-1952"><span class="linenos">1952</span></a> <span class="p">)</span> -</span><span id="Generator.select_sql-1953"><a href="#Generator.select_sql-1953"><span class="linenos">1953</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator.select_sql-1954"><a href="#Generator.select_sql-1954"><span class="linenos">1954</span></a> -</span><span id="Generator.select_sql-1955"><a href="#Generator.select_sql-1955"><span class="linenos">1955</span></a> <span class="c1"># We use LIMIT_IS_TOP as a proxy for whether DISTINCT should go first because tsql and Teradata</span> -</span><span id="Generator.select_sql-1956"><a href="#Generator.select_sql-1956"><span class="linenos">1956</span></a> <span class="c1"># are the only dialects that use LIMIT_IS_TOP and both place DISTINCT first.</span> -</span><span id="Generator.select_sql-1957"><a href="#Generator.select_sql-1957"><span class="linenos">1957</span></a> <span class="n">top_distinct</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">distinct</span><span class="si">}{</span><span class="n">hint</span><span class="si">}{</span><span class="n">top</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">LIMIT_IS_TOP</span> <span class="k">else</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">top</span><span class="si">}{</span><span class="n">hint</span><span class="si">}{</span><span class="n">distinct</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.select_sql-1958"><a href="#Generator.select_sql-1958"><span class="linenos">1958</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="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</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="n">expressions</span> -</span><span id="Generator.select_sql-1959"><a href="#Generator.select_sql-1959"><span class="linenos">1959</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">query_modifiers</span><span class="p">(</span> -</span><span id="Generator.select_sql-1960"><a href="#Generator.select_sql-1960"><span class="linenos">1960</span></a> <span class="n">expression</span><span class="p">,</span> -</span><span id="Generator.select_sql-1961"><a href="#Generator.select_sql-1961"><span class="linenos">1961</span></a> <span class="sa">f</span><span class="s2">"SELECT</span><span class="si">{</span><span class="n">top_distinct</span><span class="si">}{</span><span class="n">kind</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> -</span><span id="Generator.select_sql-1962"><a href="#Generator.select_sql-1962"><span class="linenos">1962</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">"into"</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.select_sql-1963"><a href="#Generator.select_sql-1963"><span class="linenos">1963</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">"from"</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.select_sql-1964"><a href="#Generator.select_sql-1964"><span class="linenos">1964</span></a> <span class="p">)</span> -</span><span id="Generator.select_sql-1965"><a href="#Generator.select_sql-1965"><span class="linenos">1965</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.select_sql-1925"><a href="#Generator.select_sql-1925"><span class="linenos">1925</span></a> <span class="k">def</span> <span class="nf">select_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.select_sql-1926"><a href="#Generator.select_sql-1926"><span class="linenos">1926</span></a> <span class="n">hint</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"hint"</span><span class="p">)</span> +</span><span id="Generator.select_sql-1927"><a href="#Generator.select_sql-1927"><span class="linenos">1927</span></a> <span class="n">distinct</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"distinct"</span><span class="p">)</span> +</span><span id="Generator.select_sql-1928"><a href="#Generator.select_sql-1928"><span class="linenos">1928</span></a> <span class="n">distinct</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">distinct</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">distinct</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.select_sql-1929"><a href="#Generator.select_sql-1929"><span class="linenos">1929</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 class="o">.</span><span class="n">upper</span><span class="p">()</span> +</span><span id="Generator.select_sql-1930"><a href="#Generator.select_sql-1930"><span class="linenos">1930</span></a> <span class="n">limit</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">"limit"</span><span class="p">)</span> +</span><span id="Generator.select_sql-1931"><a href="#Generator.select_sql-1931"><span class="linenos">1931</span></a> <span class="n">top</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Generator.select_sql-1932"><a href="#Generator.select_sql-1932"><span class="linenos">1932</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">limit_sql</span><span class="p">(</span><span class="n">limit</span><span class="p">,</span> <span class="n">top</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator.select_sql-1933"><a href="#Generator.select_sql-1933"><span class="linenos">1933</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">limit</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">LIMIT_IS_TOP</span> +</span><span id="Generator.select_sql-1934"><a href="#Generator.select_sql-1934"><span class="linenos">1934</span></a> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.select_sql-1935"><a href="#Generator.select_sql-1935"><span class="linenos">1935</span></a> <span class="p">)</span> +</span><span id="Generator.select_sql-1936"><a href="#Generator.select_sql-1936"><span class="linenos">1936</span></a> +</span><span id="Generator.select_sql-1937"><a href="#Generator.select_sql-1937"><span class="linenos">1937</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.select_sql-1938"><a href="#Generator.select_sql-1938"><span class="linenos">1938</span></a> +</span><span id="Generator.select_sql-1939"><a href="#Generator.select_sql-1939"><span class="linenos">1939</span></a> <span class="k">if</span> <span class="n">kind</span><span class="p">:</span> +</span><span id="Generator.select_sql-1940"><a href="#Generator.select_sql-1940"><span class="linenos">1940</span></a> <span class="k">if</span> <span class="n">kind</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">SELECT_KINDS</span><span class="p">:</span> +</span><span id="Generator.select_sql-1941"><a href="#Generator.select_sql-1941"><span class="linenos">1941</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.select_sql-1942"><a href="#Generator.select_sql-1942"><span class="linenos">1942</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator.select_sql-1943"><a href="#Generator.select_sql-1943"><span class="linenos">1943</span></a> <span class="k">if</span> <span class="n">kind</span> <span class="o">==</span> <span class="s2">"STRUCT"</span><span class="p">:</span> +</span><span id="Generator.select_sql-1944"><a href="#Generator.select_sql-1944"><span class="linenos">1944</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><span id="Generator.select_sql-1945"><a href="#Generator.select_sql-1945"><span class="linenos">1945</span></a> <span class="n">sqls</span><span class="o">=</span><span class="p">[</span> +</span><span id="Generator.select_sql-1946"><a href="#Generator.select_sql-1946"><span class="linenos">1946</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span> +</span><span id="Generator.select_sql-1947"><a href="#Generator.select_sql-1947"><span class="linenos">1947</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Struct</span><span class="p">(</span> +</span><span id="Generator.select_sql-1948"><a href="#Generator.select_sql-1948"><span class="linenos">1948</span></a> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span> +</span><span id="Generator.select_sql-1949"><a href="#Generator.select_sql-1949"><span class="linenos">1949</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">column</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">output_name</span><span class="p">)</span><span class="o">.</span><span class="n">eq</span><span class="p">(</span> +</span><span id="Generator.select_sql-1950"><a href="#Generator.select_sql-1950"><span class="linenos">1950</span></a> <span class="n">e</span><span class="o">.</span><span class="n">this</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">Alias</span><span class="p">)</span> <span class="k">else</span> <span class="n">e</span> +</span><span id="Generator.select_sql-1951"><a href="#Generator.select_sql-1951"><span class="linenos">1951</span></a> <span class="p">)</span> +</span><span id="Generator.select_sql-1952"><a href="#Generator.select_sql-1952"><span class="linenos">1952</span></a> <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">expressions</span> +</span><span id="Generator.select_sql-1953"><a href="#Generator.select_sql-1953"><span class="linenos">1953</span></a> <span class="p">]</span> +</span><span id="Generator.select_sql-1954"><a href="#Generator.select_sql-1954"><span class="linenos">1954</span></a> <span class="p">)</span> +</span><span id="Generator.select_sql-1955"><a href="#Generator.select_sql-1955"><span class="linenos">1955</span></a> <span class="p">)</span> +</span><span id="Generator.select_sql-1956"><a href="#Generator.select_sql-1956"><span class="linenos">1956</span></a> <span class="p">]</span> +</span><span id="Generator.select_sql-1957"><a href="#Generator.select_sql-1957"><span class="linenos">1957</span></a> <span class="p">)</span> +</span><span id="Generator.select_sql-1958"><a href="#Generator.select_sql-1958"><span class="linenos">1958</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator.select_sql-1959"><a href="#Generator.select_sql-1959"><span class="linenos">1959</span></a> +</span><span id="Generator.select_sql-1960"><a href="#Generator.select_sql-1960"><span class="linenos">1960</span></a> <span class="c1"># We use LIMIT_IS_TOP as a proxy for whether DISTINCT should go first because tsql and Teradata</span> +</span><span id="Generator.select_sql-1961"><a href="#Generator.select_sql-1961"><span class="linenos">1961</span></a> <span class="c1"># are the only dialects that use LIMIT_IS_TOP and both place DISTINCT first.</span> +</span><span id="Generator.select_sql-1962"><a href="#Generator.select_sql-1962"><span class="linenos">1962</span></a> <span class="n">top_distinct</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">distinct</span><span class="si">}{</span><span class="n">hint</span><span class="si">}{</span><span class="n">top</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">LIMIT_IS_TOP</span> <span class="k">else</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">top</span><span class="si">}{</span><span class="n">hint</span><span class="si">}{</span><span class="n">distinct</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.select_sql-1963"><a href="#Generator.select_sql-1963"><span class="linenos">1963</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="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</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="n">expressions</span> +</span><span id="Generator.select_sql-1964"><a href="#Generator.select_sql-1964"><span class="linenos">1964</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">query_modifiers</span><span class="p">(</span> +</span><span id="Generator.select_sql-1965"><a href="#Generator.select_sql-1965"><span class="linenos">1965</span></a> <span class="n">expression</span><span class="p">,</span> +</span><span id="Generator.select_sql-1966"><a href="#Generator.select_sql-1966"><span class="linenos">1966</span></a> <span class="sa">f</span><span class="s2">"SELECT</span><span class="si">{</span><span class="n">top_distinct</span><span class="si">}{</span><span class="n">kind</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> +</span><span id="Generator.select_sql-1967"><a href="#Generator.select_sql-1967"><span class="linenos">1967</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">"into"</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.select_sql-1968"><a href="#Generator.select_sql-1968"><span class="linenos">1968</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">"from"</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.select_sql-1969"><a href="#Generator.select_sql-1969"><span class="linenos">1969</span></a> <span class="p">)</span> +</span><span id="Generator.select_sql-1970"><a href="#Generator.select_sql-1970"><span class="linenos">1970</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> @@ -11680,10 +11788,10 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.schema_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.schema_sql-1967"><a href="#Generator.schema_sql-1967"><span class="linenos">1967</span></a> <span class="k">def</span> <span class="nf">schema_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Schema</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.schema_sql-1968"><a href="#Generator.schema_sql-1968"><span class="linenos">1968</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.schema_sql-1969"><a href="#Generator.schema_sql-1969"><span class="linenos">1969</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">schema_columns_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Generator.schema_sql-1970"><a href="#Generator.schema_sql-1970"><span class="linenos">1970</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">sql</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="ow">and</span> <span class="n">sql</span> <span class="k">else</span> <span class="n">this</span> <span class="ow">or</span> <span class="n">sql</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.schema_sql-1972"><a href="#Generator.schema_sql-1972"><span class="linenos">1972</span></a> <span class="k">def</span> <span class="nf">schema_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Schema</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.schema_sql-1973"><a href="#Generator.schema_sql-1973"><span class="linenos">1973</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.schema_sql-1974"><a href="#Generator.schema_sql-1974"><span class="linenos">1974</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">schema_columns_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Generator.schema_sql-1975"><a href="#Generator.schema_sql-1975"><span class="linenos">1975</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">sql</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="ow">and</span> <span class="n">sql</span> <span class="k">else</span> <span class="n">this</span> <span class="ow">or</span> <span class="n">sql</span> </span></pre></div> @@ -11701,10 +11809,10 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.schema_columns_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.schema_columns_sql-1972"><a href="#Generator.schema_columns_sql-1972"><span class="linenos">1972</span></a> <span class="k">def</span> <span class="nf">schema_columns_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Schema</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.schema_columns_sql-1973"><a href="#Generator.schema_columns_sql-1973"><span class="linenos">1973</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> -</span><span id="Generator.schema_columns_sql-1974"><a href="#Generator.schema_columns_sql-1974"><span class="linenos">1974</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">sep</span><span class="p">(</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">expressions</span><span class="p">(</span><span class="n">expression</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.schema_columns_sql-1975"><a href="#Generator.schema_columns_sql-1975"><span class="linenos">1975</span></a> <span class="k">return</span> <span class="s2">""</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.schema_columns_sql-1977"><a href="#Generator.schema_columns_sql-1977"><span class="linenos">1977</span></a> <span class="k">def</span> <span class="nf">schema_columns_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Schema</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.schema_columns_sql-1978"><a href="#Generator.schema_columns_sql-1978"><span class="linenos">1978</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> +</span><span id="Generator.schema_columns_sql-1979"><a href="#Generator.schema_columns_sql-1979"><span class="linenos">1979</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">sep</span><span class="p">(</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">expressions</span><span class="p">(</span><span class="n">expression</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.schema_columns_sql-1980"><a href="#Generator.schema_columns_sql-1980"><span class="linenos">1980</span></a> <span class="k">return</span> <span class="s2">""</span> </span></pre></div> @@ -11722,12 +11830,12 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.star_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.star_sql-1977"><a href="#Generator.star_sql-1977"><span class="linenos">1977</span></a> <span class="k">def</span> <span class="nf">star_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Star</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.star_sql-1978"><a href="#Generator.star_sql-1978"><span class="linenos">1978</span></a> <span class="n">except_</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">"except"</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.star_sql-1979"><a href="#Generator.star_sql-1979"><span class="linenos">1979</span></a> <span class="n">except_</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">seg</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">STAR_MAPPING</span><span class="p">[</span><span class="s1">'except'</span><span class="p">])</span><span class="si">}</span><span class="s2"> (</span><span class="si">{</span><span class="n">except_</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">except_</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.star_sql-1980"><a href="#Generator.star_sql-1980"><span class="linenos">1980</span></a> <span class="n">replace</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">"replace"</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.star_sql-1981"><a href="#Generator.star_sql-1981"><span class="linenos">1981</span></a> <span class="n">replace</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">seg</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">STAR_MAPPING</span><span class="p">[</span><span class="s1">'replace'</span><span class="p">])</span><span class="si">}</span><span class="s2"> (</span><span class="si">{</span><span class="n">replace</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">replace</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.star_sql-1982"><a href="#Generator.star_sql-1982"><span class="linenos">1982</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"*</span><span class="si">{</span><span class="n">except_</span><span class="si">}{</span><span class="n">replace</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.star_sql-1982"><a href="#Generator.star_sql-1982"><span class="linenos">1982</span></a> <span class="k">def</span> <span class="nf">star_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Star</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.star_sql-1983"><a href="#Generator.star_sql-1983"><span class="linenos">1983</span></a> <span class="n">except_</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">"except"</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.star_sql-1984"><a href="#Generator.star_sql-1984"><span class="linenos">1984</span></a> <span class="n">except_</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">seg</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">STAR_MAPPING</span><span class="p">[</span><span class="s1">'except'</span><span class="p">])</span><span class="si">}</span><span class="s2"> (</span><span class="si">{</span><span class="n">except_</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">except_</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.star_sql-1985"><a href="#Generator.star_sql-1985"><span class="linenos">1985</span></a> <span class="n">replace</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">"replace"</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.star_sql-1986"><a href="#Generator.star_sql-1986"><span class="linenos">1986</span></a> <span class="n">replace</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">seg</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">STAR_MAPPING</span><span class="p">[</span><span class="s1">'replace'</span><span class="p">])</span><span class="si">}</span><span class="s2"> (</span><span class="si">{</span><span class="n">replace</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">replace</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.star_sql-1987"><a href="#Generator.star_sql-1987"><span class="linenos">1987</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"*</span><span class="si">{</span><span class="n">except_</span><span class="si">}{</span><span class="n">replace</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -11745,9 +11853,9 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.parameter_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.parameter_sql-1984"><a href="#Generator.parameter_sql-1984"><span class="linenos">1984</span></a> <span class="k">def</span> <span class="nf">parameter_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Parameter</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.parameter_sql-1985"><a href="#Generator.parameter_sql-1985"><span class="linenos">1985</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.parameter_sql-1986"><a href="#Generator.parameter_sql-1986"><span class="linenos">1986</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">PARAMETER_TOKEN</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.parameter_sql-1989"><a href="#Generator.parameter_sql-1989"><span class="linenos">1989</span></a> <span class="k">def</span> <span class="nf">parameter_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Parameter</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.parameter_sql-1990"><a href="#Generator.parameter_sql-1990"><span class="linenos">1990</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.parameter_sql-1991"><a href="#Generator.parameter_sql-1991"><span class="linenos">1991</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">PARAMETER_TOKEN</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -11765,12 +11873,12 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.sessionparameter_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.sessionparameter_sql-1988"><a href="#Generator.sessionparameter_sql-1988"><span class="linenos">1988</span></a> <span class="k">def</span> <span class="nf">sessionparameter_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SessionParameter</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.sessionparameter_sql-1989"><a href="#Generator.sessionparameter_sql-1989"><span class="linenos">1989</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.sessionparameter_sql-1990"><a href="#Generator.sessionparameter_sql-1990"><span class="linenos">1990</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">)</span> -</span><span id="Generator.sessionparameter_sql-1991"><a href="#Generator.sessionparameter_sql-1991"><span class="linenos">1991</span></a> <span class="k">if</span> <span class="n">kind</span><span class="p">:</span> -</span><span id="Generator.sessionparameter_sql-1992"><a href="#Generator.sessionparameter_sql-1992"><span class="linenos">1992</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><span id="Generator.sessionparameter_sql-1993"><a href="#Generator.sessionparameter_sql-1993"><span class="linenos">1993</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="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.sessionparameter_sql-1993"><a href="#Generator.sessionparameter_sql-1993"><span class="linenos">1993</span></a> <span class="k">def</span> <span class="nf">sessionparameter_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SessionParameter</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.sessionparameter_sql-1994"><a href="#Generator.sessionparameter_sql-1994"><span class="linenos">1994</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.sessionparameter_sql-1995"><a href="#Generator.sessionparameter_sql-1995"><span class="linenos">1995</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">)</span> +</span><span id="Generator.sessionparameter_sql-1996"><a href="#Generator.sessionparameter_sql-1996"><span class="linenos">1996</span></a> <span class="k">if</span> <span class="n">kind</span><span class="p">:</span> +</span><span id="Generator.sessionparameter_sql-1997"><a href="#Generator.sessionparameter_sql-1997"><span class="linenos">1997</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><span id="Generator.sessionparameter_sql-1998"><a href="#Generator.sessionparameter_sql-1998"><span class="linenos">1998</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="s2">"</span> </span></pre></div> @@ -11788,8 +11896,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.placeholder_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.placeholder_sql-1995"><a href="#Generator.placeholder_sql-1995"><span class="linenos">1995</span></a> <span class="k">def</span> <span class="nf">placeholder_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Placeholder</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.placeholder_sql-1996"><a href="#Generator.placeholder_sql-1996"><span class="linenos">1996</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">name</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">name</span> <span class="k">else</span> <span class="s2">"?"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.placeholder_sql-2000"><a href="#Generator.placeholder_sql-2000"><span class="linenos">2000</span></a> <span class="k">def</span> <span class="nf">placeholder_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Placeholder</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.placeholder_sql-2001"><a href="#Generator.placeholder_sql-2001"><span class="linenos">2001</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">name</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">name</span> <span class="k">else</span> <span class="s2">"?"</span> </span></pre></div> @@ -11807,15 +11915,15 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.subquery_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.subquery_sql-1998"><a href="#Generator.subquery_sql-1998"><span class="linenos">1998</span></a> <span class="k">def</span> <span class="nf">subquery_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</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="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">" AS "</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.subquery_sql-1999"><a href="#Generator.subquery_sql-1999"><span class="linenos">1999</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.subquery_sql-2000"><a href="#Generator.subquery_sql-2000"><span class="linenos">2000</span></a> <span class="n">alias</span> <span class="o">=</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">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.subquery_sql-2001"><a href="#Generator.subquery_sql-2001"><span class="linenos">2001</span></a> -</span><span id="Generator.subquery_sql-2002"><a href="#Generator.subquery_sql-2002"><span class="linenos">2002</span></a> <span class="n">pivots</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">"pivots"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</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.subquery_sql-2003"><a href="#Generator.subquery_sql-2003"><span class="linenos">2003</span></a> <span class="n">pivots</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">pivots</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">pivots</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.subquery_sql-2004"><a href="#Generator.subquery_sql-2004"><span class="linenos">2004</span></a> -</span><span id="Generator.subquery_sql-2005"><a href="#Generator.subquery_sql-2005"><span class="linenos">2005</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">query_modifiers</span><span class="p">(</span><span class="n">expression</span><span class="p">,</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 class="n">alias</span><span class="p">,</span> <span class="n">pivots</span><span class="p">)</span> -</span><span id="Generator.subquery_sql-2006"><a href="#Generator.subquery_sql-2006"><span class="linenos">2006</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.subquery_sql-2003"><a href="#Generator.subquery_sql-2003"><span class="linenos">2003</span></a> <span class="k">def</span> <span class="nf">subquery_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</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="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">" AS "</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.subquery_sql-2004"><a href="#Generator.subquery_sql-2004"><span class="linenos">2004</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.subquery_sql-2005"><a href="#Generator.subquery_sql-2005"><span class="linenos">2005</span></a> <span class="n">alias</span> <span class="o">=</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">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.subquery_sql-2006"><a href="#Generator.subquery_sql-2006"><span class="linenos">2006</span></a> +</span><span id="Generator.subquery_sql-2007"><a href="#Generator.subquery_sql-2007"><span class="linenos">2007</span></a> <span class="n">pivots</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">"pivots"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</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.subquery_sql-2008"><a href="#Generator.subquery_sql-2008"><span class="linenos">2008</span></a> <span class="n">pivots</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">pivots</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">pivots</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.subquery_sql-2009"><a href="#Generator.subquery_sql-2009"><span class="linenos">2009</span></a> +</span><span id="Generator.subquery_sql-2010"><a href="#Generator.subquery_sql-2010"><span class="linenos">2010</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">query_modifiers</span><span class="p">(</span><span class="n">expression</span><span class="p">,</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 class="n">alias</span><span class="p">,</span> <span class="n">pivots</span><span class="p">)</span> +</span><span id="Generator.subquery_sql-2011"><a href="#Generator.subquery_sql-2011"><span class="linenos">2011</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> @@ -11833,9 +11941,9 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.qualify_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.qualify_sql-2008"><a href="#Generator.qualify_sql-2008"><span class="linenos">2008</span></a> <span class="k">def</span> <span class="nf">qualify_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Qualify</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.qualify_sql-2009"><a href="#Generator.qualify_sql-2009"><span class="linenos">2009</span></a> <span class="n">this</span> <span class="o">=</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><span id="Generator.qualify_sql-2010"><a href="#Generator.qualify_sql-2010"><span class="linenos">2010</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="s1">'QUALIFY'</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="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.qualify_sql-2013"><a href="#Generator.qualify_sql-2013"><span class="linenos">2013</span></a> <span class="k">def</span> <span class="nf">qualify_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Qualify</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.qualify_sql-2014"><a href="#Generator.qualify_sql-2014"><span class="linenos">2014</span></a> <span class="n">this</span> <span class="o">=</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><span id="Generator.qualify_sql-2015"><a href="#Generator.qualify_sql-2015"><span class="linenos">2015</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="s1">'QUALIFY'</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="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -11853,11 +11961,11 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.union_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.union_sql-2012"><a href="#Generator.union_sql-2012"><span class="linenos">2012</span></a> <span class="k">def</span> <span class="nf">union_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Union</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.union_sql-2013"><a href="#Generator.union_sql-2013"><span class="linenos">2013</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><span id="Generator.union_sql-2014"><a href="#Generator.union_sql-2014"><span class="linenos">2014</span></a> <span class="n">expression</span><span class="p">,</span> -</span><span id="Generator.union_sql-2015"><a href="#Generator.union_sql-2015"><span class="linenos">2015</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">set_operation</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">union_op</span><span class="p">(</span><span class="n">expression</span><span class="p">)),</span> -</span><span id="Generator.union_sql-2016"><a href="#Generator.union_sql-2016"><span class="linenos">2016</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.union_sql-2017"><a href="#Generator.union_sql-2017"><span class="linenos">2017</span></a> <span class="k">def</span> <span class="nf">union_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Union</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.union_sql-2018"><a href="#Generator.union_sql-2018"><span class="linenos">2018</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><span id="Generator.union_sql-2019"><a href="#Generator.union_sql-2019"><span class="linenos">2019</span></a> <span class="n">expression</span><span class="p">,</span> +</span><span id="Generator.union_sql-2020"><a href="#Generator.union_sql-2020"><span class="linenos">2020</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">set_operation</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">union_op</span><span class="p">(</span><span class="n">expression</span><span class="p">)),</span> +</span><span id="Generator.union_sql-2021"><a href="#Generator.union_sql-2021"><span class="linenos">2021</span></a> <span class="p">)</span> </span></pre></div> @@ -11875,11 +11983,11 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.union_op"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.union_op-2018"><a href="#Generator.union_op-2018"><span class="linenos">2018</span></a> <span class="k">def</span> <span class="nf">union_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Union</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.union_op-2019"><a href="#Generator.union_op-2019"><span class="linenos">2019</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="s2">" DISTINCT"</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">EXPLICIT_UNION</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.union_op-2020"><a href="#Generator.union_op-2020"><span class="linenos">2020</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">kind</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">"distinct"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">" ALL"</span> -</span><span id="Generator.union_op-2021"><a href="#Generator.union_op-2021"><span class="linenos">2021</span></a> <span class="n">by_name</span> <span class="o">=</span> <span class="s2">" BY NAME"</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">"by_name"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.union_op-2022"><a href="#Generator.union_op-2022"><span class="linenos">2022</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"UNION</span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">by_name</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.union_op-2023"><a href="#Generator.union_op-2023"><span class="linenos">2023</span></a> <span class="k">def</span> <span class="nf">union_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Union</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.union_op-2024"><a href="#Generator.union_op-2024"><span class="linenos">2024</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="s2">" DISTINCT"</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">EXPLICIT_UNION</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.union_op-2025"><a href="#Generator.union_op-2025"><span class="linenos">2025</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">kind</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">"distinct"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">" ALL"</span> +</span><span id="Generator.union_op-2026"><a href="#Generator.union_op-2026"><span class="linenos">2026</span></a> <span class="n">by_name</span> <span class="o">=</span> <span class="s2">" BY NAME"</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">"by_name"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.union_op-2027"><a href="#Generator.union_op-2027"><span class="linenos">2027</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"UNION</span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">by_name</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -11897,34 +12005,34 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.unnest_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.unnest_sql-2024"><a href="#Generator.unnest_sql-2024"><span class="linenos">2024</span></a> <span class="k">def</span> <span class="nf">unnest_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</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.unnest_sql-2025"><a href="#Generator.unnest_sql-2025"><span class="linenos">2025</span></a> <span class="n">args</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.unnest_sql-2026"><a href="#Generator.unnest_sql-2026"><span class="linenos">2026</span></a> -</span><span id="Generator.unnest_sql-2027"><a href="#Generator.unnest_sql-2027"><span class="linenos">2027</span></a> <span class="n">alias</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">"alias"</span><span class="p">)</span> -</span><span id="Generator.unnest_sql-2028"><a href="#Generator.unnest_sql-2028"><span class="linenos">2028</span></a> <span class="n">offset</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">"offset"</span><span class="p">)</span> -</span><span id="Generator.unnest_sql-2029"><a href="#Generator.unnest_sql-2029"><span class="linenos">2029</span></a> -</span><span id="Generator.unnest_sql-2030"><a href="#Generator.unnest_sql-2030"><span class="linenos">2030</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">UNNEST_WITH_ORDINALITY</span><span class="p">:</span> -</span><span id="Generator.unnest_sql-2031"><a href="#Generator.unnest_sql-2031"><span class="linenos">2031</span></a> <span class="k">if</span> <span class="n">alias</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">offset</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="Generator.unnest_sql-2032"><a href="#Generator.unnest_sql-2032"><span class="linenos">2032</span></a> <span class="n">alias</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"columns"</span><span class="p">,</span> <span class="n">offset</span><span class="p">)</span> -</span><span id="Generator.unnest_sql-2033"><a href="#Generator.unnest_sql-2033"><span class="linenos">2033</span></a> -</span><span id="Generator.unnest_sql-2034"><a href="#Generator.unnest_sql-2034"><span class="linenos">2034</span></a> <span class="k">if</span> <span class="n">alias</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">UNNEST_COLUMN_ONLY</span><span class="p">:</span> -</span><span id="Generator.unnest_sql-2035"><a href="#Generator.unnest_sql-2035"><span class="linenos">2035</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="n">alias</span><span class="o">.</span><span class="n">columns</span> -</span><span id="Generator.unnest_sql-2036"><a href="#Generator.unnest_sql-2036"><span class="linenos">2036</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">columns</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="k">if</span> <span class="n">columns</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.unnest_sql-2037"><a href="#Generator.unnest_sql-2037"><span class="linenos">2037</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator.unnest_sql-2038"><a href="#Generator.unnest_sql-2038"><span class="linenos">2038</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">alias</span><span class="p">)</span> -</span><span id="Generator.unnest_sql-2039"><a href="#Generator.unnest_sql-2039"><span class="linenos">2039</span></a> -</span><span id="Generator.unnest_sql-2040"><a href="#Generator.unnest_sql-2040"><span class="linenos">2040</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="n">alias</span> -</span><span id="Generator.unnest_sql-2041"><a href="#Generator.unnest_sql-2041"><span class="linenos">2041</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">UNNEST_WITH_ORDINALITY</span><span class="p">:</span> -</span><span id="Generator.unnest_sql-2042"><a href="#Generator.unnest_sql-2042"><span class="linenos">2042</span></a> <span class="n">suffix</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" WITH ORDINALITY</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">offset</span> <span class="k">else</span> <span class="n">alias</span> -</span><span id="Generator.unnest_sql-2043"><a href="#Generator.unnest_sql-2043"><span class="linenos">2043</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator.unnest_sql-2044"><a href="#Generator.unnest_sql-2044"><span class="linenos">2044</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">offset</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="Generator.unnest_sql-2045"><a href="#Generator.unnest_sql-2045"><span class="linenos">2045</span></a> <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">alias</span><span class="si">}</span><span class="s2"> WITH OFFSET 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">offset</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.unnest_sql-2046"><a href="#Generator.unnest_sql-2046"><span class="linenos">2046</span></a> <span class="k">elif</span> <span class="n">offset</span><span class="p">:</span> -</span><span id="Generator.unnest_sql-2047"><a href="#Generator.unnest_sql-2047"><span class="linenos">2047</span></a> <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">alias</span><span class="si">}</span><span class="s2"> WITH OFFSET"</span> -</span><span id="Generator.unnest_sql-2048"><a href="#Generator.unnest_sql-2048"><span class="linenos">2048</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator.unnest_sql-2049"><a href="#Generator.unnest_sql-2049"><span class="linenos">2049</span></a> <span class="n">suffix</span> <span class="o">=</span> <span class="n">alias</span> -</span><span id="Generator.unnest_sql-2050"><a href="#Generator.unnest_sql-2050"><span class="linenos">2050</span></a> -</span><span id="Generator.unnest_sql-2051"><a href="#Generator.unnest_sql-2051"><span class="linenos">2051</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"UNNEST(</span><span class="si">{</span><span class="n">args</span><span class="si">}</span><span class="s2">)</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.unnest_sql-2029"><a href="#Generator.unnest_sql-2029"><span class="linenos">2029</span></a> <span class="k">def</span> <span class="nf">unnest_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</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.unnest_sql-2030"><a href="#Generator.unnest_sql-2030"><span class="linenos">2030</span></a> <span class="n">args</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.unnest_sql-2031"><a href="#Generator.unnest_sql-2031"><span class="linenos">2031</span></a> +</span><span id="Generator.unnest_sql-2032"><a href="#Generator.unnest_sql-2032"><span class="linenos">2032</span></a> <span class="n">alias</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">"alias"</span><span class="p">)</span> +</span><span id="Generator.unnest_sql-2033"><a href="#Generator.unnest_sql-2033"><span class="linenos">2033</span></a> <span class="n">offset</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">"offset"</span><span class="p">)</span> +</span><span id="Generator.unnest_sql-2034"><a href="#Generator.unnest_sql-2034"><span class="linenos">2034</span></a> +</span><span id="Generator.unnest_sql-2035"><a href="#Generator.unnest_sql-2035"><span class="linenos">2035</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">UNNEST_WITH_ORDINALITY</span><span class="p">:</span> +</span><span id="Generator.unnest_sql-2036"><a href="#Generator.unnest_sql-2036"><span class="linenos">2036</span></a> <span class="k">if</span> <span class="n">alias</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">offset</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="Generator.unnest_sql-2037"><a href="#Generator.unnest_sql-2037"><span class="linenos">2037</span></a> <span class="n">alias</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"columns"</span><span class="p">,</span> <span class="n">offset</span><span class="p">)</span> +</span><span id="Generator.unnest_sql-2038"><a href="#Generator.unnest_sql-2038"><span class="linenos">2038</span></a> +</span><span id="Generator.unnest_sql-2039"><a href="#Generator.unnest_sql-2039"><span class="linenos">2039</span></a> <span class="k">if</span> <span class="n">alias</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">UNNEST_COLUMN_ONLY</span><span class="p">:</span> +</span><span id="Generator.unnest_sql-2040"><a href="#Generator.unnest_sql-2040"><span class="linenos">2040</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="n">alias</span><span class="o">.</span><span class="n">columns</span> +</span><span id="Generator.unnest_sql-2041"><a href="#Generator.unnest_sql-2041"><span class="linenos">2041</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">columns</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="k">if</span> <span class="n">columns</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.unnest_sql-2042"><a href="#Generator.unnest_sql-2042"><span class="linenos">2042</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator.unnest_sql-2043"><a href="#Generator.unnest_sql-2043"><span class="linenos">2043</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">alias</span><span class="p">)</span> +</span><span id="Generator.unnest_sql-2044"><a href="#Generator.unnest_sql-2044"><span class="linenos">2044</span></a> +</span><span id="Generator.unnest_sql-2045"><a href="#Generator.unnest_sql-2045"><span class="linenos">2045</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="n">alias</span> +</span><span id="Generator.unnest_sql-2046"><a href="#Generator.unnest_sql-2046"><span class="linenos">2046</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">UNNEST_WITH_ORDINALITY</span><span class="p">:</span> +</span><span id="Generator.unnest_sql-2047"><a href="#Generator.unnest_sql-2047"><span class="linenos">2047</span></a> <span class="n">suffix</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" WITH ORDINALITY</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">offset</span> <span class="k">else</span> <span class="n">alias</span> +</span><span id="Generator.unnest_sql-2048"><a href="#Generator.unnest_sql-2048"><span class="linenos">2048</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator.unnest_sql-2049"><a href="#Generator.unnest_sql-2049"><span class="linenos">2049</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">offset</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="Generator.unnest_sql-2050"><a href="#Generator.unnest_sql-2050"><span class="linenos">2050</span></a> <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">alias</span><span class="si">}</span><span class="s2"> WITH OFFSET 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">offset</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.unnest_sql-2051"><a href="#Generator.unnest_sql-2051"><span class="linenos">2051</span></a> <span class="k">elif</span> <span class="n">offset</span><span class="p">:</span> +</span><span id="Generator.unnest_sql-2052"><a href="#Generator.unnest_sql-2052"><span class="linenos">2052</span></a> <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">alias</span><span class="si">}</span><span class="s2"> WITH OFFSET"</span> +</span><span id="Generator.unnest_sql-2053"><a href="#Generator.unnest_sql-2053"><span class="linenos">2053</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator.unnest_sql-2054"><a href="#Generator.unnest_sql-2054"><span class="linenos">2054</span></a> <span class="n">suffix</span> <span class="o">=</span> <span class="n">alias</span> +</span><span id="Generator.unnest_sql-2055"><a href="#Generator.unnest_sql-2055"><span class="linenos">2055</span></a> +</span><span id="Generator.unnest_sql-2056"><a href="#Generator.unnest_sql-2056"><span class="linenos">2056</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"UNNEST(</span><span class="si">{</span><span class="n">args</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="n">suffix</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -11942,9 +12050,9 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.where_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.where_sql-2053"><a href="#Generator.where_sql-2053"><span class="linenos">2053</span></a> <span class="k">def</span> <span class="nf">where_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Where</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.where_sql-2054"><a href="#Generator.where_sql-2054"><span class="linenos">2054</span></a> <span class="n">this</span> <span class="o">=</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><span id="Generator.where_sql-2055"><a href="#Generator.where_sql-2055"><span class="linenos">2055</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="s1">'WHERE'</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="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.where_sql-2058"><a href="#Generator.where_sql-2058"><span class="linenos">2058</span></a> <span class="k">def</span> <span class="nf">where_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Where</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.where_sql-2059"><a href="#Generator.where_sql-2059"><span class="linenos">2059</span></a> <span class="n">this</span> <span class="o">=</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><span id="Generator.where_sql-2060"><a href="#Generator.where_sql-2060"><span class="linenos">2060</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="s1">'WHERE'</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="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -11962,28 +12070,28 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.window_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.window_sql-2057"><a href="#Generator.window_sql-2057"><span class="linenos">2057</span></a> <span class="k">def</span> <span class="nf">window_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Window</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.window_sql-2058"><a href="#Generator.window_sql-2058"><span class="linenos">2058</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.window_sql-2059"><a href="#Generator.window_sql-2059"><span class="linenos">2059</span></a> <span class="n">partition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">partition_by_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Generator.window_sql-2060"><a href="#Generator.window_sql-2060"><span class="linenos">2060</span></a> <span class="n">order</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">"order"</span><span class="p">)</span> -</span><span id="Generator.window_sql-2061"><a href="#Generator.window_sql-2061"><span class="linenos">2061</span></a> <span class="n">order</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">order_sql</span><span class="p">(</span><span class="n">order</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="k">if</span> <span class="n">order</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.window_sql-2062"><a href="#Generator.window_sql-2062"><span class="linenos">2062</span></a> <span class="n">spec</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"spec"</span><span class="p">)</span> -</span><span id="Generator.window_sql-2063"><a href="#Generator.window_sql-2063"><span class="linenos">2063</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.window_sql-2064"><a href="#Generator.window_sql-2064"><span class="linenos">2064</span></a> <span class="n">over</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"over"</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">"OVER"</span> -</span><span id="Generator.window_sql-2065"><a href="#Generator.window_sql-2065"><span class="linenos">2065</span></a> -</span><span id="Generator.window_sql-2066"><a href="#Generator.window_sql-2066"><span class="linenos">2066</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="si">{</span><span class="s1">'AS'</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">arg_key</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="s1">'windows'</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="n">over</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.window_sql-2067"><a href="#Generator.window_sql-2067"><span class="linenos">2067</span></a> -</span><span id="Generator.window_sql-2068"><a href="#Generator.window_sql-2068"><span class="linenos">2068</span></a> <span class="n">first</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">"first"</span><span class="p">)</span> -</span><span id="Generator.window_sql-2069"><a href="#Generator.window_sql-2069"><span class="linenos">2069</span></a> <span class="k">if</span> <span class="n">first</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Generator.window_sql-2070"><a href="#Generator.window_sql-2070"><span class="linenos">2070</span></a> <span class="n">first</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator.window_sql-2071"><a href="#Generator.window_sql-2071"><span class="linenos">2071</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator.window_sql-2072"><a href="#Generator.window_sql-2072"><span class="linenos">2072</span></a> <span class="n">first</span> <span class="o">=</span> <span class="s2">"FIRST"</span> <span class="k">if</span> <span class="n">first</span> <span class="k">else</span> <span class="s2">"LAST"</span> -</span><span id="Generator.window_sql-2073"><a href="#Generator.window_sql-2073"><span class="linenos">2073</span></a> -</span><span id="Generator.window_sql-2074"><a href="#Generator.window_sql-2074"><span class="linenos">2074</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">partition</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">order</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">spec</span> <span class="ow">and</span> <span class="n">alias</span><span class="p">:</span> -</span><span id="Generator.window_sql-2075"><a href="#Generator.window_sql-2075"><span class="linenos">2075</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">alias</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.window_sql-2076"><a href="#Generator.window_sql-2076"><span class="linenos">2076</span></a> -</span><span id="Generator.window_sql-2077"><a href="#Generator.window_sql-2077"><span class="linenos">2077</span></a> <span class="n">args</span> <span class="o">=</span> <span class="s2">" "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">arg</span> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="p">(</span><span class="n">alias</span><span class="p">,</span> <span class="n">first</span><span class="p">,</span> <span class="n">partition</span><span class="p">,</span> <span class="n">order</span><span class="p">,</span> <span class="n">spec</span><span class="p">)</span> <span class="k">if</span> <span class="n">arg</span><span class="p">)</span> -</span><span id="Generator.window_sql-2078"><a href="#Generator.window_sql-2078"><span class="linenos">2078</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">args</span><span class="si">}</span><span class="s2">)"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.window_sql-2062"><a href="#Generator.window_sql-2062"><span class="linenos">2062</span></a> <span class="k">def</span> <span class="nf">window_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Window</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.window_sql-2063"><a href="#Generator.window_sql-2063"><span class="linenos">2063</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.window_sql-2064"><a href="#Generator.window_sql-2064"><span class="linenos">2064</span></a> <span class="n">partition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">partition_by_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Generator.window_sql-2065"><a href="#Generator.window_sql-2065"><span class="linenos">2065</span></a> <span class="n">order</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">"order"</span><span class="p">)</span> +</span><span id="Generator.window_sql-2066"><a href="#Generator.window_sql-2066"><span class="linenos">2066</span></a> <span class="n">order</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">order_sql</span><span class="p">(</span><span class="n">order</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="k">if</span> <span class="n">order</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.window_sql-2067"><a href="#Generator.window_sql-2067"><span class="linenos">2067</span></a> <span class="n">spec</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"spec"</span><span class="p">)</span> +</span><span id="Generator.window_sql-2068"><a href="#Generator.window_sql-2068"><span class="linenos">2068</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.window_sql-2069"><a href="#Generator.window_sql-2069"><span class="linenos">2069</span></a> <span class="n">over</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"over"</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">"OVER"</span> +</span><span id="Generator.window_sql-2070"><a href="#Generator.window_sql-2070"><span class="linenos">2070</span></a> +</span><span id="Generator.window_sql-2071"><a href="#Generator.window_sql-2071"><span class="linenos">2071</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="si">{</span><span class="s1">'AS'</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">arg_key</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="s1">'windows'</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="n">over</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.window_sql-2072"><a href="#Generator.window_sql-2072"><span class="linenos">2072</span></a> +</span><span id="Generator.window_sql-2073"><a href="#Generator.window_sql-2073"><span class="linenos">2073</span></a> <span class="n">first</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">"first"</span><span class="p">)</span> +</span><span id="Generator.window_sql-2074"><a href="#Generator.window_sql-2074"><span class="linenos">2074</span></a> <span class="k">if</span> <span class="n">first</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Generator.window_sql-2075"><a href="#Generator.window_sql-2075"><span class="linenos">2075</span></a> <span class="n">first</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator.window_sql-2076"><a href="#Generator.window_sql-2076"><span class="linenos">2076</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator.window_sql-2077"><a href="#Generator.window_sql-2077"><span class="linenos">2077</span></a> <span class="n">first</span> <span class="o">=</span> <span class="s2">"FIRST"</span> <span class="k">if</span> <span class="n">first</span> <span class="k">else</span> <span class="s2">"LAST"</span> +</span><span id="Generator.window_sql-2078"><a href="#Generator.window_sql-2078"><span class="linenos">2078</span></a> +</span><span id="Generator.window_sql-2079"><a href="#Generator.window_sql-2079"><span class="linenos">2079</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">partition</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">order</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">spec</span> <span class="ow">and</span> <span class="n">alias</span><span class="p">:</span> +</span><span id="Generator.window_sql-2080"><a href="#Generator.window_sql-2080"><span class="linenos">2080</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">alias</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.window_sql-2081"><a href="#Generator.window_sql-2081"><span class="linenos">2081</span></a> +</span><span id="Generator.window_sql-2082"><a href="#Generator.window_sql-2082"><span class="linenos">2082</span></a> <span class="n">args</span> <span class="o">=</span> <span class="s2">" "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">arg</span> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="p">(</span><span class="n">alias</span><span class="p">,</span> <span class="n">first</span><span class="p">,</span> <span class="n">partition</span><span class="p">,</span> <span class="n">order</span><span class="p">,</span> <span class="n">spec</span><span class="p">)</span> <span class="k">if</span> <span class="n">arg</span><span class="p">)</span> +</span><span id="Generator.window_sql-2083"><a href="#Generator.window_sql-2083"><span class="linenos">2083</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">args</span><span class="si">}</span><span class="s2">)"</span> </span></pre></div> @@ -12001,9 +12109,9 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.partition_by_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.partition_by_sql-2080"><a href="#Generator.partition_by_sql-2080"><span class="linenos">2080</span></a> <span class="k">def</span> <span class="nf">partition_by_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Window</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">MatchRecognize</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.partition_by_sql-2081"><a href="#Generator.partition_by_sql-2081"><span class="linenos">2081</span></a> <span class="n">partition</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">"partition_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.partition_by_sql-2082"><a href="#Generator.partition_by_sql-2082"><span class="linenos">2082</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PARTITION BY </span><span class="si">{</span><span class="n">partition</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">partition</span> <span class="k">else</span> <span class="s2">""</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.partition_by_sql-2085"><a href="#Generator.partition_by_sql-2085"><span class="linenos">2085</span></a> <span class="k">def</span> <span class="nf">partition_by_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Window</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">MatchRecognize</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.partition_by_sql-2086"><a href="#Generator.partition_by_sql-2086"><span class="linenos">2086</span></a> <span class="n">partition</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">"partition_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.partition_by_sql-2087"><a href="#Generator.partition_by_sql-2087"><span class="linenos">2087</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PARTITION BY </span><span class="si">{</span><span class="n">partition</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">partition</span> <span class="k">else</span> <span class="s2">""</span> </span></pre></div> @@ -12021,14 +12129,14 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.windowspec_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.windowspec_sql-2084"><a href="#Generator.windowspec_sql-2084"><span class="linenos">2084</span></a> <span class="k">def</span> <span class="nf">windowspec_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">WindowSpec</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.windowspec_sql-2085"><a href="#Generator.windowspec_sql-2085"><span class="linenos">2085</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.windowspec_sql-2086"><a href="#Generator.windowspec_sql-2086"><span class="linenos">2086</span></a> <span class="n">start</span> <span class="o">=</span> <span class="n">csv</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">"start"</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">"start_side"</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.windowspec_sql-2087"><a href="#Generator.windowspec_sql-2087"><span class="linenos">2087</span></a> <span class="n">end</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Generator.windowspec_sql-2088"><a href="#Generator.windowspec_sql-2088"><span class="linenos">2088</span></a> <span class="n">csv</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">"end"</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">"end_side"</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.windowspec_sql-2089"><a href="#Generator.windowspec_sql-2089"><span class="linenos">2089</span></a> <span class="ow">or</span> <span class="s2">"CURRENT ROW"</span> -</span><span id="Generator.windowspec_sql-2090"><a href="#Generator.windowspec_sql-2090"><span class="linenos">2090</span></a> <span class="p">)</span> -</span><span id="Generator.windowspec_sql-2091"><a href="#Generator.windowspec_sql-2091"><span class="linenos">2091</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="s2"> BETWEEN </span><span class="si">{</span><span class="n">start</span><span class="si">}</span><span class="s2"> AND </span><span class="si">{</span><span class="n">end</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.windowspec_sql-2089"><a href="#Generator.windowspec_sql-2089"><span class="linenos">2089</span></a> <span class="k">def</span> <span class="nf">windowspec_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">WindowSpec</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.windowspec_sql-2090"><a href="#Generator.windowspec_sql-2090"><span class="linenos">2090</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.windowspec_sql-2091"><a href="#Generator.windowspec_sql-2091"><span class="linenos">2091</span></a> <span class="n">start</span> <span class="o">=</span> <span class="n">csv</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">"start"</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">"start_side"</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.windowspec_sql-2092"><a href="#Generator.windowspec_sql-2092"><span class="linenos">2092</span></a> <span class="n">end</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Generator.windowspec_sql-2093"><a href="#Generator.windowspec_sql-2093"><span class="linenos">2093</span></a> <span class="n">csv</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">"end"</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">"end_side"</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.windowspec_sql-2094"><a href="#Generator.windowspec_sql-2094"><span class="linenos">2094</span></a> <span class="ow">or</span> <span class="s2">"CURRENT ROW"</span> +</span><span id="Generator.windowspec_sql-2095"><a href="#Generator.windowspec_sql-2095"><span class="linenos">2095</span></a> <span class="p">)</span> +</span><span id="Generator.windowspec_sql-2096"><a href="#Generator.windowspec_sql-2096"><span class="linenos">2096</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="s2"> BETWEEN </span><span class="si">{</span><span class="n">start</span><span class="si">}</span><span class="s2"> AND </span><span class="si">{</span><span class="n">end</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -12046,10 +12154,10 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.withingroup_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.withingroup_sql-2093"><a href="#Generator.withingroup_sql-2093"><span class="linenos">2093</span></a> <span class="k">def</span> <span class="nf">withingroup_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">WithinGroup</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.withingroup_sql-2094"><a href="#Generator.withingroup_sql-2094"><span class="linenos">2094</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.withingroup_sql-2095"><a href="#Generator.withingroup_sql-2095"><span class="linenos">2095</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 class="mi">1</span><span class="p">:]</span> <span class="c1"># order has a leading space</span> -</span><span id="Generator.withingroup_sql-2096"><a href="#Generator.withingroup_sql-2096"><span class="linenos">2096</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"> WITHIN GROUP (</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.withingroup_sql-2098"><a href="#Generator.withingroup_sql-2098"><span class="linenos">2098</span></a> <span class="k">def</span> <span class="nf">withingroup_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">WithinGroup</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.withingroup_sql-2099"><a href="#Generator.withingroup_sql-2099"><span class="linenos">2099</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.withingroup_sql-2100"><a href="#Generator.withingroup_sql-2100"><span class="linenos">2100</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 class="mi">1</span><span class="p">:]</span> <span class="c1"># order has a leading space</span> +</span><span id="Generator.withingroup_sql-2101"><a href="#Generator.withingroup_sql-2101"><span class="linenos">2101</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"> WITHIN GROUP (</span><span class="si">{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">)"</span> </span></pre></div> @@ -12067,11 +12175,11 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.between_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.between_sql-2098"><a href="#Generator.between_sql-2098"><span class="linenos">2098</span></a> <span class="k">def</span> <span class="nf">between_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Between</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.between_sql-2099"><a href="#Generator.between_sql-2099"><span class="linenos">2099</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.between_sql-2100"><a href="#Generator.between_sql-2100"><span class="linenos">2100</span></a> <span class="n">low</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"low"</span><span class="p">)</span> -</span><span id="Generator.between_sql-2101"><a href="#Generator.between_sql-2101"><span class="linenos">2101</span></a> <span class="n">high</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"high"</span><span class="p">)</span> -</span><span id="Generator.between_sql-2102"><a href="#Generator.between_sql-2102"><span class="linenos">2102</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"> BETWEEN </span><span class="si">{</span><span class="n">low</span><span class="si">}</span><span class="s2"> AND </span><span class="si">{</span><span class="n">high</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.between_sql-2103"><a href="#Generator.between_sql-2103"><span class="linenos">2103</span></a> <span class="k">def</span> <span class="nf">between_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Between</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.between_sql-2104"><a href="#Generator.between_sql-2104"><span class="linenos">2104</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.between_sql-2105"><a href="#Generator.between_sql-2105"><span class="linenos">2105</span></a> <span class="n">low</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"low"</span><span class="p">)</span> +</span><span id="Generator.between_sql-2106"><a href="#Generator.between_sql-2106"><span class="linenos">2106</span></a> <span class="n">high</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"high"</span><span class="p">)</span> +</span><span id="Generator.between_sql-2107"><a href="#Generator.between_sql-2107"><span class="linenos">2107</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"> BETWEEN </span><span class="si">{</span><span class="n">low</span><span class="si">}</span><span class="s2"> AND </span><span class="si">{</span><span class="n">high</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -12089,14 +12197,14 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.bracket_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.bracket_sql-2104"><a href="#Generator.bracket_sql-2104"><span class="linenos">2104</span></a> <span class="k">def</span> <span class="nf">bracket_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Bracket</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.bracket_sql-2105"><a href="#Generator.bracket_sql-2105"><span class="linenos">2105</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="n">apply_index_offset</span><span class="p">(</span> -</span><span id="Generator.bracket_sql-2106"><a href="#Generator.bracket_sql-2106"><span class="linenos">2106</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> -</span><span id="Generator.bracket_sql-2107"><a href="#Generator.bracket_sql-2107"><span class="linenos">2107</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">,</span> -</span><span id="Generator.bracket_sql-2108"><a href="#Generator.bracket_sql-2108"><span class="linenos">2108</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">INDEX_OFFSET</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">"offset"</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> -</span><span id="Generator.bracket_sql-2109"><a href="#Generator.bracket_sql-2109"><span class="linenos">2109</span></a> <span class="p">)</span> -</span><span id="Generator.bracket_sql-2110"><a href="#Generator.bracket_sql-2110"><span class="linenos">2110</span></a> <span class="n">expressions_sql</span> <span class="o">=</span> <span class="s2">", "</span><span class="o">.</span><span class="n">join</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><span id="Generator.bracket_sql-2111"><a href="#Generator.bracket_sql-2111"><span class="linenos">2111</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">expressions_sql</span><span class="si">}</span><span class="s2">]"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.bracket_sql-2109"><a href="#Generator.bracket_sql-2109"><span class="linenos">2109</span></a> <span class="k">def</span> <span class="nf">bracket_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Bracket</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.bracket_sql-2110"><a href="#Generator.bracket_sql-2110"><span class="linenos">2110</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="n">apply_index_offset</span><span class="p">(</span> +</span><span id="Generator.bracket_sql-2111"><a href="#Generator.bracket_sql-2111"><span class="linenos">2111</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> +</span><span id="Generator.bracket_sql-2112"><a href="#Generator.bracket_sql-2112"><span class="linenos">2112</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">,</span> +</span><span id="Generator.bracket_sql-2113"><a href="#Generator.bracket_sql-2113"><span class="linenos">2113</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">INDEX_OFFSET</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">"offset"</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> +</span><span id="Generator.bracket_sql-2114"><a href="#Generator.bracket_sql-2114"><span class="linenos">2114</span></a> <span class="p">)</span> +</span><span id="Generator.bracket_sql-2115"><a href="#Generator.bracket_sql-2115"><span class="linenos">2115</span></a> <span class="n">expressions_sql</span> <span class="o">=</span> <span class="s2">", "</span><span class="o">.</span><span class="n">join</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><span id="Generator.bracket_sql-2116"><a href="#Generator.bracket_sql-2116"><span class="linenos">2116</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">expressions_sql</span><span class="si">}</span><span class="s2">]"</span> </span></pre></div> @@ -12114,8 +12222,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.all_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.all_sql-2113"><a href="#Generator.all_sql-2113"><span class="linenos">2113</span></a> <span class="k">def</span> <span class="nf">all_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">All</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.all_sql-2114"><a href="#Generator.all_sql-2114"><span class="linenos">2114</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ALL </span><span class="si">{</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 class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.all_sql-2118"><a href="#Generator.all_sql-2118"><span class="linenos">2118</span></a> <span class="k">def</span> <span class="nf">all_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">All</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.all_sql-2119"><a href="#Generator.all_sql-2119"><span class="linenos">2119</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ALL </span><span class="si">{</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 class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -12133,11 +12241,11 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.any_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.any_sql-2116"><a href="#Generator.any_sql-2116"><span class="linenos">2116</span></a> <span class="k">def</span> <span class="nf">any_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Any</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.any_sql-2117"><a href="#Generator.any_sql-2117"><span class="linenos">2117</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.any_sql-2118"><a href="#Generator.any_sql-2118"><span class="linenos">2118</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">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Subqueryable</span><span class="p">):</span> -</span><span id="Generator.any_sql-2119"><a href="#Generator.any_sql-2119"><span class="linenos">2119</span></a> <span class="n">this</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">this</span><span class="p">)</span> -</span><span id="Generator.any_sql-2120"><a href="#Generator.any_sql-2120"><span class="linenos">2120</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ANY </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.any_sql-2121"><a href="#Generator.any_sql-2121"><span class="linenos">2121</span></a> <span class="k">def</span> <span class="nf">any_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Any</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.any_sql-2122"><a href="#Generator.any_sql-2122"><span class="linenos">2122</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.any_sql-2123"><a href="#Generator.any_sql-2123"><span class="linenos">2123</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">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Subqueryable</span><span class="p">):</span> +</span><span id="Generator.any_sql-2124"><a href="#Generator.any_sql-2124"><span class="linenos">2124</span></a> <span class="n">this</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">this</span><span class="p">)</span> +</span><span id="Generator.any_sql-2125"><a href="#Generator.any_sql-2125"><span class="linenos">2125</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ANY </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -12155,8 +12263,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.exists_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.exists_sql-2122"><a href="#Generator.exists_sql-2122"><span class="linenos">2122</span></a> <span class="k">def</span> <span class="nf">exists_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Exists</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.exists_sql-2123"><a href="#Generator.exists_sql-2123"><span class="linenos">2123</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"EXISTS</span><span class="si">{</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 class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.exists_sql-2127"><a href="#Generator.exists_sql-2127"><span class="linenos">2127</span></a> <span class="k">def</span> <span class="nf">exists_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Exists</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.exists_sql-2128"><a href="#Generator.exists_sql-2128"><span class="linenos">2128</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"EXISTS</span><span class="si">{</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 class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -12174,25 +12282,25 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.case_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.case_sql-2125"><a href="#Generator.case_sql-2125"><span class="linenos">2125</span></a> <span class="k">def</span> <span class="nf">case_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</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="nb">str</span><span class="p">:</span> -</span><span id="Generator.case_sql-2126"><a href="#Generator.case_sql-2126"><span class="linenos">2126</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.case_sql-2127"><a href="#Generator.case_sql-2127"><span class="linenos">2127</span></a> <span class="n">statements</span> <span class="o">=</span> <span class="p">[</span><span class="sa">f</span><span class="s2">"CASE </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">"CASE"</span><span class="p">]</span> -</span><span id="Generator.case_sql-2128"><a href="#Generator.case_sql-2128"><span class="linenos">2128</span></a> -</span><span id="Generator.case_sql-2129"><a href="#Generator.case_sql-2129"><span class="linenos">2129</span></a> <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">args</span><span class="p">[</span><span class="s2">"ifs"</span><span class="p">]:</span> -</span><span id="Generator.case_sql-2130"><a href="#Generator.case_sql-2130"><span class="linenos">2130</span></a> <span class="n">statements</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="sa">f</span><span class="s2">"WHEN </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">e</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="p">)</span> -</span><span id="Generator.case_sql-2131"><a href="#Generator.case_sql-2131"><span class="linenos">2131</span></a> <span class="n">statements</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="sa">f</span><span class="s2">"THEN </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">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'true'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="Generator.case_sql-2132"><a href="#Generator.case_sql-2132"><span class="linenos">2132</span></a> -</span><span id="Generator.case_sql-2133"><a href="#Generator.case_sql-2133"><span class="linenos">2133</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.case_sql-2134"><a href="#Generator.case_sql-2134"><span class="linenos">2134</span></a> -</span><span id="Generator.case_sql-2135"><a href="#Generator.case_sql-2135"><span class="linenos">2135</span></a> <span class="k">if</span> <span class="n">default</span><span class="p">:</span> -</span><span id="Generator.case_sql-2136"><a href="#Generator.case_sql-2136"><span class="linenos">2136</span></a> <span class="n">statements</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="sa">f</span><span class="s2">"ELSE </span><span class="si">{</span><span class="n">default</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.case_sql-2130"><a href="#Generator.case_sql-2130"><span class="linenos">2130</span></a> <span class="k">def</span> <span class="nf">case_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</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="nb">str</span><span class="p">:</span> +</span><span id="Generator.case_sql-2131"><a href="#Generator.case_sql-2131"><span class="linenos">2131</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.case_sql-2132"><a href="#Generator.case_sql-2132"><span class="linenos">2132</span></a> <span class="n">statements</span> <span class="o">=</span> <span class="p">[</span><span class="sa">f</span><span class="s2">"CASE </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">"CASE"</span><span class="p">]</span> +</span><span id="Generator.case_sql-2133"><a href="#Generator.case_sql-2133"><span class="linenos">2133</span></a> +</span><span id="Generator.case_sql-2134"><a href="#Generator.case_sql-2134"><span class="linenos">2134</span></a> <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">args</span><span class="p">[</span><span class="s2">"ifs"</span><span class="p">]:</span> +</span><span id="Generator.case_sql-2135"><a href="#Generator.case_sql-2135"><span class="linenos">2135</span></a> <span class="n">statements</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="sa">f</span><span class="s2">"WHEN </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">e</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="p">)</span> +</span><span id="Generator.case_sql-2136"><a href="#Generator.case_sql-2136"><span class="linenos">2136</span></a> <span class="n">statements</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="sa">f</span><span class="s2">"THEN </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">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'true'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> </span><span id="Generator.case_sql-2137"><a href="#Generator.case_sql-2137"><span class="linenos">2137</span></a> -</span><span id="Generator.case_sql-2138"><a href="#Generator.case_sql-2138"><span class="linenos">2138</span></a> <span class="n">statements</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"END"</span><span class="p">)</span> +</span><span id="Generator.case_sql-2138"><a href="#Generator.case_sql-2138"><span class="linenos">2138</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.case_sql-2139"><a href="#Generator.case_sql-2139"><span class="linenos">2139</span></a> -</span><span id="Generator.case_sql-2140"><a href="#Generator.case_sql-2140"><span class="linenos">2140</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">statements</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.case_sql-2141"><a href="#Generator.case_sql-2141"><span class="linenos">2141</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="n">join</span><span class="p">(</span><span class="n">statements</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.case_sql-2140"><a href="#Generator.case_sql-2140"><span class="linenos">2140</span></a> <span class="k">if</span> <span class="n">default</span><span class="p">:</span> +</span><span id="Generator.case_sql-2141"><a href="#Generator.case_sql-2141"><span class="linenos">2141</span></a> <span class="n">statements</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="sa">f</span><span class="s2">"ELSE </span><span class="si">{</span><span class="n">default</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> </span><span id="Generator.case_sql-2142"><a href="#Generator.case_sql-2142"><span class="linenos">2142</span></a> -</span><span id="Generator.case_sql-2143"><a href="#Generator.case_sql-2143"><span class="linenos">2143</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">statements</span><span class="p">)</span> +</span><span id="Generator.case_sql-2143"><a href="#Generator.case_sql-2143"><span class="linenos">2143</span></a> <span class="n">statements</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"END"</span><span class="p">)</span> +</span><span id="Generator.case_sql-2144"><a href="#Generator.case_sql-2144"><span class="linenos">2144</span></a> +</span><span id="Generator.case_sql-2145"><a href="#Generator.case_sql-2145"><span class="linenos">2145</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">statements</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.case_sql-2146"><a href="#Generator.case_sql-2146"><span class="linenos">2146</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="n">join</span><span class="p">(</span><span class="n">statements</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.case_sql-2147"><a href="#Generator.case_sql-2147"><span class="linenos">2147</span></a> +</span><span id="Generator.case_sql-2148"><a href="#Generator.case_sql-2148"><span class="linenos">2148</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">statements</span><span class="p">)</span> </span></pre></div> @@ -12210,10 +12318,10 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.constraint_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.constraint_sql-2145"><a href="#Generator.constraint_sql-2145"><span class="linenos">2145</span></a> <span class="k">def</span> <span class="nf">constraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Constraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.constraint_sql-2146"><a href="#Generator.constraint_sql-2146"><span class="linenos">2146</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.constraint_sql-2147"><a href="#Generator.constraint_sql-2147"><span class="linenos">2147</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.constraint_sql-2148"><a href="#Generator.constraint_sql-2148"><span class="linenos">2148</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CONSTRAINT </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.constraint_sql-2150"><a href="#Generator.constraint_sql-2150"><span class="linenos">2150</span></a> <span class="k">def</span> <span class="nf">constraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Constraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.constraint_sql-2151"><a href="#Generator.constraint_sql-2151"><span class="linenos">2151</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.constraint_sql-2152"><a href="#Generator.constraint_sql-2152"><span class="linenos">2152</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.constraint_sql-2153"><a href="#Generator.constraint_sql-2153"><span class="linenos">2153</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CONSTRAINT </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> @@ -12231,10 +12339,10 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.nextvaluefor_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.nextvaluefor_sql-2150"><a href="#Generator.nextvaluefor_sql-2150"><span class="linenos">2150</span></a> <span class="k">def</span> <span class="nf">nextvaluefor_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">NextValueFor</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.nextvaluefor_sql-2151"><a href="#Generator.nextvaluefor_sql-2151"><span class="linenos">2151</span></a> <span class="n">order</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">"order"</span><span class="p">)</span> -</span><span id="Generator.nextvaluefor_sql-2152"><a href="#Generator.nextvaluefor_sql-2152"><span class="linenos">2152</span></a> <span class="n">order</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" OVER (</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">order_sql</span><span class="p">(</span><span class="n">order</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 class="k">if</span> <span class="n">order</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.nextvaluefor_sql-2153"><a href="#Generator.nextvaluefor_sql-2153"><span class="linenos">2153</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"NEXT VALUE FOR </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">order</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.nextvaluefor_sql-2155"><a href="#Generator.nextvaluefor_sql-2155"><span class="linenos">2155</span></a> <span class="k">def</span> <span class="nf">nextvaluefor_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">NextValueFor</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.nextvaluefor_sql-2156"><a href="#Generator.nextvaluefor_sql-2156"><span class="linenos">2156</span></a> <span class="n">order</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">"order"</span><span class="p">)</span> +</span><span id="Generator.nextvaluefor_sql-2157"><a href="#Generator.nextvaluefor_sql-2157"><span class="linenos">2157</span></a> <span class="n">order</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" OVER (</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">order_sql</span><span class="p">(</span><span class="n">order</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 class="k">if</span> <span class="n">order</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.nextvaluefor_sql-2158"><a href="#Generator.nextvaluefor_sql-2158"><span class="linenos">2158</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"NEXT VALUE FOR </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">order</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -12252,10 +12360,10 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.extract_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.extract_sql-2155"><a href="#Generator.extract_sql-2155"><span class="linenos">2155</span></a> <span class="k">def</span> <span class="nf">extract_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Extract</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.extract_sql-2156"><a href="#Generator.extract_sql-2156"><span class="linenos">2156</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 class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">EXTRACT_ALLOWS_QUOTES</span> <span class="k">else</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><span id="Generator.extract_sql-2157"><a href="#Generator.extract_sql-2157"><span class="linenos">2157</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.extract_sql-2158"><a href="#Generator.extract_sql-2158"><span class="linenos">2158</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"EXTRACT(</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> FROM </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.extract_sql-2160"><a href="#Generator.extract_sql-2160"><span class="linenos">2160</span></a> <span class="k">def</span> <span class="nf">extract_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Extract</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.extract_sql-2161"><a href="#Generator.extract_sql-2161"><span class="linenos">2161</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 class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">EXTRACT_ALLOWS_QUOTES</span> <span class="k">else</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><span id="Generator.extract_sql-2162"><a href="#Generator.extract_sql-2162"><span class="linenos">2162</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.extract_sql-2163"><a href="#Generator.extract_sql-2163"><span class="linenos">2163</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"EXTRACT(</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> FROM </span><span class="si">{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">)"</span> </span></pre></div> @@ -12273,15 +12381,44 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.trim_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.trim_sql-2160"><a href="#Generator.trim_sql-2160"><span class="linenos">2160</span></a> <span class="k">def</span> <span class="nf">trim_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Trim</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.trim_sql-2161"><a href="#Generator.trim_sql-2161"><span class="linenos">2161</span></a> <span class="n">trim_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">"position"</span><span class="p">)</span> -</span><span id="Generator.trim_sql-2162"><a href="#Generator.trim_sql-2162"><span class="linenos">2162</span></a> -</span><span id="Generator.trim_sql-2163"><a href="#Generator.trim_sql-2163"><span class="linenos">2163</span></a> <span class="k">if</span> <span class="n">trim_type</span> <span class="o">==</span> <span class="s2">"LEADING"</span><span class="p">:</span> -</span><span id="Generator.trim_sql-2164"><a href="#Generator.trim_sql-2164"><span class="linenos">2164</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">"LTRIM"</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.trim_sql-2165"><a href="#Generator.trim_sql-2165"><span class="linenos">2165</span></a> <span class="k">elif</span> <span class="n">trim_type</span> <span class="o">==</span> <span class="s2">"TRAILING"</span><span class="p">:</span> -</span><span id="Generator.trim_sql-2166"><a href="#Generator.trim_sql-2166"><span class="linenos">2166</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">"RTRIM"</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.trim_sql-2167"><a href="#Generator.trim_sql-2167"><span class="linenos">2167</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator.trim_sql-2168"><a href="#Generator.trim_sql-2168"><span class="linenos">2168</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">"TRIM"</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="n">expression</span><span class="o">.</span><span class="n">expression</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.trim_sql-2165"><a href="#Generator.trim_sql-2165"><span class="linenos">2165</span></a> <span class="k">def</span> <span class="nf">trim_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Trim</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.trim_sql-2166"><a href="#Generator.trim_sql-2166"><span class="linenos">2166</span></a> <span class="n">trim_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">"position"</span><span class="p">)</span> +</span><span id="Generator.trim_sql-2167"><a href="#Generator.trim_sql-2167"><span class="linenos">2167</span></a> +</span><span id="Generator.trim_sql-2168"><a href="#Generator.trim_sql-2168"><span class="linenos">2168</span></a> <span class="k">if</span> <span class="n">trim_type</span> <span class="o">==</span> <span class="s2">"LEADING"</span><span class="p">:</span> +</span><span id="Generator.trim_sql-2169"><a href="#Generator.trim_sql-2169"><span class="linenos">2169</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">"LTRIM"</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.trim_sql-2170"><a href="#Generator.trim_sql-2170"><span class="linenos">2170</span></a> <span class="k">elif</span> <span class="n">trim_type</span> <span class="o">==</span> <span class="s2">"TRAILING"</span><span class="p">:</span> +</span><span id="Generator.trim_sql-2171"><a href="#Generator.trim_sql-2171"><span class="linenos">2171</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">"RTRIM"</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.trim_sql-2172"><a href="#Generator.trim_sql-2172"><span class="linenos">2172</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator.trim_sql-2173"><a href="#Generator.trim_sql-2173"><span class="linenos">2173</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">"TRIM"</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="n">expression</span><span class="o">.</span><span class="n">expression</span><span class="p">)</span> +</span></pre></div> + + + + + </div> + <div id="Generator.convert_concat_args" class="classattr"> + <input id="Generator.convert_concat_args-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">convert_concat_args</span><span class="signature pdoc-code multiline">(<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#Concat">sqlglot.expressions.Concat</a></span> <span class="o">|</span> <span class="n"><a href="expressions.html#ConcatWs">sqlglot.expressions.ConcatWs</a></span></span><span class="return-annotation">) -> <span class="n">List</span><span class="p">[</span><span class="n"><a href="expressions.html#Expression">sqlglot.expressions.Expression</a></span><span class="p">]</span>:</span></span> + + <label class="view-source-button" for="Generator.convert_concat_args-view-source"><span>View Source</span></label> + + </div> + <a class="headerlink" href="#Generator.convert_concat_args"></a> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.convert_concat_args-2175"><a href="#Generator.convert_concat_args-2175"><span class="linenos">2175</span></a> <span class="k">def</span> <span class="nf">convert_concat_args</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Concat</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">ConcatWs</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]:</span> +</span><span id="Generator.convert_concat_args-2176"><a href="#Generator.convert_concat_args-2176"><span class="linenos">2176</span></a> <span class="n">args</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> +</span><span id="Generator.convert_concat_args-2177"><a href="#Generator.convert_concat_args-2177"><span class="linenos">2177</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">ConcatWs</span><span class="p">):</span> +</span><span id="Generator.convert_concat_args-2178"><a href="#Generator.convert_concat_args-2178"><span class="linenos">2178</span></a> <span class="n">args</span> <span class="o">=</span> <span class="n">args</span><span class="p">[</span><span class="mi">1</span><span class="p">:]</span> <span class="c1"># Skip the delimiter</span> +</span><span id="Generator.convert_concat_args-2179"><a href="#Generator.convert_concat_args-2179"><span class="linenos">2179</span></a> +</span><span id="Generator.convert_concat_args-2180"><a href="#Generator.convert_concat_args-2180"><span class="linenos">2180</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">STRICT_STRING_CONCAT</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">"safe"</span><span class="p">):</span> +</span><span id="Generator.convert_concat_args-2181"><a href="#Generator.convert_concat_args-2181"><span class="linenos">2181</span></a> <span class="n">args</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">args</span><span class="p">]</span> +</span><span id="Generator.convert_concat_args-2182"><a href="#Generator.convert_concat_args-2182"><span class="linenos">2182</span></a> +</span><span id="Generator.convert_concat_args-2183"><a href="#Generator.convert_concat_args-2183"><span class="linenos">2183</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">CONCAT_COALESCE</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">"coalesce"</span><span class="p">):</span> +</span><span id="Generator.convert_concat_args-2184"><a href="#Generator.convert_concat_args-2184"><span class="linenos">2184</span></a> <span class="n">args</span> <span class="o">=</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="s2">"coalesce"</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">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="s2">""</span><span class="p">))</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">args</span><span class="p">]</span> +</span><span id="Generator.convert_concat_args-2185"><a href="#Generator.convert_concat_args-2185"><span class="linenos">2185</span></a> +</span><span id="Generator.convert_concat_args-2186"><a href="#Generator.convert_concat_args-2186"><span class="linenos">2186</span></a> <span class="k">return</span> <span class="n">args</span> </span></pre></div> @@ -12299,11 +12436,35 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.concat_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.concat_sql-2170"><a href="#Generator.concat_sql-2170"><span class="linenos">2170</span></a> <span class="k">def</span> <span class="nf">concat_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Concat</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.concat_sql-2171"><a href="#Generator.concat_sql-2171"><span class="linenos">2171</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> -</span><span id="Generator.concat_sql-2172"><a href="#Generator.concat_sql-2172"><span class="linenos">2172</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">STRICT_STRING_CONCAT</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">"safe"</span><span class="p">):</span> -</span><span id="Generator.concat_sql-2173"><a href="#Generator.concat_sql-2173"><span class="linenos">2173</span></a> <span class="n">expressions</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">expressions</span><span class="p">]</span> -</span><span id="Generator.concat_sql-2174"><a href="#Generator.concat_sql-2174"><span class="linenos">2174</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="n">expressions</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.concat_sql-2188"><a href="#Generator.concat_sql-2188"><span class="linenos">2188</span></a> <span class="k">def</span> <span class="nf">concat_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Concat</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.concat_sql-2189"><a href="#Generator.concat_sql-2189"><span class="linenos">2189</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">convert_concat_args</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Generator.concat_sql-2190"><a href="#Generator.concat_sql-2190"><span class="linenos">2190</span></a> +</span><span id="Generator.concat_sql-2191"><a href="#Generator.concat_sql-2191"><span class="linenos">2191</span></a> <span class="c1"># Some dialects don't allow a single-argument CONCAT call</span> +</span><span id="Generator.concat_sql-2192"><a href="#Generator.concat_sql-2192"><span class="linenos">2192</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">SUPPORTS_SINGLE_ARG_CONCAT</span> <span class="ow">and</span> <span class="nb">len</span><span class="p">(</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.concat_sql-2193"><a href="#Generator.concat_sql-2193"><span class="linenos">2193</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">expressions</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> +</span><span id="Generator.concat_sql-2194"><a href="#Generator.concat_sql-2194"><span class="linenos">2194</span></a> +</span><span id="Generator.concat_sql-2195"><a href="#Generator.concat_sql-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">"CONCAT"</span><span class="p">,</span> <span class="o">*</span><span class="n">expressions</span><span class="p">)</span> +</span></pre></div> + + + + + </div> + <div id="Generator.concatws_sql" class="classattr"> + <input id="Generator.concatws_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">concatws_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#ConcatWs">sqlglot.expressions.ConcatWs</a></span></span><span class="return-annotation">) -> <span class="nb">str</span>:</span></span> + + <label class="view-source-button" for="Generator.concatws_sql-view-source"><span>View Source</span></label> + + </div> + <a class="headerlink" href="#Generator.concatws_sql"></a> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.concatws_sql-2197"><a href="#Generator.concatws_sql-2197"><span class="linenos">2197</span></a> <span class="k">def</span> <span class="nf">concatws_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ConcatWs</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.concatws_sql-2198"><a href="#Generator.concatws_sql-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="Generator.concatws_sql-2199"><a href="#Generator.concatws_sql-2199"><span class="linenos">2199</span></a> <span class="s2">"CONCAT_WS"</span><span class="p">,</span> <span class="n">seq_get</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="mi">0</span><span class="p">),</span> <span class="o">*</span><span class="bp">self</span><span class="o">.</span><span class="n">convert_concat_args</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Generator.concatws_sql-2200"><a href="#Generator.concatws_sql-2200"><span class="linenos">2200</span></a> <span class="p">)</span> </span></pre></div> @@ -12321,9 +12482,9 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.check_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.check_sql-2176"><a href="#Generator.check_sql-2176"><span class="linenos">2176</span></a> <span class="k">def</span> <span class="nf">check_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Check</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.check_sql-2177"><a href="#Generator.check_sql-2177"><span class="linenos">2177</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="n">key</span><span class="o">=</span><span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.check_sql-2178"><a href="#Generator.check_sql-2178"><span class="linenos">2178</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CHECK (</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.check_sql-2202"><a href="#Generator.check_sql-2202"><span class="linenos">2202</span></a> <span class="k">def</span> <span class="nf">check_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Check</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.check_sql-2203"><a href="#Generator.check_sql-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="n">key</span><span class="o">=</span><span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.check_sql-2204"><a href="#Generator.check_sql-2204"><span class="linenos">2204</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CHECK (</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">)"</span> </span></pre></div> @@ -12341,15 +12502,15 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.foreignkey_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.foreignkey_sql-2180"><a href="#Generator.foreignkey_sql-2180"><span class="linenos">2180</span></a> <span class="k">def</span> <span class="nf">foreignkey_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ForeignKey</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.foreignkey_sql-2181"><a href="#Generator.foreignkey_sql-2181"><span class="linenos">2181</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.foreignkey_sql-2182"><a href="#Generator.foreignkey_sql-2182"><span class="linenos">2182</span></a> <span class="n">reference</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"reference"</span><span class="p">)</span> -</span><span id="Generator.foreignkey_sql-2183"><a href="#Generator.foreignkey_sql-2183"><span class="linenos">2183</span></a> <span class="n">reference</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">reference</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">reference</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.foreignkey_sql-2184"><a href="#Generator.foreignkey_sql-2184"><span class="linenos">2184</span></a> <span class="n">delete</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"delete"</span><span class="p">)</span> -</span><span id="Generator.foreignkey_sql-2185"><a href="#Generator.foreignkey_sql-2185"><span class="linenos">2185</span></a> <span class="n">delete</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" ON DELETE </span><span class="si">{</span><span class="n">delete</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">delete</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.foreignkey_sql-2186"><a href="#Generator.foreignkey_sql-2186"><span class="linenos">2186</span></a> <span class="n">update</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"update"</span><span class="p">)</span> -</span><span id="Generator.foreignkey_sql-2187"><a href="#Generator.foreignkey_sql-2187"><span class="linenos">2187</span></a> <span class="n">update</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" ON UPDATE </span><span class="si">{</span><span class="n">update</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">update</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.foreignkey_sql-2188"><a href="#Generator.foreignkey_sql-2188"><span class="linenos">2188</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"FOREIGN KEY (</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">reference</span><span class="si">}{</span><span class="n">delete</span><span class="si">}{</span><span class="n">update</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.foreignkey_sql-2206"><a href="#Generator.foreignkey_sql-2206"><span class="linenos">2206</span></a> <span class="k">def</span> <span class="nf">foreignkey_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ForeignKey</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.foreignkey_sql-2207"><a href="#Generator.foreignkey_sql-2207"><span class="linenos">2207</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.foreignkey_sql-2208"><a href="#Generator.foreignkey_sql-2208"><span class="linenos">2208</span></a> <span class="n">reference</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"reference"</span><span class="p">)</span> +</span><span id="Generator.foreignkey_sql-2209"><a href="#Generator.foreignkey_sql-2209"><span class="linenos">2209</span></a> <span class="n">reference</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">reference</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">reference</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.foreignkey_sql-2210"><a href="#Generator.foreignkey_sql-2210"><span class="linenos">2210</span></a> <span class="n">delete</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"delete"</span><span class="p">)</span> +</span><span id="Generator.foreignkey_sql-2211"><a href="#Generator.foreignkey_sql-2211"><span class="linenos">2211</span></a> <span class="n">delete</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" ON DELETE </span><span class="si">{</span><span class="n">delete</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">delete</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.foreignkey_sql-2212"><a href="#Generator.foreignkey_sql-2212"><span class="linenos">2212</span></a> <span class="n">update</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"update"</span><span class="p">)</span> +</span><span id="Generator.foreignkey_sql-2213"><a href="#Generator.foreignkey_sql-2213"><span class="linenos">2213</span></a> <span class="n">update</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" ON UPDATE </span><span class="si">{</span><span class="n">update</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">update</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.foreignkey_sql-2214"><a href="#Generator.foreignkey_sql-2214"><span class="linenos">2214</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"FOREIGN KEY (</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">reference</span><span class="si">}{</span><span class="n">delete</span><span class="si">}{</span><span class="n">update</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -12367,11 +12528,11 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.primarykey_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.primarykey_sql-2190"><a href="#Generator.primarykey_sql-2190"><span class="linenos">2190</span></a> <span class="k">def</span> <span class="nf">primarykey_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ForeignKey</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.primarykey_sql-2191"><a href="#Generator.primarykey_sql-2191"><span class="linenos">2191</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.primarykey_sql-2192"><a href="#Generator.primarykey_sql-2192"><span class="linenos">2192</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.primarykey_sql-2193"><a href="#Generator.primarykey_sql-2193"><span class="linenos">2193</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.primarykey_sql-2194"><a href="#Generator.primarykey_sql-2194"><span class="linenos">2194</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PRIMARY KEY (</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">options</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.primarykey_sql-2216"><a href="#Generator.primarykey_sql-2216"><span class="linenos">2216</span></a> <span class="k">def</span> <span class="nf">primarykey_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ForeignKey</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.primarykey_sql-2217"><a href="#Generator.primarykey_sql-2217"><span class="linenos">2217</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.primarykey_sql-2218"><a href="#Generator.primarykey_sql-2218"><span class="linenos">2218</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.primarykey_sql-2219"><a href="#Generator.primarykey_sql-2219"><span class="linenos">2219</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.primarykey_sql-2220"><a href="#Generator.primarykey_sql-2220"><span class="linenos">2220</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PRIMARY KEY (</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">options</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -12389,8 +12550,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.if_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.if_sql-2196"><a href="#Generator.if_sql-2196"><span class="linenos">2196</span></a> <span class="k">def</span> <span class="nf">if_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">If</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.if_sql-2197"><a href="#Generator.if_sql-2197"><span class="linenos">2197</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">case_sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Case</span><span class="p">(</span><span class="n">ifs</span><span class="o">=</span><span class="p">[</span><span class="n">expression</span><span class="p">],</span> <span class="n">default</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> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.if_sql-2222"><a href="#Generator.if_sql-2222"><span class="linenos">2222</span></a> <span class="k">def</span> <span class="nf">if_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">If</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.if_sql-2223"><a href="#Generator.if_sql-2223"><span class="linenos">2223</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">case_sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Case</span><span class="p">(</span><span class="n">ifs</span><span class="o">=</span><span class="p">[</span><span class="n">expression</span><span class="p">],</span> <span class="n">default</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></pre></div> @@ -12408,10 +12569,10 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.matchagainst_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.matchagainst_sql-2199"><a href="#Generator.matchagainst_sql-2199"><span class="linenos">2199</span></a> <span class="k">def</span> <span class="nf">matchagainst_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">MatchAgainst</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.matchagainst_sql-2200"><a href="#Generator.matchagainst_sql-2200"><span class="linenos">2200</span></a> <span class="n">modifier</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">"modifier"</span><span class="p">)</span> -</span><span id="Generator.matchagainst_sql-2201"><a href="#Generator.matchagainst_sql-2201"><span class="linenos">2201</span></a> <span class="n">modifier</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">modifier</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">modifier</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.matchagainst_sql-2202"><a href="#Generator.matchagainst_sql-2202"><span class="linenos">2202</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">func</span><span class="p">(</span><span class="s1">'MATCH'</span><span class="p">,</span><span class="w"> </span><span class="o">*</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span><span class="si">}</span><span class="s2"> AGAINST(</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">modifier</span><span class="si">}</span><span class="s2">)"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.matchagainst_sql-2225"><a href="#Generator.matchagainst_sql-2225"><span class="linenos">2225</span></a> <span class="k">def</span> <span class="nf">matchagainst_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">MatchAgainst</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.matchagainst_sql-2226"><a href="#Generator.matchagainst_sql-2226"><span class="linenos">2226</span></a> <span class="n">modifier</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">"modifier"</span><span class="p">)</span> +</span><span id="Generator.matchagainst_sql-2227"><a href="#Generator.matchagainst_sql-2227"><span class="linenos">2227</span></a> <span class="n">modifier</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">modifier</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">modifier</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.matchagainst_sql-2228"><a href="#Generator.matchagainst_sql-2228"><span class="linenos">2228</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">func</span><span class="p">(</span><span class="s1">'MATCH'</span><span class="p">,</span><span class="w"> </span><span class="o">*</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span><span class="si">}</span><span class="s2"> AGAINST(</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">modifier</span><span class="si">}</span><span class="s2">)"</span> </span></pre></div> @@ -12429,8 +12590,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.jsonkeyvalue_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.jsonkeyvalue_sql-2204"><a href="#Generator.jsonkeyvalue_sql-2204"><span class="linenos">2204</span></a> <span class="k">def</span> <span class="nf">jsonkeyvalue_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">JSONKeyValue</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.jsonkeyvalue_sql-2205"><a href="#Generator.jsonkeyvalue_sql-2205"><span class="linenos">2205</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.jsonkeyvalue_sql-2230"><a href="#Generator.jsonkeyvalue_sql-2230"><span class="linenos">2230</span></a> <span class="k">def</span> <span class="nf">jsonkeyvalue_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">JSONKeyValue</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.jsonkeyvalue_sql-2231"><a href="#Generator.jsonkeyvalue_sql-2231"><span class="linenos">2231</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> @@ -12448,8 +12609,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.formatjson_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.formatjson_sql-2207"><a href="#Generator.formatjson_sql-2207"><span class="linenos">2207</span></a> <span class="k">def</span> <span class="nf">formatjson_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">FormatJson</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.formatjson_sql-2208"><a href="#Generator.formatjson_sql-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="bp">self</span><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"> FORMAT JSON"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.formatjson_sql-2233"><a href="#Generator.formatjson_sql-2233"><span class="linenos">2233</span></a> <span class="k">def</span> <span class="nf">formatjson_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">FormatJson</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.formatjson_sql-2234"><a href="#Generator.formatjson_sql-2234"><span class="linenos">2234</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"> FORMAT JSON"</span> </span></pre></div> @@ -12467,23 +12628,23 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.jsonobject_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.jsonobject_sql-2210"><a href="#Generator.jsonobject_sql-2210"><span class="linenos">2210</span></a> <span class="k">def</span> <span class="nf">jsonobject_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">JSONObject</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.jsonobject_sql-2211"><a href="#Generator.jsonobject_sql-2211"><span class="linenos">2211</span></a> <span class="n">null_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">"null_handling"</span><span class="p">)</span> -</span><span id="Generator.jsonobject_sql-2212"><a href="#Generator.jsonobject_sql-2212"><span class="linenos">2212</span></a> <span class="n">null_handling</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">null_handling</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">null_handling</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.jsonobject_sql-2213"><a href="#Generator.jsonobject_sql-2213"><span class="linenos">2213</span></a> <span class="n">unique_keys</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">"unique_keys"</span><span class="p">)</span> -</span><span id="Generator.jsonobject_sql-2214"><a href="#Generator.jsonobject_sql-2214"><span class="linenos">2214</span></a> <span class="k">if</span> <span class="n">unique_keys</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Generator.jsonobject_sql-2215"><a href="#Generator.jsonobject_sql-2215"><span class="linenos">2215</span></a> <span class="n">unique_keys</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="s1">'WITH'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">unique_keys</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">'WITHOUT'</span><span class="si">}</span><span class="s2"> UNIQUE KEYS"</span> -</span><span id="Generator.jsonobject_sql-2216"><a href="#Generator.jsonobject_sql-2216"><span class="linenos">2216</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator.jsonobject_sql-2217"><a href="#Generator.jsonobject_sql-2217"><span class="linenos">2217</span></a> <span class="n">unique_keys</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator.jsonobject_sql-2218"><a href="#Generator.jsonobject_sql-2218"><span class="linenos">2218</span></a> <span class="n">return_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">"return_type"</span><span class="p">)</span> -</span><span id="Generator.jsonobject_sql-2219"><a href="#Generator.jsonobject_sql-2219"><span class="linenos">2219</span></a> <span class="n">return_type</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" RETURNING </span><span class="si">{</span><span class="n">return_type</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">return_type</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.jsonobject_sql-2220"><a href="#Generator.jsonobject_sql-2220"><span class="linenos">2220</span></a> <span class="n">encoding</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"encoding"</span><span class="p">)</span> -</span><span id="Generator.jsonobject_sql-2221"><a href="#Generator.jsonobject_sql-2221"><span class="linenos">2221</span></a> <span class="n">encoding</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" ENCODING </span><span class="si">{</span><span class="n">encoding</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">encoding</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.jsonobject_sql-2222"><a href="#Generator.jsonobject_sql-2222"><span class="linenos">2222</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.jsonobject_sql-2223"><a href="#Generator.jsonobject_sql-2223"><span class="linenos">2223</span></a> <span class="s2">"JSON_OBJECT"</span><span class="p">,</span> -</span><span id="Generator.jsonobject_sql-2224"><a href="#Generator.jsonobject_sql-2224"><span class="linenos">2224</span></a> <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.jsonobject_sql-2225"><a href="#Generator.jsonobject_sql-2225"><span class="linenos">2225</span></a> <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">null_handling</span><span class="si">}{</span><span class="n">unique_keys</span><span class="si">}{</span><span class="n">return_type</span><span class="si">}{</span><span class="n">encoding</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="Generator.jsonobject_sql-2226"><a href="#Generator.jsonobject_sql-2226"><span class="linenos">2226</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.jsonobject_sql-2236"><a href="#Generator.jsonobject_sql-2236"><span class="linenos">2236</span></a> <span class="k">def</span> <span class="nf">jsonobject_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">JSONObject</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.jsonobject_sql-2237"><a href="#Generator.jsonobject_sql-2237"><span class="linenos">2237</span></a> <span class="n">null_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">"null_handling"</span><span class="p">)</span> +</span><span id="Generator.jsonobject_sql-2238"><a href="#Generator.jsonobject_sql-2238"><span class="linenos">2238</span></a> <span class="n">null_handling</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">null_handling</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">null_handling</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.jsonobject_sql-2239"><a href="#Generator.jsonobject_sql-2239"><span class="linenos">2239</span></a> <span class="n">unique_keys</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">"unique_keys"</span><span class="p">)</span> +</span><span id="Generator.jsonobject_sql-2240"><a href="#Generator.jsonobject_sql-2240"><span class="linenos">2240</span></a> <span class="k">if</span> <span class="n">unique_keys</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Generator.jsonobject_sql-2241"><a href="#Generator.jsonobject_sql-2241"><span class="linenos">2241</span></a> <span class="n">unique_keys</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="s1">'WITH'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">unique_keys</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">'WITHOUT'</span><span class="si">}</span><span class="s2"> UNIQUE KEYS"</span> +</span><span id="Generator.jsonobject_sql-2242"><a href="#Generator.jsonobject_sql-2242"><span class="linenos">2242</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator.jsonobject_sql-2243"><a href="#Generator.jsonobject_sql-2243"><span class="linenos">2243</span></a> <span class="n">unique_keys</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator.jsonobject_sql-2244"><a href="#Generator.jsonobject_sql-2244"><span class="linenos">2244</span></a> <span class="n">return_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">"return_type"</span><span class="p">)</span> +</span><span id="Generator.jsonobject_sql-2245"><a href="#Generator.jsonobject_sql-2245"><span class="linenos">2245</span></a> <span class="n">return_type</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" RETURNING </span><span class="si">{</span><span class="n">return_type</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">return_type</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.jsonobject_sql-2246"><a href="#Generator.jsonobject_sql-2246"><span class="linenos">2246</span></a> <span class="n">encoding</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"encoding"</span><span class="p">)</span> +</span><span id="Generator.jsonobject_sql-2247"><a href="#Generator.jsonobject_sql-2247"><span class="linenos">2247</span></a> <span class="n">encoding</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" ENCODING </span><span class="si">{</span><span class="n">encoding</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">encoding</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.jsonobject_sql-2248"><a href="#Generator.jsonobject_sql-2248"><span class="linenos">2248</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.jsonobject_sql-2249"><a href="#Generator.jsonobject_sql-2249"><span class="linenos">2249</span></a> <span class="s2">"JSON_OBJECT"</span><span class="p">,</span> +</span><span id="Generator.jsonobject_sql-2250"><a href="#Generator.jsonobject_sql-2250"><span class="linenos">2250</span></a> <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.jsonobject_sql-2251"><a href="#Generator.jsonobject_sql-2251"><span class="linenos">2251</span></a> <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">null_handling</span><span class="si">}{</span><span class="n">unique_keys</span><span class="si">}{</span><span class="n">return_type</span><span class="si">}{</span><span class="n">encoding</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="Generator.jsonobject_sql-2252"><a href="#Generator.jsonobject_sql-2252"><span class="linenos">2252</span></a> <span class="p">)</span> </span></pre></div> @@ -12501,15 +12662,15 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.jsonarray_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.jsonarray_sql-2228"><a href="#Generator.jsonarray_sql-2228"><span class="linenos">2228</span></a> <span class="k">def</span> <span class="nf">jsonarray_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">JSONArray</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.jsonarray_sql-2229"><a href="#Generator.jsonarray_sql-2229"><span class="linenos">2229</span></a> <span class="n">null_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">"null_handling"</span><span class="p">)</span> -</span><span id="Generator.jsonarray_sql-2230"><a href="#Generator.jsonarray_sql-2230"><span class="linenos">2230</span></a> <span class="n">null_handling</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">null_handling</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">null_handling</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.jsonarray_sql-2231"><a href="#Generator.jsonarray_sql-2231"><span class="linenos">2231</span></a> <span class="n">return_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">"return_type"</span><span class="p">)</span> -</span><span id="Generator.jsonarray_sql-2232"><a href="#Generator.jsonarray_sql-2232"><span class="linenos">2232</span></a> <span class="n">return_type</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" RETURNING </span><span class="si">{</span><span class="n">return_type</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">return_type</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.jsonarray_sql-2233"><a href="#Generator.jsonarray_sql-2233"><span class="linenos">2233</span></a> <span class="n">strict</span> <span class="o">=</span> <span class="s2">" STRICT"</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">"strict"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.jsonarray_sql-2234"><a href="#Generator.jsonarray_sql-2234"><span class="linenos">2234</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.jsonarray_sql-2235"><a href="#Generator.jsonarray_sql-2235"><span class="linenos">2235</span></a> <span class="s2">"JSON_ARRAY"</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 class="n">suffix</span><span class="o">=</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">null_handling</span><span class="si">}{</span><span class="n">return_type</span><span class="si">}{</span><span class="n">strict</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="Generator.jsonarray_sql-2236"><a href="#Generator.jsonarray_sql-2236"><span class="linenos">2236</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.jsonarray_sql-2254"><a href="#Generator.jsonarray_sql-2254"><span class="linenos">2254</span></a> <span class="k">def</span> <span class="nf">jsonarray_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">JSONArray</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.jsonarray_sql-2255"><a href="#Generator.jsonarray_sql-2255"><span class="linenos">2255</span></a> <span class="n">null_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">"null_handling"</span><span class="p">)</span> +</span><span id="Generator.jsonarray_sql-2256"><a href="#Generator.jsonarray_sql-2256"><span class="linenos">2256</span></a> <span class="n">null_handling</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">null_handling</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">null_handling</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.jsonarray_sql-2257"><a href="#Generator.jsonarray_sql-2257"><span class="linenos">2257</span></a> <span class="n">return_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">"return_type"</span><span class="p">)</span> +</span><span id="Generator.jsonarray_sql-2258"><a href="#Generator.jsonarray_sql-2258"><span class="linenos">2258</span></a> <span class="n">return_type</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" RETURNING </span><span class="si">{</span><span class="n">return_type</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">return_type</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.jsonarray_sql-2259"><a href="#Generator.jsonarray_sql-2259"><span class="linenos">2259</span></a> <span class="n">strict</span> <span class="o">=</span> <span class="s2">" STRICT"</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">"strict"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.jsonarray_sql-2260"><a href="#Generator.jsonarray_sql-2260"><span class="linenos">2260</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.jsonarray_sql-2261"><a href="#Generator.jsonarray_sql-2261"><span class="linenos">2261</span></a> <span class="s2">"JSON_ARRAY"</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 class="n">suffix</span><span class="o">=</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">null_handling</span><span class="si">}{</span><span class="n">return_type</span><span class="si">}{</span><span class="n">strict</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Generator.jsonarray_sql-2262"><a href="#Generator.jsonarray_sql-2262"><span class="linenos">2262</span></a> <span class="p">)</span> </span></pre></div> @@ -12527,19 +12688,19 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.jsonarrayagg_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.jsonarrayagg_sql-2238"><a href="#Generator.jsonarrayagg_sql-2238"><span class="linenos">2238</span></a> <span class="k">def</span> <span class="nf">jsonarrayagg_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">JSONArrayAgg</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.jsonarrayagg_sql-2239"><a href="#Generator.jsonarrayagg_sql-2239"><span class="linenos">2239</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.jsonarrayagg_sql-2240"><a href="#Generator.jsonarrayagg_sql-2240"><span class="linenos">2240</span></a> <span class="n">order</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"order"</span><span class="p">)</span> -</span><span id="Generator.jsonarrayagg_sql-2241"><a href="#Generator.jsonarrayagg_sql-2241"><span class="linenos">2241</span></a> <span class="n">null_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">"null_handling"</span><span class="p">)</span> -</span><span id="Generator.jsonarrayagg_sql-2242"><a href="#Generator.jsonarrayagg_sql-2242"><span class="linenos">2242</span></a> <span class="n">null_handling</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">null_handling</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">null_handling</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.jsonarrayagg_sql-2243"><a href="#Generator.jsonarrayagg_sql-2243"><span class="linenos">2243</span></a> <span class="n">return_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">"return_type"</span><span class="p">)</span> -</span><span id="Generator.jsonarrayagg_sql-2244"><a href="#Generator.jsonarrayagg_sql-2244"><span class="linenos">2244</span></a> <span class="n">return_type</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" RETURNING </span><span class="si">{</span><span class="n">return_type</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">return_type</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.jsonarrayagg_sql-2245"><a href="#Generator.jsonarrayagg_sql-2245"><span class="linenos">2245</span></a> <span class="n">strict</span> <span class="o">=</span> <span class="s2">" STRICT"</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">"strict"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.jsonarrayagg_sql-2246"><a href="#Generator.jsonarrayagg_sql-2246"><span class="linenos">2246</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.jsonarrayagg_sql-2247"><a href="#Generator.jsonarrayagg_sql-2247"><span class="linenos">2247</span></a> <span class="s2">"JSON_ARRAYAGG"</span><span class="p">,</span> -</span><span id="Generator.jsonarrayagg_sql-2248"><a href="#Generator.jsonarrayagg_sql-2248"><span class="linenos">2248</span></a> <span class="n">this</span><span class="p">,</span> -</span><span id="Generator.jsonarrayagg_sql-2249"><a href="#Generator.jsonarrayagg_sql-2249"><span class="linenos">2249</span></a> <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">order</span><span class="si">}{</span><span class="n">null_handling</span><span class="si">}{</span><span class="n">return_type</span><span class="si">}{</span><span class="n">strict</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="Generator.jsonarrayagg_sql-2250"><a href="#Generator.jsonarrayagg_sql-2250"><span class="linenos">2250</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.jsonarrayagg_sql-2264"><a href="#Generator.jsonarrayagg_sql-2264"><span class="linenos">2264</span></a> <span class="k">def</span> <span class="nf">jsonarrayagg_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">JSONArrayAgg</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.jsonarrayagg_sql-2265"><a href="#Generator.jsonarrayagg_sql-2265"><span class="linenos">2265</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.jsonarrayagg_sql-2266"><a href="#Generator.jsonarrayagg_sql-2266"><span class="linenos">2266</span></a> <span class="n">order</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"order"</span><span class="p">)</span> +</span><span id="Generator.jsonarrayagg_sql-2267"><a href="#Generator.jsonarrayagg_sql-2267"><span class="linenos">2267</span></a> <span class="n">null_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">"null_handling"</span><span class="p">)</span> +</span><span id="Generator.jsonarrayagg_sql-2268"><a href="#Generator.jsonarrayagg_sql-2268"><span class="linenos">2268</span></a> <span class="n">null_handling</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">null_handling</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">null_handling</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.jsonarrayagg_sql-2269"><a href="#Generator.jsonarrayagg_sql-2269"><span class="linenos">2269</span></a> <span class="n">return_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">"return_type"</span><span class="p">)</span> +</span><span id="Generator.jsonarrayagg_sql-2270"><a href="#Generator.jsonarrayagg_sql-2270"><span class="linenos">2270</span></a> <span class="n">return_type</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" RETURNING </span><span class="si">{</span><span class="n">return_type</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">return_type</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.jsonarrayagg_sql-2271"><a href="#Generator.jsonarrayagg_sql-2271"><span class="linenos">2271</span></a> <span class="n">strict</span> <span class="o">=</span> <span class="s2">" STRICT"</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">"strict"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.jsonarrayagg_sql-2272"><a href="#Generator.jsonarrayagg_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><span id="Generator.jsonarrayagg_sql-2273"><a href="#Generator.jsonarrayagg_sql-2273"><span class="linenos">2273</span></a> <span class="s2">"JSON_ARRAYAGG"</span><span class="p">,</span> +</span><span id="Generator.jsonarrayagg_sql-2274"><a href="#Generator.jsonarrayagg_sql-2274"><span class="linenos">2274</span></a> <span class="n">this</span><span class="p">,</span> +</span><span id="Generator.jsonarrayagg_sql-2275"><a href="#Generator.jsonarrayagg_sql-2275"><span class="linenos">2275</span></a> <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">order</span><span class="si">}{</span><span class="n">null_handling</span><span class="si">}{</span><span class="n">return_type</span><span class="si">}{</span><span class="n">strict</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="Generator.jsonarrayagg_sql-2276"><a href="#Generator.jsonarrayagg_sql-2276"><span class="linenos">2276</span></a> <span class="p">)</span> </span></pre></div> @@ -12557,18 +12718,18 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.jsoncolumndef_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.jsoncolumndef_sql-2252"><a href="#Generator.jsoncolumndef_sql-2252"><span class="linenos">2252</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-2253"><a href="#Generator.jsoncolumndef_sql-2253"><span class="linenos">2253</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-2254"><a href="#Generator.jsoncolumndef_sql-2254"><span class="linenos">2254</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-2255"><a href="#Generator.jsoncolumndef_sql-2255"><span class="linenos">2255</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-2256"><a href="#Generator.jsoncolumndef_sql-2256"><span class="linenos">2256</span></a> -</span><span id="Generator.jsoncolumndef_sql-2257"><a href="#Generator.jsoncolumndef_sql-2257"><span class="linenos">2257</span></a> <span class="k">if</span> <span class="n">nested_schema</span><span class="p">:</span> -</span><span id="Generator.jsoncolumndef_sql-2258"><a href="#Generator.jsoncolumndef_sql-2258"><span class="linenos">2258</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-2259"><a href="#Generator.jsoncolumndef_sql-2259"><span class="linenos">2259</span></a> -</span><span id="Generator.jsoncolumndef_sql-2260"><a href="#Generator.jsoncolumndef_sql-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="Generator.jsoncolumndef_sql-2261"><a href="#Generator.jsoncolumndef_sql-2261"><span class="linenos">2261</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-2262"><a href="#Generator.jsoncolumndef_sql-2262"><span class="linenos">2262</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-2263"><a href="#Generator.jsoncolumndef_sql-2263"><span class="linenos">2263</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> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.jsoncolumndef_sql-2278"><a href="#Generator.jsoncolumndef_sql-2278"><span class="linenos">2278</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-2279"><a href="#Generator.jsoncolumndef_sql-2279"><span class="linenos">2279</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-2280"><a href="#Generator.jsoncolumndef_sql-2280"><span class="linenos">2280</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-2281"><a href="#Generator.jsoncolumndef_sql-2281"><span class="linenos">2281</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-2282"><a href="#Generator.jsoncolumndef_sql-2282"><span class="linenos">2282</span></a> +</span><span id="Generator.jsoncolumndef_sql-2283"><a href="#Generator.jsoncolumndef_sql-2283"><span class="linenos">2283</span></a> <span class="k">if</span> <span class="n">nested_schema</span><span class="p">:</span> +</span><span id="Generator.jsoncolumndef_sql-2284"><a href="#Generator.jsoncolumndef_sql-2284"><span class="linenos">2284</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-2285"><a href="#Generator.jsoncolumndef_sql-2285"><span class="linenos">2285</span></a> +</span><span id="Generator.jsoncolumndef_sql-2286"><a href="#Generator.jsoncolumndef_sql-2286"><span class="linenos">2286</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-2287"><a href="#Generator.jsoncolumndef_sql-2287"><span class="linenos">2287</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-2288"><a href="#Generator.jsoncolumndef_sql-2288"><span class="linenos">2288</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-2289"><a href="#Generator.jsoncolumndef_sql-2289"><span class="linenos">2289</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> @@ -12586,8 +12747,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.jsonschema_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.jsonschema_sql-2265"><a href="#Generator.jsonschema_sql-2265"><span class="linenos">2265</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-2266"><a href="#Generator.jsonschema_sql-2266"><span class="linenos">2266</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> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.jsonschema_sql-2291"><a href="#Generator.jsonschema_sql-2291"><span class="linenos">2291</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-2292"><a href="#Generator.jsonschema_sql-2292"><span class="linenos">2292</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> @@ -12605,18 +12766,18 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.jsontable_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.jsontable_sql-2268"><a href="#Generator.jsontable_sql-2268"><span class="linenos">2268</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-2269"><a href="#Generator.jsontable_sql-2269"><span class="linenos">2269</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-2270"><a href="#Generator.jsontable_sql-2270"><span class="linenos">2270</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-2271"><a href="#Generator.jsontable_sql-2271"><span class="linenos">2271</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-2272"><a href="#Generator.jsontable_sql-2272"><span class="linenos">2272</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-2273"><a href="#Generator.jsontable_sql-2273"><span class="linenos">2273</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-2274"><a href="#Generator.jsontable_sql-2274"><span class="linenos">2274</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-2275"><a href="#Generator.jsontable_sql-2275"><span class="linenos">2275</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-2276"><a href="#Generator.jsontable_sql-2276"><span class="linenos">2276</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-2277"><a href="#Generator.jsontable_sql-2277"><span class="linenos">2277</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-2278"><a href="#Generator.jsontable_sql-2278"><span class="linenos">2278</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-2279"><a href="#Generator.jsontable_sql-2279"><span class="linenos">2279</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.jsontable_sql-2294"><a href="#Generator.jsontable_sql-2294"><span class="linenos">2294</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-2295"><a href="#Generator.jsontable_sql-2295"><span class="linenos">2295</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-2296"><a href="#Generator.jsontable_sql-2296"><span class="linenos">2296</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-2297"><a href="#Generator.jsontable_sql-2297"><span class="linenos">2297</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-2298"><a href="#Generator.jsontable_sql-2298"><span class="linenos">2298</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-2299"><a href="#Generator.jsontable_sql-2299"><span class="linenos">2299</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-2300"><a href="#Generator.jsontable_sql-2300"><span class="linenos">2300</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-2301"><a href="#Generator.jsontable_sql-2301"><span class="linenos">2301</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-2302"><a href="#Generator.jsontable_sql-2302"><span class="linenos">2302</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-2303"><a href="#Generator.jsontable_sql-2303"><span class="linenos">2303</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-2304"><a href="#Generator.jsontable_sql-2304"><span class="linenos">2304</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-2305"><a href="#Generator.jsontable_sql-2305"><span class="linenos">2305</span></a> <span class="p">)</span> </span></pre></div> @@ -12634,13 +12795,13 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.openjsoncolumndef_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.openjsoncolumndef_sql-2281"><a href="#Generator.openjsoncolumndef_sql-2281"><span class="linenos">2281</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-2282"><a href="#Generator.openjsoncolumndef_sql-2282"><span class="linenos">2282</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-2283"><a href="#Generator.openjsoncolumndef_sql-2283"><span class="linenos">2283</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-2284"><a href="#Generator.openjsoncolumndef_sql-2284"><span class="linenos">2284</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-2285"><a href="#Generator.openjsoncolumndef_sql-2285"><span class="linenos">2285</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-2286"><a href="#Generator.openjsoncolumndef_sql-2286"><span class="linenos">2286</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-2287"><a href="#Generator.openjsoncolumndef_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">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-2307"><a href="#Generator.openjsoncolumndef_sql-2307"><span class="linenos">2307</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-2308"><a href="#Generator.openjsoncolumndef_sql-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="Generator.openjsoncolumndef_sql-2309"><a href="#Generator.openjsoncolumndef_sql-2309"><span class="linenos">2309</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-2310"><a href="#Generator.openjsoncolumndef_sql-2310"><span class="linenos">2310</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-2311"><a href="#Generator.openjsoncolumndef_sql-2311"><span class="linenos">2311</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-2312"><a href="#Generator.openjsoncolumndef_sql-2312"><span class="linenos">2312</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-2313"><a href="#Generator.openjsoncolumndef_sql-2313"><span class="linenos">2313</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> @@ -12658,17 +12819,17 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.openjson_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.openjson_sql-2289"><a href="#Generator.openjson_sql-2289"><span class="linenos">2289</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-2290"><a href="#Generator.openjson_sql-2290"><span class="linenos">2290</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-2291"><a href="#Generator.openjson_sql-2291"><span class="linenos">2291</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-2292"><a href="#Generator.openjson_sql-2292"><span class="linenos">2292</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-2293"><a href="#Generator.openjson_sql-2293"><span class="linenos">2293</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-2294"><a href="#Generator.openjson_sql-2294"><span class="linenos">2294</span></a> <span class="n">with_</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Generator.openjson_sql-2295"><a href="#Generator.openjson_sql-2295"><span class="linenos">2295</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-2296"><a href="#Generator.openjson_sql-2296"><span class="linenos">2296</span></a> <span class="k">if</span> <span class="n">expressions</span> -</span><span id="Generator.openjson_sql-2297"><a href="#Generator.openjson_sql-2297"><span class="linenos">2297</span></a> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.openjson_sql-2298"><a href="#Generator.openjson_sql-2298"><span class="linenos">2298</span></a> <span class="p">)</span> -</span><span id="Generator.openjson_sql-2299"><a href="#Generator.openjson_sql-2299"><span class="linenos">2299</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-2315"><a href="#Generator.openjson_sql-2315"><span class="linenos">2315</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-2316"><a href="#Generator.openjson_sql-2316"><span class="linenos">2316</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-2317"><a href="#Generator.openjson_sql-2317"><span class="linenos">2317</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-2318"><a href="#Generator.openjson_sql-2318"><span class="linenos">2318</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-2319"><a href="#Generator.openjson_sql-2319"><span class="linenos">2319</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-2320"><a href="#Generator.openjson_sql-2320"><span class="linenos">2320</span></a> <span class="n">with_</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Generator.openjson_sql-2321"><a href="#Generator.openjson_sql-2321"><span class="linenos">2321</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-2322"><a href="#Generator.openjson_sql-2322"><span class="linenos">2322</span></a> <span class="k">if</span> <span class="n">expressions</span> +</span><span id="Generator.openjson_sql-2323"><a href="#Generator.openjson_sql-2323"><span class="linenos">2323</span></a> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.openjson_sql-2324"><a href="#Generator.openjson_sql-2324"><span class="linenos">2324</span></a> <span class="p">)</span> +</span><span id="Generator.openjson_sql-2325"><a href="#Generator.openjson_sql-2325"><span class="linenos">2325</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> @@ -12686,22 +12847,22 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.in_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.in_sql-2301"><a href="#Generator.in_sql-2301"><span class="linenos">2301</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-2302"><a href="#Generator.in_sql-2302"><span class="linenos">2302</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-2303"><a href="#Generator.in_sql-2303"><span class="linenos">2303</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-2304"><a href="#Generator.in_sql-2304"><span class="linenos">2304</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-2305"><a href="#Generator.in_sql-2305"><span class="linenos">2305</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-2306"><a href="#Generator.in_sql-2306"><span class="linenos">2306</span></a> -</span><span id="Generator.in_sql-2307"><a href="#Generator.in_sql-2307"><span class="linenos">2307</span></a> <span class="k">if</span> <span class="n">query</span><span class="p">:</span> -</span><span id="Generator.in_sql-2308"><a href="#Generator.in_sql-2308"><span class="linenos">2308</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-2309"><a href="#Generator.in_sql-2309"><span class="linenos">2309</span></a> <span class="k">elif</span> <span class="n">unnest</span><span class="p">:</span> -</span><span id="Generator.in_sql-2310"><a href="#Generator.in_sql-2310"><span class="linenos">2310</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-2311"><a href="#Generator.in_sql-2311"><span class="linenos">2311</span></a> <span class="k">elif</span> <span class="n">field</span><span class="p">:</span> -</span><span id="Generator.in_sql-2312"><a href="#Generator.in_sql-2312"><span class="linenos">2312</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-2313"><a href="#Generator.in_sql-2313"><span class="linenos">2313</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator.in_sql-2314"><a href="#Generator.in_sql-2314"><span class="linenos">2314</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-2315"><a href="#Generator.in_sql-2315"><span class="linenos">2315</span></a> -</span><span id="Generator.in_sql-2316"><a href="#Generator.in_sql-2316"><span class="linenos">2316</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-2327"><a href="#Generator.in_sql-2327"><span class="linenos">2327</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-2328"><a href="#Generator.in_sql-2328"><span class="linenos">2328</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-2329"><a href="#Generator.in_sql-2329"><span class="linenos">2329</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-2330"><a href="#Generator.in_sql-2330"><span class="linenos">2330</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-2331"><a href="#Generator.in_sql-2331"><span class="linenos">2331</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-2332"><a href="#Generator.in_sql-2332"><span class="linenos">2332</span></a> +</span><span id="Generator.in_sql-2333"><a href="#Generator.in_sql-2333"><span class="linenos">2333</span></a> <span class="k">if</span> <span class="n">query</span><span class="p">:</span> +</span><span id="Generator.in_sql-2334"><a href="#Generator.in_sql-2334"><span class="linenos">2334</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-2335"><a href="#Generator.in_sql-2335"><span class="linenos">2335</span></a> <span class="k">elif</span> <span class="n">unnest</span><span class="p">:</span> +</span><span id="Generator.in_sql-2336"><a href="#Generator.in_sql-2336"><span class="linenos">2336</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-2337"><a href="#Generator.in_sql-2337"><span class="linenos">2337</span></a> <span class="k">elif</span> <span class="n">field</span><span class="p">:</span> +</span><span id="Generator.in_sql-2338"><a href="#Generator.in_sql-2338"><span class="linenos">2338</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-2339"><a href="#Generator.in_sql-2339"><span class="linenos">2339</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator.in_sql-2340"><a href="#Generator.in_sql-2340"><span class="linenos">2340</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-2341"><a href="#Generator.in_sql-2341"><span class="linenos">2341</span></a> +</span><span id="Generator.in_sql-2342"><a href="#Generator.in_sql-2342"><span class="linenos">2342</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> @@ -12719,8 +12880,8 @@ it is safer to copy.</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-2318"><a href="#Generator.in_unnest_op-2318"><span class="linenos">2318</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-2319"><a href="#Generator.in_unnest_op-2319"><span class="linenos">2319</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-2344"><a href="#Generator.in_unnest_op-2344"><span class="linenos">2344</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-2345"><a href="#Generator.in_unnest_op-2345"><span class="linenos">2345</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> @@ -12738,22 +12899,22 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.interval_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.interval_sql-2321"><a href="#Generator.interval_sql-2321"><span class="linenos">2321</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-2322"><a href="#Generator.interval_sql-2322"><span class="linenos">2322</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-2323"><a href="#Generator.interval_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">INTERVAL_ALLOWS_PLURAL_FORM</span><span class="p">:</span> -</span><span id="Generator.interval_sql-2324"><a href="#Generator.interval_sql-2324"><span class="linenos">2324</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-2325"><a href="#Generator.interval_sql-2325"><span class="linenos">2325</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-2326"><a href="#Generator.interval_sql-2326"><span class="linenos">2326</span></a> -</span><span id="Generator.interval_sql-2327"><a href="#Generator.interval_sql-2327"><span class="linenos">2327</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-2328"><a href="#Generator.interval_sql-2328"><span class="linenos">2328</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-2329"><a href="#Generator.interval_sql-2329"><span class="linenos">2329</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-2330"><a href="#Generator.interval_sql-2330"><span class="linenos">2330</span></a> -</span><span id="Generator.interval_sql-2331"><a href="#Generator.interval_sql-2331"><span class="linenos">2331</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-2332"><a href="#Generator.interval_sql-2332"><span class="linenos">2332</span></a> <span class="k">if</span> <span class="n">this</span><span class="p">:</span> -</span><span id="Generator.interval_sql-2333"><a href="#Generator.interval_sql-2333"><span class="linenos">2333</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-2334"><a href="#Generator.interval_sql-2334"><span class="linenos">2334</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-2335"><a href="#Generator.interval_sql-2335"><span class="linenos">2335</span></a> -</span><span id="Generator.interval_sql-2336"><a href="#Generator.interval_sql-2336"><span class="linenos">2336</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-2347"><a href="#Generator.interval_sql-2347"><span class="linenos">2347</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-2348"><a href="#Generator.interval_sql-2348"><span class="linenos">2348</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-2349"><a href="#Generator.interval_sql-2349"><span class="linenos">2349</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-2350"><a href="#Generator.interval_sql-2350"><span class="linenos">2350</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-2351"><a href="#Generator.interval_sql-2351"><span class="linenos">2351</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-2352"><a href="#Generator.interval_sql-2352"><span class="linenos">2352</span></a> +</span><span id="Generator.interval_sql-2353"><a href="#Generator.interval_sql-2353"><span class="linenos">2353</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-2354"><a href="#Generator.interval_sql-2354"><span class="linenos">2354</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-2355"><a href="#Generator.interval_sql-2355"><span class="linenos">2355</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-2356"><a href="#Generator.interval_sql-2356"><span class="linenos">2356</span></a> +</span><span id="Generator.interval_sql-2357"><a href="#Generator.interval_sql-2357"><span class="linenos">2357</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-2358"><a href="#Generator.interval_sql-2358"><span class="linenos">2358</span></a> <span class="k">if</span> <span class="n">this</span><span class="p">:</span> +</span><span id="Generator.interval_sql-2359"><a href="#Generator.interval_sql-2359"><span class="linenos">2359</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-2360"><a href="#Generator.interval_sql-2360"><span class="linenos">2360</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-2361"><a href="#Generator.interval_sql-2361"><span class="linenos">2361</span></a> +</span><span id="Generator.interval_sql-2362"><a href="#Generator.interval_sql-2362"><span class="linenos">2362</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> @@ -12771,8 +12932,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.return_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.return_sql-2338"><a href="#Generator.return_sql-2338"><span class="linenos">2338</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-2339"><a href="#Generator.return_sql-2339"><span class="linenos">2339</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-2364"><a href="#Generator.return_sql-2364"><span class="linenos">2364</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-2365"><a href="#Generator.return_sql-2365"><span class="linenos">2365</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> @@ -12790,13 +12951,13 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.reference_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.reference_sql-2341"><a href="#Generator.reference_sql-2341"><span class="linenos">2341</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-2342"><a href="#Generator.reference_sql-2342"><span class="linenos">2342</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-2343"><a href="#Generator.reference_sql-2343"><span class="linenos">2343</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-2344"><a href="#Generator.reference_sql-2344"><span class="linenos">2344</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-2345"><a href="#Generator.reference_sql-2345"><span class="linenos">2345</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-2346"><a href="#Generator.reference_sql-2346"><span class="linenos">2346</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-2347"><a href="#Generator.reference_sql-2347"><span class="linenos">2347</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-2367"><a href="#Generator.reference_sql-2367"><span class="linenos">2367</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-2368"><a href="#Generator.reference_sql-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="Generator.reference_sql-2369"><a href="#Generator.reference_sql-2369"><span class="linenos">2369</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-2370"><a href="#Generator.reference_sql-2370"><span class="linenos">2370</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-2371"><a href="#Generator.reference_sql-2371"><span class="linenos">2371</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-2372"><a href="#Generator.reference_sql-2372"><span class="linenos">2372</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-2373"><a href="#Generator.reference_sql-2373"><span class="linenos">2373</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> @@ -12814,8 +12975,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.anonymous_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.anonymous_sql-2349"><a href="#Generator.anonymous_sql-2349"><span class="linenos">2349</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-2350"><a href="#Generator.anonymous_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">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-2375"><a href="#Generator.anonymous_sql-2375"><span class="linenos">2375</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-2376"><a href="#Generator.anonymous_sql-2376"><span class="linenos">2376</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> @@ -12833,14 +12994,14 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.paren_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.paren_sql-2352"><a href="#Generator.paren_sql-2352"><span class="linenos">2352</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-2353"><a href="#Generator.paren_sql-2353"><span class="linenos">2353</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-2354"><a href="#Generator.paren_sql-2354"><span class="linenos">2354</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-2355"><a href="#Generator.paren_sql-2355"><span class="linenos">2355</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator.paren_sql-2356"><a href="#Generator.paren_sql-2356"><span class="linenos">2356</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-2357"><a href="#Generator.paren_sql-2357"><span class="linenos">2357</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-2358"><a href="#Generator.paren_sql-2358"><span class="linenos">2358</span></a> -</span><span id="Generator.paren_sql-2359"><a href="#Generator.paren_sql-2359"><span class="linenos">2359</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-2378"><a href="#Generator.paren_sql-2378"><span class="linenos">2378</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-2379"><a href="#Generator.paren_sql-2379"><span class="linenos">2379</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-2380"><a href="#Generator.paren_sql-2380"><span class="linenos">2380</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-2381"><a href="#Generator.paren_sql-2381"><span class="linenos">2381</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator.paren_sql-2382"><a href="#Generator.paren_sql-2382"><span class="linenos">2382</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-2383"><a href="#Generator.paren_sql-2383"><span class="linenos">2383</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-2384"><a href="#Generator.paren_sql-2384"><span class="linenos">2384</span></a> +</span><span id="Generator.paren_sql-2385"><a href="#Generator.paren_sql-2385"><span class="linenos">2385</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> @@ -12858,11 +13019,11 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.neg_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.neg_sql-2361"><a href="#Generator.neg_sql-2361"><span class="linenos">2361</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-2362"><a href="#Generator.neg_sql-2362"><span class="linenos">2362</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-2363"><a href="#Generator.neg_sql-2363"><span class="linenos">2363</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-2364"><a href="#Generator.neg_sql-2364"><span class="linenos">2364</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-2365"><a href="#Generator.neg_sql-2365"><span class="linenos">2365</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-2387"><a href="#Generator.neg_sql-2387"><span class="linenos">2387</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-2388"><a href="#Generator.neg_sql-2388"><span class="linenos">2388</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-2389"><a href="#Generator.neg_sql-2389"><span class="linenos">2389</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-2390"><a href="#Generator.neg_sql-2390"><span class="linenos">2390</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-2391"><a href="#Generator.neg_sql-2391"><span class="linenos">2391</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> @@ -12880,8 +13041,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.not_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.not_sql-2367"><a href="#Generator.not_sql-2367"><span class="linenos">2367</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-2368"><a href="#Generator.not_sql-2368"><span class="linenos">2368</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-2393"><a href="#Generator.not_sql-2393"><span class="linenos">2393</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-2394"><a href="#Generator.not_sql-2394"><span class="linenos">2394</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> @@ -12899,10 +13060,10 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.alias_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.alias_sql-2370"><a href="#Generator.alias_sql-2370"><span class="linenos">2370</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-2371"><a href="#Generator.alias_sql-2371"><span class="linenos">2371</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-2372"><a href="#Generator.alias_sql-2372"><span class="linenos">2372</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-2373"><a href="#Generator.alias_sql-2373"><span class="linenos">2373</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-2396"><a href="#Generator.alias_sql-2396"><span class="linenos">2396</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-2397"><a href="#Generator.alias_sql-2397"><span class="linenos">2397</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-2398"><a href="#Generator.alias_sql-2398"><span class="linenos">2398</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-2399"><a href="#Generator.alias_sql-2399"><span class="linenos">2399</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> @@ -12920,8 +13081,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.aliases_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.aliases_sql-2375"><a href="#Generator.aliases_sql-2375"><span class="linenos">2375</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-2376"><a href="#Generator.aliases_sql-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="bp">self</span><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-2401"><a href="#Generator.aliases_sql-2401"><span class="linenos">2401</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-2402"><a href="#Generator.aliases_sql-2402"><span class="linenos">2402</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> @@ -12939,10 +13100,10 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.attimezone_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.attimezone_sql-2378"><a href="#Generator.attimezone_sql-2378"><span class="linenos">2378</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-2379"><a href="#Generator.attimezone_sql-2379"><span class="linenos">2379</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-2380"><a href="#Generator.attimezone_sql-2380"><span class="linenos">2380</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-2381"><a href="#Generator.attimezone_sql-2381"><span class="linenos">2381</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-2404"><a href="#Generator.attimezone_sql-2404"><span class="linenos">2404</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-2405"><a href="#Generator.attimezone_sql-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="Generator.attimezone_sql-2406"><a href="#Generator.attimezone_sql-2406"><span class="linenos">2406</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-2407"><a href="#Generator.attimezone_sql-2407"><span class="linenos">2407</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> @@ -12960,8 +13121,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.add_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.add_sql-2383"><a href="#Generator.add_sql-2383"><span class="linenos">2383</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-2384"><a href="#Generator.add_sql-2384"><span class="linenos">2384</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-2409"><a href="#Generator.add_sql-2409"><span class="linenos">2409</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-2410"><a href="#Generator.add_sql-2410"><span class="linenos">2410</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> @@ -12979,8 +13140,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.and_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.and_sql-2386"><a href="#Generator.and_sql-2386"><span class="linenos">2386</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-2387"><a href="#Generator.and_sql-2387"><span class="linenos">2387</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-2412"><a href="#Generator.and_sql-2412"><span class="linenos">2412</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-2413"><a href="#Generator.and_sql-2413"><span class="linenos">2413</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> @@ -12998,8 +13159,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.xor_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.xor_sql-2389"><a href="#Generator.xor_sql-2389"><span class="linenos">2389</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-2390"><a href="#Generator.xor_sql-2390"><span class="linenos">2390</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-2415"><a href="#Generator.xor_sql-2415"><span class="linenos">2415</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-2416"><a href="#Generator.xor_sql-2416"><span class="linenos">2416</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> @@ -13017,17 +13178,17 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.connector_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.connector_sql-2392"><a href="#Generator.connector_sql-2392"><span class="linenos">2392</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-2393"><a href="#Generator.connector_sql-2393"><span class="linenos">2393</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-2394"><a href="#Generator.connector_sql-2394"><span class="linenos">2394</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-2395"><a href="#Generator.connector_sql-2395"><span class="linenos">2395</span></a> -</span><span id="Generator.connector_sql-2396"><a href="#Generator.connector_sql-2396"><span class="linenos">2396</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-2397"><a href="#Generator.connector_sql-2397"><span class="linenos">2397</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-2398"><a href="#Generator.connector_sql-2398"><span class="linenos">2398</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-2399"><a href="#Generator.connector_sql-2399"><span class="linenos">2399</span></a> <span class="p">)</span> -</span><span id="Generator.connector_sql-2400"><a href="#Generator.connector_sql-2400"><span class="linenos">2400</span></a> -</span><span id="Generator.connector_sql-2401"><a href="#Generator.connector_sql-2401"><span class="linenos">2401</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-2402"><a href="#Generator.connector_sql-2402"><span class="linenos">2402</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-2418"><a href="#Generator.connector_sql-2418"><span class="linenos">2418</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-2419"><a href="#Generator.connector_sql-2419"><span class="linenos">2419</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-2420"><a href="#Generator.connector_sql-2420"><span class="linenos">2420</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-2421"><a href="#Generator.connector_sql-2421"><span class="linenos">2421</span></a> +</span><span id="Generator.connector_sql-2422"><a href="#Generator.connector_sql-2422"><span class="linenos">2422</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-2423"><a href="#Generator.connector_sql-2423"><span class="linenos">2423</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-2424"><a href="#Generator.connector_sql-2424"><span class="linenos">2424</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-2425"><a href="#Generator.connector_sql-2425"><span class="linenos">2425</span></a> <span class="p">)</span> +</span><span id="Generator.connector_sql-2426"><a href="#Generator.connector_sql-2426"><span class="linenos">2426</span></a> +</span><span id="Generator.connector_sql-2427"><a href="#Generator.connector_sql-2427"><span class="linenos">2427</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-2428"><a href="#Generator.connector_sql-2428"><span class="linenos">2428</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> @@ -13045,8 +13206,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.bitwiseand_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.bitwiseand_sql-2404"><a href="#Generator.bitwiseand_sql-2404"><span class="linenos">2404</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-2405"><a href="#Generator.bitwiseand_sql-2405"><span class="linenos">2405</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-2430"><a href="#Generator.bitwiseand_sql-2430"><span class="linenos">2430</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-2431"><a href="#Generator.bitwiseand_sql-2431"><span class="linenos">2431</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> @@ -13064,8 +13225,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.bitwiseleftshift_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.bitwiseleftshift_sql-2407"><a href="#Generator.bitwiseleftshift_sql-2407"><span class="linenos">2407</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-2408"><a href="#Generator.bitwiseleftshift_sql-2408"><span class="linenos">2408</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-2433"><a href="#Generator.bitwiseleftshift_sql-2433"><span class="linenos">2433</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-2434"><a href="#Generator.bitwiseleftshift_sql-2434"><span class="linenos">2434</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> @@ -13083,8 +13244,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.bitwisenot_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.bitwisenot_sql-2410"><a href="#Generator.bitwisenot_sql-2410"><span class="linenos">2410</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-2411"><a href="#Generator.bitwisenot_sql-2411"><span class="linenos">2411</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-2436"><a href="#Generator.bitwisenot_sql-2436"><span class="linenos">2436</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-2437"><a href="#Generator.bitwisenot_sql-2437"><span class="linenos">2437</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> @@ -13102,8 +13263,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.bitwiseor_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.bitwiseor_sql-2413"><a href="#Generator.bitwiseor_sql-2413"><span class="linenos">2413</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-2414"><a href="#Generator.bitwiseor_sql-2414"><span class="linenos">2414</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-2439"><a href="#Generator.bitwiseor_sql-2439"><span class="linenos">2439</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-2440"><a href="#Generator.bitwiseor_sql-2440"><span class="linenos">2440</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> @@ -13121,8 +13282,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.bitwiserightshift_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.bitwiserightshift_sql-2416"><a href="#Generator.bitwiserightshift_sql-2416"><span class="linenos">2416</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-2417"><a href="#Generator.bitwiserightshift_sql-2417"><span class="linenos">2417</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-2442"><a href="#Generator.bitwiserightshift_sql-2442"><span class="linenos">2442</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-2443"><a href="#Generator.bitwiserightshift_sql-2443"><span class="linenos">2443</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> @@ -13140,8 +13301,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.bitwisexor_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.bitwisexor_sql-2419"><a href="#Generator.bitwisexor_sql-2419"><span class="linenos">2419</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-2420"><a href="#Generator.bitwisexor_sql-2420"><span class="linenos">2420</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-2445"><a href="#Generator.bitwisexor_sql-2445"><span class="linenos">2445</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-2446"><a href="#Generator.bitwisexor_sql-2446"><span class="linenos">2446</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> @@ -13159,12 +13320,12 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.cast_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.cast_sql-2422"><a href="#Generator.cast_sql-2422"><span class="linenos">2422</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-2423"><a href="#Generator.cast_sql-2423"><span class="linenos">2423</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-2424"><a href="#Generator.cast_sql-2424"><span class="linenos">2424</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-2425"><a href="#Generator.cast_sql-2425"><span class="linenos">2425</span></a> <span class="n">to_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">"to"</span><span class="p">)</span> -</span><span id="Generator.cast_sql-2426"><a href="#Generator.cast_sql-2426"><span class="linenos">2426</span></a> <span class="n">to_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">to_sql</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">to_sql</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.cast_sql-2427"><a href="#Generator.cast_sql-2427"><span class="linenos">2427</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="n">to_sql</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-2448"><a href="#Generator.cast_sql-2448"><span class="linenos">2448</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-2449"><a href="#Generator.cast_sql-2449"><span class="linenos">2449</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-2450"><a href="#Generator.cast_sql-2450"><span class="linenos">2450</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-2451"><a href="#Generator.cast_sql-2451"><span class="linenos">2451</span></a> <span class="n">to_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">"to"</span><span class="p">)</span> +</span><span id="Generator.cast_sql-2452"><a href="#Generator.cast_sql-2452"><span class="linenos">2452</span></a> <span class="n">to_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">to_sql</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">to_sql</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.cast_sql-2453"><a href="#Generator.cast_sql-2453"><span class="linenos">2453</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="n">to_sql</span><span class="si">}{</span><span class="n">format_sql</span><span class="si">}</span><span class="s2">)"</span> </span></pre></div> @@ -13182,9 +13343,9 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.currentdate_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.currentdate_sql-2429"><a href="#Generator.currentdate_sql-2429"><span class="linenos">2429</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-2430"><a href="#Generator.currentdate_sql-2430"><span class="linenos">2430</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-2431"><a href="#Generator.currentdate_sql-2431"><span class="linenos">2431</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-2455"><a href="#Generator.currentdate_sql-2455"><span class="linenos">2455</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-2456"><a href="#Generator.currentdate_sql-2456"><span class="linenos">2456</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-2457"><a href="#Generator.currentdate_sql-2457"><span class="linenos">2457</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> @@ -13202,10 +13363,10 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.collate_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.collate_sql-2433"><a href="#Generator.collate_sql-2433"><span class="linenos">2433</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-2434"><a href="#Generator.collate_sql-2434"><span class="linenos">2434</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-2435"><a href="#Generator.collate_sql-2435"><span class="linenos">2435</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-2436"><a href="#Generator.collate_sql-2436"><span class="linenos">2436</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-2459"><a href="#Generator.collate_sql-2459"><span class="linenos">2459</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-2460"><a href="#Generator.collate_sql-2460"><span class="linenos">2460</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-2461"><a href="#Generator.collate_sql-2461"><span class="linenos">2461</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-2462"><a href="#Generator.collate_sql-2462"><span class="linenos">2462</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> @@ -13223,8 +13384,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.command_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.command_sql-2438"><a href="#Generator.command_sql-2438"><span class="linenos">2438</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-2439"><a href="#Generator.command_sql-2439"><span class="linenos">2439</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-2464"><a href="#Generator.command_sql-2464"><span class="linenos">2464</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-2465"><a href="#Generator.command_sql-2465"><span class="linenos">2465</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> @@ -13242,12 +13403,12 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.comment_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.comment_sql-2441"><a href="#Generator.comment_sql-2441"><span class="linenos">2441</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-2442"><a href="#Generator.comment_sql-2442"><span class="linenos">2442</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-2443"><a href="#Generator.comment_sql-2443"><span class="linenos">2443</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-2444"><a href="#Generator.comment_sql-2444"><span class="linenos">2444</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-2445"><a href="#Generator.comment_sql-2445"><span class="linenos">2445</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-2446"><a href="#Generator.comment_sql-2446"><span class="linenos">2446</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-2467"><a href="#Generator.comment_sql-2467"><span class="linenos">2467</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-2468"><a href="#Generator.comment_sql-2468"><span class="linenos">2468</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-2469"><a href="#Generator.comment_sql-2469"><span class="linenos">2469</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-2470"><a href="#Generator.comment_sql-2470"><span class="linenos">2470</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-2471"><a href="#Generator.comment_sql-2471"><span class="linenos">2471</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-2472"><a href="#Generator.comment_sql-2472"><span class="linenos">2472</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> @@ -13265,16 +13426,16 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.mergetreettlaction_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.mergetreettlaction_sql-2448"><a href="#Generator.mergetreettlaction_sql-2448"><span class="linenos">2448</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-2449"><a href="#Generator.mergetreettlaction_sql-2449"><span class="linenos">2449</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-2450"><a href="#Generator.mergetreettlaction_sql-2450"><span class="linenos">2450</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-2451"><a href="#Generator.mergetreettlaction_sql-2451"><span class="linenos">2451</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-2452"><a href="#Generator.mergetreettlaction_sql-2452"><span class="linenos">2452</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-2453"><a href="#Generator.mergetreettlaction_sql-2453"><span class="linenos">2453</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-2454"><a href="#Generator.mergetreettlaction_sql-2454"><span class="linenos">2454</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-2455"><a href="#Generator.mergetreettlaction_sql-2455"><span class="linenos">2455</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-2456"><a href="#Generator.mergetreettlaction_sql-2456"><span class="linenos">2456</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-2457"><a href="#Generator.mergetreettlaction_sql-2457"><span class="linenos">2457</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-2474"><a href="#Generator.mergetreettlaction_sql-2474"><span class="linenos">2474</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-2475"><a href="#Generator.mergetreettlaction_sql-2475"><span class="linenos">2475</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-2476"><a href="#Generator.mergetreettlaction_sql-2476"><span class="linenos">2476</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-2477"><a href="#Generator.mergetreettlaction_sql-2477"><span class="linenos">2477</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-2478"><a href="#Generator.mergetreettlaction_sql-2478"><span class="linenos">2478</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-2479"><a href="#Generator.mergetreettlaction_sql-2479"><span class="linenos">2479</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-2480"><a href="#Generator.mergetreettlaction_sql-2480"><span class="linenos">2480</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-2481"><a href="#Generator.mergetreettlaction_sql-2481"><span class="linenos">2481</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-2482"><a href="#Generator.mergetreettlaction_sql-2482"><span class="linenos">2482</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-2483"><a href="#Generator.mergetreettlaction_sql-2483"><span class="linenos">2483</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> @@ -13292,16 +13453,16 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.mergetreettl_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.mergetreettl_sql-2459"><a href="#Generator.mergetreettl_sql-2459"><span class="linenos">2459</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-2460"><a href="#Generator.mergetreettl_sql-2460"><span class="linenos">2460</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-2461"><a href="#Generator.mergetreettl_sql-2461"><span class="linenos">2461</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-2462"><a href="#Generator.mergetreettl_sql-2462"><span class="linenos">2462</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-2463"><a href="#Generator.mergetreettl_sql-2463"><span class="linenos">2463</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-2464"><a href="#Generator.mergetreettl_sql-2464"><span class="linenos">2464</span></a> -</span><span id="Generator.mergetreettl_sql-2465"><a href="#Generator.mergetreettl_sql-2465"><span class="linenos">2465</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-2466"><a href="#Generator.mergetreettl_sql-2466"><span class="linenos">2466</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-2467"><a href="#Generator.mergetreettl_sql-2467"><span class="linenos">2467</span></a> -</span><span id="Generator.mergetreettl_sql-2468"><a href="#Generator.mergetreettl_sql-2468"><span class="linenos">2468</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-2485"><a href="#Generator.mergetreettl_sql-2485"><span class="linenos">2485</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-2486"><a href="#Generator.mergetreettl_sql-2486"><span class="linenos">2486</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-2487"><a href="#Generator.mergetreettl_sql-2487"><span class="linenos">2487</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-2488"><a href="#Generator.mergetreettl_sql-2488"><span class="linenos">2488</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-2489"><a href="#Generator.mergetreettl_sql-2489"><span class="linenos">2489</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-2490"><a href="#Generator.mergetreettl_sql-2490"><span class="linenos">2490</span></a> +</span><span id="Generator.mergetreettl_sql-2491"><a href="#Generator.mergetreettl_sql-2491"><span class="linenos">2491</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-2492"><a href="#Generator.mergetreettl_sql-2492"><span class="linenos">2492</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-2493"><a href="#Generator.mergetreettl_sql-2493"><span class="linenos">2493</span></a> +</span><span id="Generator.mergetreettl_sql-2494"><a href="#Generator.mergetreettl_sql-2494"><span class="linenos">2494</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> @@ -13319,8 +13480,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.transaction_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.transaction_sql-2470"><a href="#Generator.transaction_sql-2470"><span class="linenos">2470</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-2471"><a href="#Generator.transaction_sql-2471"><span class="linenos">2471</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-2496"><a href="#Generator.transaction_sql-2496"><span class="linenos">2496</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-2497"><a href="#Generator.transaction_sql-2497"><span class="linenos">2497</span></a> <span class="k">return</span> <span class="s2">"BEGIN"</span> </span></pre></div> @@ -13338,12 +13499,12 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.commit_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.commit_sql-2473"><a href="#Generator.commit_sql-2473"><span class="linenos">2473</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-2474"><a href="#Generator.commit_sql-2474"><span class="linenos">2474</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-2475"><a href="#Generator.commit_sql-2475"><span class="linenos">2475</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-2476"><a href="#Generator.commit_sql-2476"><span class="linenos">2476</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-2477"><a href="#Generator.commit_sql-2477"><span class="linenos">2477</span></a> -</span><span id="Generator.commit_sql-2478"><a href="#Generator.commit_sql-2478"><span class="linenos">2478</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-2499"><a href="#Generator.commit_sql-2499"><span class="linenos">2499</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-2500"><a href="#Generator.commit_sql-2500"><span class="linenos">2500</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-2501"><a href="#Generator.commit_sql-2501"><span class="linenos">2501</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-2502"><a href="#Generator.commit_sql-2502"><span class="linenos">2502</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-2503"><a href="#Generator.commit_sql-2503"><span class="linenos">2503</span></a> +</span><span id="Generator.commit_sql-2504"><a href="#Generator.commit_sql-2504"><span class="linenos">2504</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> @@ -13361,10 +13522,10 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.rollback_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.rollback_sql-2480"><a href="#Generator.rollback_sql-2480"><span class="linenos">2480</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-2481"><a href="#Generator.rollback_sql-2481"><span class="linenos">2481</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-2482"><a href="#Generator.rollback_sql-2482"><span class="linenos">2482</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-2483"><a href="#Generator.rollback_sql-2483"><span class="linenos">2483</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-2506"><a href="#Generator.rollback_sql-2506"><span class="linenos">2506</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-2507"><a href="#Generator.rollback_sql-2507"><span class="linenos">2507</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-2508"><a href="#Generator.rollback_sql-2508"><span class="linenos">2508</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-2509"><a href="#Generator.rollback_sql-2509"><span class="linenos">2509</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> @@ -13382,25 +13543,25 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.altercolumn_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.altercolumn_sql-2485"><a href="#Generator.altercolumn_sql-2485"><span class="linenos">2485</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-2486"><a href="#Generator.altercolumn_sql-2486"><span class="linenos">2486</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-2487"><a href="#Generator.altercolumn_sql-2487"><span class="linenos">2487</span></a> -</span><span id="Generator.altercolumn_sql-2488"><a href="#Generator.altercolumn_sql-2488"><span class="linenos">2488</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-2489"><a href="#Generator.altercolumn_sql-2489"><span class="linenos">2489</span></a> <span class="k">if</span> <span class="n">dtype</span><span class="p">:</span> -</span><span id="Generator.altercolumn_sql-2490"><a href="#Generator.altercolumn_sql-2490"><span class="linenos">2490</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-2491"><a href="#Generator.altercolumn_sql-2491"><span class="linenos">2491</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-2492"><a href="#Generator.altercolumn_sql-2492"><span class="linenos">2492</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-2493"><a href="#Generator.altercolumn_sql-2493"><span class="linenos">2493</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-2494"><a href="#Generator.altercolumn_sql-2494"><span class="linenos">2494</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-2495"><a href="#Generator.altercolumn_sql-2495"><span class="linenos">2495</span></a> -</span><span id="Generator.altercolumn_sql-2496"><a href="#Generator.altercolumn_sql-2496"><span class="linenos">2496</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-2497"><a href="#Generator.altercolumn_sql-2497"><span class="linenos">2497</span></a> <span class="k">if</span> <span class="n">default</span><span class="p">:</span> -</span><span id="Generator.altercolumn_sql-2498"><a href="#Generator.altercolumn_sql-2498"><span class="linenos">2498</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-2499"><a href="#Generator.altercolumn_sql-2499"><span class="linenos">2499</span></a> -</span><span id="Generator.altercolumn_sql-2500"><a href="#Generator.altercolumn_sql-2500"><span class="linenos">2500</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-2501"><a href="#Generator.altercolumn_sql-2501"><span class="linenos">2501</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-2502"><a href="#Generator.altercolumn_sql-2502"><span class="linenos">2502</span></a> -</span><span id="Generator.altercolumn_sql-2503"><a href="#Generator.altercolumn_sql-2503"><span class="linenos">2503</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> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.altercolumn_sql-2511"><a href="#Generator.altercolumn_sql-2511"><span class="linenos">2511</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-2512"><a href="#Generator.altercolumn_sql-2512"><span class="linenos">2512</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-2513"><a href="#Generator.altercolumn_sql-2513"><span class="linenos">2513</span></a> +</span><span id="Generator.altercolumn_sql-2514"><a href="#Generator.altercolumn_sql-2514"><span class="linenos">2514</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-2515"><a href="#Generator.altercolumn_sql-2515"><span class="linenos">2515</span></a> <span class="k">if</span> <span class="n">dtype</span><span class="p">:</span> +</span><span id="Generator.altercolumn_sql-2516"><a href="#Generator.altercolumn_sql-2516"><span class="linenos">2516</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-2517"><a href="#Generator.altercolumn_sql-2517"><span class="linenos">2517</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-2518"><a href="#Generator.altercolumn_sql-2518"><span class="linenos">2518</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-2519"><a href="#Generator.altercolumn_sql-2519"><span class="linenos">2519</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-2520"><a href="#Generator.altercolumn_sql-2520"><span class="linenos">2520</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-2521"><a href="#Generator.altercolumn_sql-2521"><span class="linenos">2521</span></a> +</span><span id="Generator.altercolumn_sql-2522"><a href="#Generator.altercolumn_sql-2522"><span class="linenos">2522</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-2523"><a href="#Generator.altercolumn_sql-2523"><span class="linenos">2523</span></a> <span class="k">if</span> <span class="n">default</span><span class="p">:</span> +</span><span id="Generator.altercolumn_sql-2524"><a href="#Generator.altercolumn_sql-2524"><span class="linenos">2524</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-2525"><a href="#Generator.altercolumn_sql-2525"><span class="linenos">2525</span></a> +</span><span id="Generator.altercolumn_sql-2526"><a href="#Generator.altercolumn_sql-2526"><span class="linenos">2526</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-2527"><a href="#Generator.altercolumn_sql-2527"><span class="linenos">2527</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-2528"><a href="#Generator.altercolumn_sql-2528"><span class="linenos">2528</span></a> +</span><span id="Generator.altercolumn_sql-2529"><a href="#Generator.altercolumn_sql-2529"><span class="linenos">2529</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> @@ -13418,14 +13579,14 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.renametable_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.renametable_sql-2505"><a href="#Generator.renametable_sql-2505"><span class="linenos">2505</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-2506"><a href="#Generator.renametable_sql-2506"><span class="linenos">2506</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-2507"><a href="#Generator.renametable_sql-2507"><span class="linenos">2507</span></a> <span class="c1"># Remove db from tables</span> -</span><span id="Generator.renametable_sql-2508"><a href="#Generator.renametable_sql-2508"><span class="linenos">2508</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-2509"><a href="#Generator.renametable_sql-2509"><span class="linenos">2509</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-2510"><a href="#Generator.renametable_sql-2510"><span class="linenos">2510</span></a> <span class="p">)</span> -</span><span id="Generator.renametable_sql-2511"><a href="#Generator.renametable_sql-2511"><span class="linenos">2511</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-2512"><a href="#Generator.renametable_sql-2512"><span class="linenos">2512</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-2531"><a href="#Generator.renametable_sql-2531"><span class="linenos">2531</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-2532"><a href="#Generator.renametable_sql-2532"><span class="linenos">2532</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-2533"><a href="#Generator.renametable_sql-2533"><span class="linenos">2533</span></a> <span class="c1"># Remove db from tables</span> +</span><span id="Generator.renametable_sql-2534"><a href="#Generator.renametable_sql-2534"><span class="linenos">2534</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-2535"><a href="#Generator.renametable_sql-2535"><span class="linenos">2535</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-2536"><a href="#Generator.renametable_sql-2536"><span class="linenos">2536</span></a> <span class="p">)</span> +</span><span id="Generator.renametable_sql-2537"><a href="#Generator.renametable_sql-2537"><span class="linenos">2537</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-2538"><a href="#Generator.renametable_sql-2538"><span class="linenos">2538</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> @@ -13443,21 +13604,21 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.altertable_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.altertable_sql-2514"><a href="#Generator.altertable_sql-2514"><span class="linenos">2514</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-2515"><a href="#Generator.altertable_sql-2515"><span class="linenos">2515</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-2516"><a href="#Generator.altertable_sql-2516"><span class="linenos">2516</span></a> -</span><span id="Generator.altertable_sql-2517"><a href="#Generator.altertable_sql-2517"><span class="linenos">2517</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-2518"><a href="#Generator.altertable_sql-2518"><span class="linenos">2518</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">add_column_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Generator.altertable_sql-2519"><a href="#Generator.altertable_sql-2519"><span class="linenos">2519</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-2520"><a href="#Generator.altertable_sql-2520"><span class="linenos">2520</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-2521"><a href="#Generator.altertable_sql-2521"><span class="linenos">2521</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-2522"><a href="#Generator.altertable_sql-2522"><span class="linenos">2522</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-2523"><a href="#Generator.altertable_sql-2523"><span class="linenos">2523</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator.altertable_sql-2524"><a href="#Generator.altertable_sql-2524"><span class="linenos">2524</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-2525"><a href="#Generator.altertable_sql-2525"><span class="linenos">2525</span></a> -</span><span id="Generator.altertable_sql-2526"><a href="#Generator.altertable_sql-2526"><span class="linenos">2526</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-2527"><a href="#Generator.altertable_sql-2527"><span class="linenos">2527</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-2528"><a href="#Generator.altertable_sql-2528"><span class="linenos">2528</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-2540"><a href="#Generator.altertable_sql-2540"><span class="linenos">2540</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-2541"><a href="#Generator.altertable_sql-2541"><span class="linenos">2541</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-2542"><a href="#Generator.altertable_sql-2542"><span class="linenos">2542</span></a> +</span><span id="Generator.altertable_sql-2543"><a href="#Generator.altertable_sql-2543"><span class="linenos">2543</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-2544"><a href="#Generator.altertable_sql-2544"><span class="linenos">2544</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">add_column_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Generator.altertable_sql-2545"><a href="#Generator.altertable_sql-2545"><span class="linenos">2545</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-2546"><a href="#Generator.altertable_sql-2546"><span class="linenos">2546</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-2547"><a href="#Generator.altertable_sql-2547"><span class="linenos">2547</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-2548"><a href="#Generator.altertable_sql-2548"><span class="linenos">2548</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-2549"><a href="#Generator.altertable_sql-2549"><span class="linenos">2549</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator.altertable_sql-2550"><a href="#Generator.altertable_sql-2550"><span class="linenos">2550</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-2551"><a href="#Generator.altertable_sql-2551"><span class="linenos">2551</span></a> +</span><span id="Generator.altertable_sql-2552"><a href="#Generator.altertable_sql-2552"><span class="linenos">2552</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-2553"><a href="#Generator.altertable_sql-2553"><span class="linenos">2553</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-2554"><a href="#Generator.altertable_sql-2554"><span class="linenos">2554</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> @@ -13475,14 +13636,14 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.add_column_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.add_column_sql-2530"><a href="#Generator.add_column_sql-2530"><span class="linenos">2530</span></a> <span class="k">def</span> <span class="nf">add_column_sql</span><span class="p">(</span><span class="bp">self</span><span 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.add_column_sql-2531"><a href="#Generator.add_column_sql-2531"><span class="linenos">2531</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">ALTER_TABLE_INCLUDE_COLUMN_KEYWORD</span><span class="p">:</span> -</span><span id="Generator.add_column_sql-2532"><a href="#Generator.add_column_sql-2532"><span class="linenos">2532</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span> -</span><span id="Generator.add_column_sql-2533"><a href="#Generator.add_column_sql-2533"><span class="linenos">2533</span></a> <span class="n">expression</span><span class="p">,</span> -</span><span id="Generator.add_column_sql-2534"><a href="#Generator.add_column_sql-2534"><span class="linenos">2534</span></a> <span class="n">key</span><span class="o">=</span><span class="s2">"actions"</span><span class="p">,</span> -</span><span id="Generator.add_column_sql-2535"><a href="#Generator.add_column_sql-2535"><span class="linenos">2535</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.add_column_sql-2536"><a href="#Generator.add_column_sql-2536"><span class="linenos">2536</span></a> <span class="p">)</span> -</span><span id="Generator.add_column_sql-2537"><a href="#Generator.add_column_sql-2537"><span class="linenos">2537</span></a> <span class="k">return</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="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.add_column_sql-2556"><a href="#Generator.add_column_sql-2556"><span class="linenos">2556</span></a> <span class="k">def</span> <span class="nf">add_column_sql</span><span class="p">(</span><span class="bp">self</span><span 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.add_column_sql-2557"><a href="#Generator.add_column_sql-2557"><span class="linenos">2557</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">ALTER_TABLE_INCLUDE_COLUMN_KEYWORD</span><span class="p">:</span> +</span><span id="Generator.add_column_sql-2558"><a href="#Generator.add_column_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">expressions</span><span class="p">(</span> +</span><span id="Generator.add_column_sql-2559"><a href="#Generator.add_column_sql-2559"><span class="linenos">2559</span></a> <span class="n">expression</span><span class="p">,</span> +</span><span id="Generator.add_column_sql-2560"><a href="#Generator.add_column_sql-2560"><span class="linenos">2560</span></a> <span class="n">key</span><span class="o">=</span><span class="s2">"actions"</span><span class="p">,</span> +</span><span id="Generator.add_column_sql-2561"><a href="#Generator.add_column_sql-2561"><span class="linenos">2561</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.add_column_sql-2562"><a href="#Generator.add_column_sql-2562"><span class="linenos">2562</span></a> <span class="p">)</span> +</span><span id="Generator.add_column_sql-2563"><a href="#Generator.add_column_sql-2563"><span class="linenos">2563</span></a> <span class="k">return</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="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> @@ -13500,10 +13661,10 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.droppartition_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.droppartition_sql-2539"><a href="#Generator.droppartition_sql-2539"><span class="linenos">2539</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-2540"><a href="#Generator.droppartition_sql-2540"><span class="linenos">2540</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-2541"><a href="#Generator.droppartition_sql-2541"><span class="linenos">2541</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-2542"><a href="#Generator.droppartition_sql-2542"><span class="linenos">2542</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-2565"><a href="#Generator.droppartition_sql-2565"><span class="linenos">2565</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-2566"><a href="#Generator.droppartition_sql-2566"><span class="linenos">2566</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-2567"><a href="#Generator.droppartition_sql-2567"><span class="linenos">2567</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-2568"><a href="#Generator.droppartition_sql-2568"><span class="linenos">2568</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> @@ -13521,16 +13682,16 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.addconstraint_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.addconstraint_sql-2544"><a href="#Generator.addconstraint_sql-2544"><span class="linenos">2544</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-2545"><a href="#Generator.addconstraint_sql-2545"><span class="linenos">2545</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-2546"><a href="#Generator.addconstraint_sql-2546"><span class="linenos">2546</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-2547"><a href="#Generator.addconstraint_sql-2547"><span class="linenos">2547</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-2548"><a href="#Generator.addconstraint_sql-2548"><span class="linenos">2548</span></a> -</span><span id="Generator.addconstraint_sql-2549"><a href="#Generator.addconstraint_sql-2549"><span class="linenos">2549</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-2550"><a href="#Generator.addconstraint_sql-2550"><span class="linenos">2550</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-2551"><a href="#Generator.addconstraint_sql-2551"><span class="linenos">2551</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-2552"><a href="#Generator.addconstraint_sql-2552"><span class="linenos">2552</span></a> -</span><span id="Generator.addconstraint_sql-2553"><a href="#Generator.addconstraint_sql-2553"><span class="linenos">2553</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-2570"><a href="#Generator.addconstraint_sql-2570"><span class="linenos">2570</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-2571"><a href="#Generator.addconstraint_sql-2571"><span class="linenos">2571</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-2572"><a href="#Generator.addconstraint_sql-2572"><span class="linenos">2572</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-2573"><a href="#Generator.addconstraint_sql-2573"><span class="linenos">2573</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-2574"><a href="#Generator.addconstraint_sql-2574"><span class="linenos">2574</span></a> +</span><span id="Generator.addconstraint_sql-2575"><a href="#Generator.addconstraint_sql-2575"><span class="linenos">2575</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-2576"><a href="#Generator.addconstraint_sql-2576"><span class="linenos">2576</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-2577"><a href="#Generator.addconstraint_sql-2577"><span class="linenos">2577</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-2578"><a href="#Generator.addconstraint_sql-2578"><span class="linenos">2578</span></a> +</span><span id="Generator.addconstraint_sql-2579"><a href="#Generator.addconstraint_sql-2579"><span class="linenos">2579</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> @@ -13548,13 +13709,13 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.distinct_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.distinct_sql-2555"><a href="#Generator.distinct_sql-2555"><span class="linenos">2555</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-2556"><a href="#Generator.distinct_sql-2556"><span class="linenos">2556</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-2557"><a href="#Generator.distinct_sql-2557"><span class="linenos">2557</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-2558"><a href="#Generator.distinct_sql-2558"><span class="linenos">2558</span></a> -</span><span id="Generator.distinct_sql-2559"><a href="#Generator.distinct_sql-2559"><span class="linenos">2559</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-2560"><a href="#Generator.distinct_sql-2560"><span class="linenos">2560</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-2561"><a href="#Generator.distinct_sql-2561"><span class="linenos">2561</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-2581"><a href="#Generator.distinct_sql-2581"><span class="linenos">2581</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-2582"><a href="#Generator.distinct_sql-2582"><span class="linenos">2582</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-2583"><a href="#Generator.distinct_sql-2583"><span class="linenos">2583</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-2584"><a href="#Generator.distinct_sql-2584"><span class="linenos">2584</span></a> +</span><span id="Generator.distinct_sql-2585"><a href="#Generator.distinct_sql-2585"><span class="linenos">2585</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-2586"><a href="#Generator.distinct_sql-2586"><span class="linenos">2586</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-2587"><a href="#Generator.distinct_sql-2587"><span class="linenos">2587</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> @@ -13572,8 +13733,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.ignorenulls_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.ignorenulls_sql-2563"><a href="#Generator.ignorenulls_sql-2563"><span class="linenos">2563</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-2564"><a href="#Generator.ignorenulls_sql-2564"><span class="linenos">2564</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-2589"><a href="#Generator.ignorenulls_sql-2589"><span class="linenos">2589</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-2590"><a href="#Generator.ignorenulls_sql-2590"><span class="linenos">2590</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> @@ -13591,8 +13752,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.respectnulls_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.respectnulls_sql-2566"><a href="#Generator.respectnulls_sql-2566"><span class="linenos">2566</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-2567"><a href="#Generator.respectnulls_sql-2567"><span class="linenos">2567</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-2592"><a href="#Generator.respectnulls_sql-2592"><span class="linenos">2592</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-2593"><a href="#Generator.respectnulls_sql-2593"><span class="linenos">2593</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> @@ -13610,13 +13771,13 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.intdiv_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.intdiv_sql-2569"><a href="#Generator.intdiv_sql-2569"><span class="linenos">2569</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-2570"><a href="#Generator.intdiv_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">sql</span><span class="p">(</span> -</span><span id="Generator.intdiv_sql-2571"><a href="#Generator.intdiv_sql-2571"><span class="linenos">2571</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-2572"><a href="#Generator.intdiv_sql-2572"><span class="linenos">2572</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="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="p">),</span> -</span><span id="Generator.intdiv_sql-2573"><a href="#Generator.intdiv_sql-2573"><span class="linenos">2573</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-2574"><a href="#Generator.intdiv_sql-2574"><span class="linenos">2574</span></a> <span class="p">)</span> -</span><span id="Generator.intdiv_sql-2575"><a href="#Generator.intdiv_sql-2575"><span class="linenos">2575</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.intdiv_sql-2595"><a href="#Generator.intdiv_sql-2595"><span class="linenos">2595</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-2596"><a href="#Generator.intdiv_sql-2596"><span class="linenos">2596</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-2597"><a href="#Generator.intdiv_sql-2597"><span class="linenos">2597</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-2598"><a href="#Generator.intdiv_sql-2598"><span class="linenos">2598</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="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="p">),</span> +</span><span id="Generator.intdiv_sql-2599"><a href="#Generator.intdiv_sql-2599"><span class="linenos">2599</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-2600"><a href="#Generator.intdiv_sql-2600"><span class="linenos">2600</span></a> <span class="p">)</span> +</span><span id="Generator.intdiv_sql-2601"><a href="#Generator.intdiv_sql-2601"><span class="linenos">2601</span></a> <span class="p">)</span> </span></pre></div> @@ -13634,10 +13795,10 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.dpipe_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.dpipe_sql-2577"><a href="#Generator.dpipe_sql-2577"><span class="linenos">2577</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-2578"><a href="#Generator.dpipe_sql-2578"><span class="linenos">2578</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">STRICT_STRING_CONCAT</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">"safe"</span><span class="p">):</span> -</span><span id="Generator.dpipe_sql-2579"><a href="#Generator.dpipe_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">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.dpipe_sql-2580"><a href="#Generator.dpipe_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.dpipe_sql-2603"><a href="#Generator.dpipe_sql-2603"><span class="linenos">2603</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-2604"><a href="#Generator.dpipe_sql-2604"><span class="linenos">2604</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">STRICT_STRING_CONCAT</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">"safe"</span><span class="p">):</span> +</span><span id="Generator.dpipe_sql-2605"><a href="#Generator.dpipe_sql-2605"><span class="linenos">2605</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.dpipe_sql-2606"><a href="#Generator.dpipe_sql-2606"><span class="linenos">2606</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> @@ -13655,28 +13816,28 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.div_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.div_sql-2582"><a href="#Generator.div_sql-2582"><span class="linenos">2582</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-2583"><a href="#Generator.div_sql-2583"><span class="linenos">2583</span></a> <span class="n">l</span><span class="p">,</span> <span class="n">r</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">left</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">right</span> -</span><span id="Generator.div_sql-2584"><a href="#Generator.div_sql-2584"><span class="linenos">2584</span></a> -</span><span id="Generator.div_sql-2585"><a href="#Generator.div_sql-2585"><span class="linenos">2585</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">SAFE_DIVISION</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">"safe"</span><span class="p">):</span> -</span><span id="Generator.div_sql-2586"><a href="#Generator.div_sql-2586"><span class="linenos">2586</span></a> <span class="n">r</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Nullif</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">r</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">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">number</span><span class="p">(</span><span class="mi">0</span><span class="p">)))</span> -</span><span id="Generator.div_sql-2587"><a href="#Generator.div_sql-2587"><span class="linenos">2587</span></a> -</span><span id="Generator.div_sql-2588"><a href="#Generator.div_sql-2588"><span class="linenos">2588</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">TYPED_DIVISION</span> <span class="ow">and</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">"typed"</span><span class="p">):</span> -</span><span id="Generator.div_sql-2589"><a href="#Generator.div_sql-2589"><span class="linenos">2589</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">l</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</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">FLOAT_TYPES</span><span class="p">)</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">r</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span> -</span><span id="Generator.div_sql-2590"><a href="#Generator.div_sql-2590"><span class="linenos">2590</span></a> <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">FLOAT_TYPES</span> -</span><span id="Generator.div_sql-2591"><a href="#Generator.div_sql-2591"><span class="linenos">2591</span></a> <span class="p">):</span> -</span><span id="Generator.div_sql-2592"><a href="#Generator.div_sql-2592"><span class="linenos">2592</span></a> <span class="n">l</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">l</span><span class="o">.</span><span class="n">copy</span><span class="p">(),</span> <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="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">DOUBLE</span><span class="p">))</span> -</span><span id="Generator.div_sql-2593"><a href="#Generator.div_sql-2593"><span class="linenos">2593</span></a> -</span><span id="Generator.div_sql-2594"><a href="#Generator.div_sql-2594"><span class="linenos">2594</span></a> <span class="k">elif</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">TYPED_DIVISION</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">"typed"</span><span class="p">):</span> -</span><span id="Generator.div_sql-2595"><a href="#Generator.div_sql-2595"><span class="linenos">2595</span></a> <span class="k">if</span> <span class="n">l</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</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">INTEGER_TYPES</span><span class="p">)</span> <span class="ow">and</span> <span class="n">r</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</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">INTEGER_TYPES</span><span class="p">):</span> -</span><span id="Generator.div_sql-2596"><a href="#Generator.div_sql-2596"><span class="linenos">2596</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.div_sql-2597"><a href="#Generator.div_sql-2597"><span class="linenos">2597</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span> -</span><span id="Generator.div_sql-2598"><a href="#Generator.div_sql-2598"><span class="linenos">2598</span></a> <span class="n">l</span> <span class="o">/</span> <span class="n">r</span><span class="p">,</span> -</span><span id="Generator.div_sql-2599"><a href="#Generator.div_sql-2599"><span class="linenos">2599</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="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">BIGINT</span><span class="p">,</span> -</span><span id="Generator.div_sql-2600"><a href="#Generator.div_sql-2600"><span class="linenos">2600</span></a> <span class="p">)</span> -</span><span id="Generator.div_sql-2601"><a href="#Generator.div_sql-2601"><span class="linenos">2601</span></a> <span class="p">)</span> -</span><span id="Generator.div_sql-2602"><a href="#Generator.div_sql-2602"><span class="linenos">2602</span></a> -</span><span id="Generator.div_sql-2603"><a href="#Generator.div_sql-2603"><span class="linenos">2603</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-2608"><a href="#Generator.div_sql-2608"><span class="linenos">2608</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-2609"><a href="#Generator.div_sql-2609"><span class="linenos">2609</span></a> <span class="n">l</span><span class="p">,</span> <span class="n">r</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">left</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">right</span> +</span><span id="Generator.div_sql-2610"><a href="#Generator.div_sql-2610"><span class="linenos">2610</span></a> +</span><span id="Generator.div_sql-2611"><a href="#Generator.div_sql-2611"><span class="linenos">2611</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">SAFE_DIVISION</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">"safe"</span><span class="p">):</span> +</span><span id="Generator.div_sql-2612"><a href="#Generator.div_sql-2612"><span class="linenos">2612</span></a> <span class="n">r</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Nullif</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">r</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">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">number</span><span class="p">(</span><span class="mi">0</span><span class="p">)))</span> +</span><span id="Generator.div_sql-2613"><a href="#Generator.div_sql-2613"><span class="linenos">2613</span></a> +</span><span id="Generator.div_sql-2614"><a href="#Generator.div_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">dialect</span><span class="o">.</span><span class="n">TYPED_DIVISION</span> <span class="ow">and</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">"typed"</span><span class="p">):</span> +</span><span id="Generator.div_sql-2615"><a href="#Generator.div_sql-2615"><span class="linenos">2615</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">l</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</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">FLOAT_TYPES</span><span class="p">)</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">r</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span> +</span><span id="Generator.div_sql-2616"><a href="#Generator.div_sql-2616"><span class="linenos">2616</span></a> <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">FLOAT_TYPES</span> +</span><span id="Generator.div_sql-2617"><a href="#Generator.div_sql-2617"><span class="linenos">2617</span></a> <span class="p">):</span> +</span><span id="Generator.div_sql-2618"><a href="#Generator.div_sql-2618"><span class="linenos">2618</span></a> <span class="n">l</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">l</span><span class="o">.</span><span class="n">copy</span><span class="p">(),</span> <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="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">DOUBLE</span><span class="p">))</span> +</span><span id="Generator.div_sql-2619"><a href="#Generator.div_sql-2619"><span class="linenos">2619</span></a> +</span><span id="Generator.div_sql-2620"><a href="#Generator.div_sql-2620"><span class="linenos">2620</span></a> <span class="k">elif</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">TYPED_DIVISION</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">"typed"</span><span class="p">):</span> +</span><span id="Generator.div_sql-2621"><a href="#Generator.div_sql-2621"><span class="linenos">2621</span></a> <span class="k">if</span> <span class="n">l</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</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">INTEGER_TYPES</span><span class="p">)</span> <span class="ow">and</span> <span class="n">r</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</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">INTEGER_TYPES</span><span class="p">):</span> +</span><span id="Generator.div_sql-2622"><a href="#Generator.div_sql-2622"><span class="linenos">2622</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.div_sql-2623"><a href="#Generator.div_sql-2623"><span class="linenos">2623</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span> +</span><span id="Generator.div_sql-2624"><a href="#Generator.div_sql-2624"><span class="linenos">2624</span></a> <span class="n">l</span> <span class="o">/</span> <span class="n">r</span><span class="p">,</span> +</span><span id="Generator.div_sql-2625"><a href="#Generator.div_sql-2625"><span class="linenos">2625</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="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">BIGINT</span><span class="p">,</span> +</span><span id="Generator.div_sql-2626"><a href="#Generator.div_sql-2626"><span class="linenos">2626</span></a> <span class="p">)</span> +</span><span id="Generator.div_sql-2627"><a href="#Generator.div_sql-2627"><span class="linenos">2627</span></a> <span class="p">)</span> +</span><span id="Generator.div_sql-2628"><a href="#Generator.div_sql-2628"><span class="linenos">2628</span></a> +</span><span id="Generator.div_sql-2629"><a href="#Generator.div_sql-2629"><span class="linenos">2629</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> @@ -13694,8 +13855,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.overlaps_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.overlaps_sql-2605"><a href="#Generator.overlaps_sql-2605"><span class="linenos">2605</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-2606"><a href="#Generator.overlaps_sql-2606"><span class="linenos">2606</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-2631"><a href="#Generator.overlaps_sql-2631"><span class="linenos">2631</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-2632"><a href="#Generator.overlaps_sql-2632"><span class="linenos">2632</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> @@ -13713,8 +13874,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.distance_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.distance_sql-2608"><a href="#Generator.distance_sql-2608"><span class="linenos">2608</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-2609"><a href="#Generator.distance_sql-2609"><span class="linenos">2609</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-2634"><a href="#Generator.distance_sql-2634"><span class="linenos">2634</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-2635"><a href="#Generator.distance_sql-2635"><span class="linenos">2635</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> @@ -13732,8 +13893,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.dot_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.dot_sql-2611"><a href="#Generator.dot_sql-2611"><span class="linenos">2611</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-2612"><a href="#Generator.dot_sql-2612"><span class="linenos">2612</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-2637"><a href="#Generator.dot_sql-2637"><span class="linenos">2637</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-2638"><a href="#Generator.dot_sql-2638"><span class="linenos">2638</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> @@ -13751,8 +13912,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.eq_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.eq_sql-2614"><a href="#Generator.eq_sql-2614"><span class="linenos">2614</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-2615"><a href="#Generator.eq_sql-2615"><span class="linenos">2615</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-2640"><a href="#Generator.eq_sql-2640"><span class="linenos">2640</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-2641"><a href="#Generator.eq_sql-2641"><span class="linenos">2641</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> @@ -13770,8 +13931,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.propertyeq_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.propertyeq_sql-2617"><a href="#Generator.propertyeq_sql-2617"><span class="linenos">2617</span></a> <span class="k">def</span> <span class="nf">propertyeq_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">PropertyEQ</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.propertyeq_sql-2618"><a href="#Generator.propertyeq_sql-2618"><span class="linenos">2618</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.propertyeq_sql-2643"><a href="#Generator.propertyeq_sql-2643"><span class="linenos">2643</span></a> <span class="k">def</span> <span class="nf">propertyeq_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">PropertyEQ</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.propertyeq_sql-2644"><a href="#Generator.propertyeq_sql-2644"><span class="linenos">2644</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> @@ -13789,8 +13950,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.escape_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.escape_sql-2620"><a href="#Generator.escape_sql-2620"><span class="linenos">2620</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-2621"><a href="#Generator.escape_sql-2621"><span class="linenos">2621</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-2646"><a href="#Generator.escape_sql-2646"><span class="linenos">2646</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-2647"><a href="#Generator.escape_sql-2647"><span class="linenos">2647</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> @@ -13808,8 +13969,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.glob_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.glob_sql-2623"><a href="#Generator.glob_sql-2623"><span class="linenos">2623</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-2624"><a href="#Generator.glob_sql-2624"><span class="linenos">2624</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-2649"><a href="#Generator.glob_sql-2649"><span class="linenos">2649</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-2650"><a href="#Generator.glob_sql-2650"><span class="linenos">2650</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> @@ -13827,8 +13988,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.gt_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.gt_sql-2626"><a href="#Generator.gt_sql-2626"><span class="linenos">2626</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-2627"><a href="#Generator.gt_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">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-2652"><a href="#Generator.gt_sql-2652"><span class="linenos">2652</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-2653"><a href="#Generator.gt_sql-2653"><span class="linenos">2653</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> @@ -13846,8 +14007,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.gte_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.gte_sql-2629"><a href="#Generator.gte_sql-2629"><span class="linenos">2629</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-2630"><a href="#Generator.gte_sql-2630"><span class="linenos">2630</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-2655"><a href="#Generator.gte_sql-2655"><span class="linenos">2655</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-2656"><a href="#Generator.gte_sql-2656"><span class="linenos">2656</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> @@ -13865,8 +14026,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.ilike_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.ilike_sql-2632"><a href="#Generator.ilike_sql-2632"><span class="linenos">2632</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-2633"><a href="#Generator.ilike_sql-2633"><span class="linenos">2633</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-2658"><a href="#Generator.ilike_sql-2658"><span class="linenos">2658</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-2659"><a href="#Generator.ilike_sql-2659"><span class="linenos">2659</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> @@ -13884,8 +14045,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.ilikeany_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.ilikeany_sql-2635"><a href="#Generator.ilikeany_sql-2635"><span class="linenos">2635</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-2636"><a href="#Generator.ilikeany_sql-2636"><span class="linenos">2636</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-2661"><a href="#Generator.ilikeany_sql-2661"><span class="linenos">2661</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-2662"><a href="#Generator.ilikeany_sql-2662"><span class="linenos">2662</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> @@ -13903,12 +14064,12 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.is_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.is_sql-2638"><a href="#Generator.is_sql-2638"><span class="linenos">2638</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-2639"><a href="#Generator.is_sql-2639"><span class="linenos">2639</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-2640"><a href="#Generator.is_sql-2640"><span class="linenos">2640</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-2641"><a href="#Generator.is_sql-2641"><span class="linenos">2641</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-2642"><a href="#Generator.is_sql-2642"><span class="linenos">2642</span></a> <span class="p">)</span> -</span><span id="Generator.is_sql-2643"><a href="#Generator.is_sql-2643"><span class="linenos">2643</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-2664"><a href="#Generator.is_sql-2664"><span class="linenos">2664</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-2665"><a href="#Generator.is_sql-2665"><span class="linenos">2665</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-2666"><a href="#Generator.is_sql-2666"><span class="linenos">2666</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-2667"><a href="#Generator.is_sql-2667"><span class="linenos">2667</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-2668"><a href="#Generator.is_sql-2668"><span class="linenos">2668</span></a> <span class="p">)</span> +</span><span id="Generator.is_sql-2669"><a href="#Generator.is_sql-2669"><span class="linenos">2669</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> @@ -13926,8 +14087,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.like_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.like_sql-2645"><a href="#Generator.like_sql-2645"><span class="linenos">2645</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-2646"><a href="#Generator.like_sql-2646"><span class="linenos">2646</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-2671"><a href="#Generator.like_sql-2671"><span class="linenos">2671</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-2672"><a href="#Generator.like_sql-2672"><span class="linenos">2672</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> @@ -13945,8 +14106,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.likeany_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.likeany_sql-2648"><a href="#Generator.likeany_sql-2648"><span class="linenos">2648</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-2649"><a href="#Generator.likeany_sql-2649"><span class="linenos">2649</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-2674"><a href="#Generator.likeany_sql-2674"><span class="linenos">2674</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-2675"><a href="#Generator.likeany_sql-2675"><span class="linenos">2675</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> @@ -13964,8 +14125,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.similarto_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.similarto_sql-2651"><a href="#Generator.similarto_sql-2651"><span class="linenos">2651</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-2652"><a href="#Generator.similarto_sql-2652"><span class="linenos">2652</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-2677"><a href="#Generator.similarto_sql-2677"><span class="linenos">2677</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-2678"><a href="#Generator.similarto_sql-2678"><span class="linenos">2678</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> @@ -13983,8 +14144,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.lt_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.lt_sql-2654"><a href="#Generator.lt_sql-2654"><span class="linenos">2654</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-2655"><a href="#Generator.lt_sql-2655"><span class="linenos">2655</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-2680"><a href="#Generator.lt_sql-2680"><span class="linenos">2680</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-2681"><a href="#Generator.lt_sql-2681"><span class="linenos">2681</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> @@ -14002,8 +14163,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.lte_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.lte_sql-2657"><a href="#Generator.lte_sql-2657"><span class="linenos">2657</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-2658"><a href="#Generator.lte_sql-2658"><span class="linenos">2658</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-2683"><a href="#Generator.lte_sql-2683"><span class="linenos">2683</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-2684"><a href="#Generator.lte_sql-2684"><span class="linenos">2684</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> @@ -14021,8 +14182,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.mod_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.mod_sql-2660"><a href="#Generator.mod_sql-2660"><span class="linenos">2660</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-2661"><a href="#Generator.mod_sql-2661"><span class="linenos">2661</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-2686"><a href="#Generator.mod_sql-2686"><span class="linenos">2686</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-2687"><a href="#Generator.mod_sql-2687"><span class="linenos">2687</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> @@ -14040,8 +14201,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.mul_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.mul_sql-2663"><a href="#Generator.mul_sql-2663"><span class="linenos">2663</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-2664"><a href="#Generator.mul_sql-2664"><span class="linenos">2664</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-2689"><a href="#Generator.mul_sql-2689"><span class="linenos">2689</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-2690"><a href="#Generator.mul_sql-2690"><span class="linenos">2690</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> @@ -14059,8 +14220,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.neq_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.neq_sql-2666"><a href="#Generator.neq_sql-2666"><span class="linenos">2666</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-2667"><a href="#Generator.neq_sql-2667"><span class="linenos">2667</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-2692"><a href="#Generator.neq_sql-2692"><span class="linenos">2692</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-2693"><a href="#Generator.neq_sql-2693"><span class="linenos">2693</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> @@ -14078,8 +14239,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.nullsafeeq_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.nullsafeeq_sql-2669"><a href="#Generator.nullsafeeq_sql-2669"><span class="linenos">2669</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-2670"><a href="#Generator.nullsafeeq_sql-2670"><span class="linenos">2670</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-2695"><a href="#Generator.nullsafeeq_sql-2695"><span class="linenos">2695</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-2696"><a href="#Generator.nullsafeeq_sql-2696"><span class="linenos">2696</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> @@ -14097,8 +14258,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.nullsafeneq_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.nullsafeneq_sql-2672"><a href="#Generator.nullsafeneq_sql-2672"><span class="linenos">2672</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-2673"><a href="#Generator.nullsafeneq_sql-2673"><span class="linenos">2673</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-2698"><a href="#Generator.nullsafeneq_sql-2698"><span class="linenos">2698</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-2699"><a href="#Generator.nullsafeneq_sql-2699"><span class="linenos">2699</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> @@ -14116,8 +14277,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.or_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.or_sql-2675"><a href="#Generator.or_sql-2675"><span class="linenos">2675</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-2676"><a href="#Generator.or_sql-2676"><span class="linenos">2676</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-2701"><a href="#Generator.or_sql-2701"><span class="linenos">2701</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-2702"><a href="#Generator.or_sql-2702"><span class="linenos">2702</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> @@ -14135,8 +14296,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.slice_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.slice_sql-2678"><a href="#Generator.slice_sql-2678"><span class="linenos">2678</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-2679"><a href="#Generator.slice_sql-2679"><span class="linenos">2679</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-2704"><a href="#Generator.slice_sql-2704"><span class="linenos">2704</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-2705"><a href="#Generator.slice_sql-2705"><span class="linenos">2705</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> @@ -14154,8 +14315,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.sub_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.sub_sql-2681"><a href="#Generator.sub_sql-2681"><span class="linenos">2681</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-2682"><a href="#Generator.sub_sql-2682"><span class="linenos">2682</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-2707"><a href="#Generator.sub_sql-2707"><span class="linenos">2707</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-2708"><a href="#Generator.sub_sql-2708"><span class="linenos">2708</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> @@ -14173,8 +14334,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.trycast_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.trycast_sql-2684"><a href="#Generator.trycast_sql-2684"><span class="linenos">2684</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-2685"><a href="#Generator.trycast_sql-2685"><span class="linenos">2685</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-2710"><a href="#Generator.trycast_sql-2710"><span class="linenos">2710</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-2711"><a href="#Generator.trycast_sql-2711"><span class="linenos">2711</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> @@ -14192,14 +14353,14 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.log_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.log_sql-2687"><a href="#Generator.log_sql-2687"><span class="linenos">2687</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-2688"><a href="#Generator.log_sql-2688"><span class="linenos">2688</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><span id="Generator.log_sql-2689"><a href="#Generator.log_sql-2689"><span class="linenos">2689</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span> -</span><span id="Generator.log_sql-2690"><a href="#Generator.log_sql-2690"><span class="linenos">2690</span></a> -</span><span id="Generator.log_sql-2691"><a href="#Generator.log_sql-2691"><span class="linenos">2691</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">LOG_BASE_FIRST</span><span class="p">:</span> -</span><span id="Generator.log_sql-2692"><a href="#Generator.log_sql-2692"><span class="linenos">2692</span></a> <span class="n">this</span><span class="p">,</span> <span class="n">expr</span> <span class="o">=</span> <span class="n">expr</span><span class="p">,</span> <span class="n">this</span> -</span><span id="Generator.log_sql-2693"><a href="#Generator.log_sql-2693"><span class="linenos">2693</span></a> -</span><span id="Generator.log_sql-2694"><a href="#Generator.log_sql-2694"><span class="linenos">2694</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="n">this</span><span class="p">,</span> <span class="n">expr</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.log_sql-2713"><a href="#Generator.log_sql-2713"><span class="linenos">2713</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-2714"><a href="#Generator.log_sql-2714"><span class="linenos">2714</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><span id="Generator.log_sql-2715"><a href="#Generator.log_sql-2715"><span class="linenos">2715</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span> +</span><span id="Generator.log_sql-2716"><a href="#Generator.log_sql-2716"><span class="linenos">2716</span></a> +</span><span id="Generator.log_sql-2717"><a href="#Generator.log_sql-2717"><span class="linenos">2717</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">LOG_BASE_FIRST</span><span class="p">:</span> +</span><span id="Generator.log_sql-2718"><a href="#Generator.log_sql-2718"><span class="linenos">2718</span></a> <span class="n">this</span><span class="p">,</span> <span class="n">expr</span> <span class="o">=</span> <span class="n">expr</span><span class="p">,</span> <span class="n">this</span> +</span><span id="Generator.log_sql-2719"><a href="#Generator.log_sql-2719"><span class="linenos">2719</span></a> +</span><span id="Generator.log_sql-2720"><a href="#Generator.log_sql-2720"><span class="linenos">2720</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="n">this</span><span class="p">,</span> <span class="n">expr</span><span class="p">)</span> </span></pre></div> @@ -14217,12 +14378,12 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.use_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.use_sql-2696"><a href="#Generator.use_sql-2696"><span class="linenos">2696</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-2697"><a href="#Generator.use_sql-2697"><span class="linenos">2697</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-2698"><a href="#Generator.use_sql-2698"><span class="linenos">2698</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-2699"><a href="#Generator.use_sql-2699"><span class="linenos">2699</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-2700"><a href="#Generator.use_sql-2700"><span class="linenos">2700</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-2701"><a href="#Generator.use_sql-2701"><span class="linenos">2701</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-2722"><a href="#Generator.use_sql-2722"><span class="linenos">2722</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-2723"><a href="#Generator.use_sql-2723"><span class="linenos">2723</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-2724"><a href="#Generator.use_sql-2724"><span class="linenos">2724</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-2725"><a href="#Generator.use_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.use_sql-2726"><a href="#Generator.use_sql-2726"><span class="linenos">2726</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-2727"><a href="#Generator.use_sql-2727"><span class="linenos">2727</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> @@ -14240,9 +14401,9 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.binary"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.binary-2703"><a href="#Generator.binary-2703"><span class="linenos">2703</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-2704"><a href="#Generator.binary-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">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-2705"><a href="#Generator.binary-2705"><span class="linenos">2705</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-2729"><a href="#Generator.binary-2729"><span class="linenos">2729</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-2730"><a href="#Generator.binary-2730"><span class="linenos">2730</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-2731"><a href="#Generator.binary-2731"><span class="linenos">2731</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> @@ -14260,24 +14421,24 @@ it is safer to copy.</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-2707"><a href="#Generator.function_fallback_sql-2707"><span class="linenos">2707</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-2708"><a href="#Generator.function_fallback_sql-2708"><span class="linenos">2708</span></a> <span class="n">args</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="Generator.function_fallback_sql-2709"><a href="#Generator.function_fallback_sql-2709"><span class="linenos">2709</span></a> -</span><span id="Generator.function_fallback_sql-2710"><a href="#Generator.function_fallback_sql-2710"><span class="linenos">2710</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-2711"><a href="#Generator.function_fallback_sql-2711"><span class="linenos">2711</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-2712"><a href="#Generator.function_fallback_sql-2712"><span class="linenos">2712</span></a> -</span><span id="Generator.function_fallback_sql-2713"><a href="#Generator.function_fallback_sql-2713"><span class="linenos">2713</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-2714"><a href="#Generator.function_fallback_sql-2714"><span class="linenos">2714</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-2715"><a href="#Generator.function_fallback_sql-2715"><span class="linenos">2715</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-2716"><a href="#Generator.function_fallback_sql-2716"><span class="linenos">2716</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-2717"><a href="#Generator.function_fallback_sql-2717"><span class="linenos">2717</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-2718"><a href="#Generator.function_fallback_sql-2718"><span class="linenos">2718</span></a> -</span><span id="Generator.function_fallback_sql-2719"><a href="#Generator.function_fallback_sql-2719"><span class="linenos">2719</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-2720"><a href="#Generator.function_fallback_sql-2720"><span class="linenos">2720</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-2721"><a href="#Generator.function_fallback_sql-2721"><span class="linenos">2721</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator.function_fallback_sql-2722"><a href="#Generator.function_fallback_sql-2722"><span class="linenos">2722</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-2723"><a href="#Generator.function_fallback_sql-2723"><span class="linenos">2723</span></a> -</span><span id="Generator.function_fallback_sql-2724"><a href="#Generator.function_fallback_sql-2724"><span class="linenos">2724</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-2733"><a href="#Generator.function_fallback_sql-2733"><span class="linenos">2733</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-2734"><a href="#Generator.function_fallback_sql-2734"><span class="linenos">2734</span></a> <span class="n">args</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="Generator.function_fallback_sql-2735"><a href="#Generator.function_fallback_sql-2735"><span class="linenos">2735</span></a> +</span><span id="Generator.function_fallback_sql-2736"><a href="#Generator.function_fallback_sql-2736"><span class="linenos">2736</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-2737"><a href="#Generator.function_fallback_sql-2737"><span class="linenos">2737</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-2738"><a href="#Generator.function_fallback_sql-2738"><span class="linenos">2738</span></a> +</span><span id="Generator.function_fallback_sql-2739"><a href="#Generator.function_fallback_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">arg_value</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span> +</span><span id="Generator.function_fallback_sql-2740"><a href="#Generator.function_fallback_sql-2740"><span class="linenos">2740</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-2741"><a href="#Generator.function_fallback_sql-2741"><span class="linenos">2741</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-2742"><a href="#Generator.function_fallback_sql-2742"><span class="linenos">2742</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-2743"><a href="#Generator.function_fallback_sql-2743"><span class="linenos">2743</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-2744"><a href="#Generator.function_fallback_sql-2744"><span class="linenos">2744</span></a> +</span><span id="Generator.function_fallback_sql-2745"><a href="#Generator.function_fallback_sql-2745"><span class="linenos">2745</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-2746"><a href="#Generator.function_fallback_sql-2746"><span class="linenos">2746</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-2747"><a href="#Generator.function_fallback_sql-2747"><span class="linenos">2747</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator.function_fallback_sql-2748"><a href="#Generator.function_fallback_sql-2748"><span class="linenos">2748</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-2749"><a href="#Generator.function_fallback_sql-2749"><span class="linenos">2749</span></a> +</span><span id="Generator.function_fallback_sql-2750"><a href="#Generator.function_fallback_sql-2750"><span class="linenos">2750</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> @@ -14295,14 +14456,14 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.func"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.func-2726"><a href="#Generator.func-2726"><span class="linenos">2726</span></a> <span class="k">def</span> <span class="nf">func</span><span class="p">(</span> -</span><span id="Generator.func-2727"><a href="#Generator.func-2727"><span class="linenos">2727</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Generator.func-2728"><a href="#Generator.func-2728"><span class="linenos">2728</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-2729"><a href="#Generator.func-2729"><span class="linenos">2729</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-2730"><a href="#Generator.func-2730"><span class="linenos">2730</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-2731"><a href="#Generator.func-2731"><span class="linenos">2731</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-2732"><a href="#Generator.func-2732"><span class="linenos">2732</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.func-2733"><a href="#Generator.func-2733"><span class="linenos">2733</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-2752"><a href="#Generator.func-2752"><span class="linenos">2752</span></a> <span class="k">def</span> <span class="nf">func</span><span class="p">(</span> +</span><span id="Generator.func-2753"><a href="#Generator.func-2753"><span class="linenos">2753</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Generator.func-2754"><a href="#Generator.func-2754"><span class="linenos">2754</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-2755"><a href="#Generator.func-2755"><span class="linenos">2755</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-2756"><a href="#Generator.func-2756"><span class="linenos">2756</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-2757"><a href="#Generator.func-2757"><span class="linenos">2757</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-2758"><a href="#Generator.func-2758"><span class="linenos">2758</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.func-2759"><a href="#Generator.func-2759"><span class="linenos">2759</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> @@ -14320,11 +14481,11 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.format_args"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.format_args-2735"><a href="#Generator.format_args-2735"><span class="linenos">2735</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-2736"><a href="#Generator.format_args-2736"><span class="linenos">2736</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-2737"><a href="#Generator.format_args-2737"><span class="linenos">2737</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-2738"><a href="#Generator.format_args-2738"><span class="linenos">2738</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-2739"><a href="#Generator.format_args-2739"><span class="linenos">2739</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-2761"><a href="#Generator.format_args-2761"><span class="linenos">2761</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-2762"><a href="#Generator.format_args-2762"><span class="linenos">2762</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-2763"><a href="#Generator.format_args-2763"><span class="linenos">2763</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-2764"><a href="#Generator.format_args-2764"><span class="linenos">2764</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-2765"><a href="#Generator.format_args-2765"><span class="linenos">2765</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> @@ -14342,8 +14503,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.text_width"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.text_width-2741"><a href="#Generator.text_width-2741"><span class="linenos">2741</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-2742"><a href="#Generator.text_width-2742"><span class="linenos">2742</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-2767"><a href="#Generator.text_width-2767"><span class="linenos">2767</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-2768"><a href="#Generator.text_width-2768"><span class="linenos">2768</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> @@ -14361,12 +14522,12 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.format_time"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.format_time-2744"><a href="#Generator.format_time-2744"><span class="linenos">2744</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-2745"><a href="#Generator.format_time-2745"><span class="linenos">2745</span></a> <span class="k">return</span> <span class="n">format_time</span><span class="p">(</span> -</span><span id="Generator.format_time-2746"><a href="#Generator.format_time-2746"><span class="linenos">2746</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><span id="Generator.format_time-2747"><a href="#Generator.format_time-2747"><span class="linenos">2747</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">INVERSE_TIME_MAPPING</span><span class="p">,</span> -</span><span id="Generator.format_time-2748"><a href="#Generator.format_time-2748"><span class="linenos">2748</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">INVERSE_TIME_TRIE</span><span class="p">,</span> -</span><span id="Generator.format_time-2749"><a href="#Generator.format_time-2749"><span class="linenos">2749</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.format_time-2770"><a href="#Generator.format_time-2770"><span class="linenos">2770</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-2771"><a href="#Generator.format_time-2771"><span class="linenos">2771</span></a> <span class="k">return</span> <span class="n">format_time</span><span class="p">(</span> +</span><span id="Generator.format_time-2772"><a href="#Generator.format_time-2772"><span class="linenos">2772</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><span id="Generator.format_time-2773"><a href="#Generator.format_time-2773"><span class="linenos">2773</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">INVERSE_TIME_MAPPING</span><span class="p">,</span> +</span><span id="Generator.format_time-2774"><a href="#Generator.format_time-2774"><span class="linenos">2774</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">INVERSE_TIME_TRIE</span><span class="p">,</span> +</span><span id="Generator.format_time-2775"><a href="#Generator.format_time-2775"><span class="linenos">2775</span></a> <span class="p">)</span> </span></pre></div> @@ -14384,51 +14545,51 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.expressions"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.expressions-2751"><a href="#Generator.expressions-2751"><span class="linenos">2751</span></a> <span class="k">def</span> <span class="nf">expressions</span><span class="p">(</span> -</span><span id="Generator.expressions-2752"><a href="#Generator.expressions-2752"><span class="linenos">2752</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Generator.expressions-2753"><a href="#Generator.expressions-2753"><span class="linenos">2753</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-2754"><a href="#Generator.expressions-2754"><span class="linenos">2754</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-2755"><a href="#Generator.expressions-2755"><span class="linenos">2755</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-2756"><a href="#Generator.expressions-2756"><span class="linenos">2756</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-2757"><a href="#Generator.expressions-2757"><span class="linenos">2757</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-2758"><a href="#Generator.expressions-2758"><span class="linenos">2758</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-2759"><a href="#Generator.expressions-2759"><span class="linenos">2759</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-2760"><a href="#Generator.expressions-2760"><span class="linenos">2760</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-2761"><a href="#Generator.expressions-2761"><span class="linenos">2761</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.expressions-2762"><a href="#Generator.expressions-2762"><span class="linenos">2762</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-2763"><a href="#Generator.expressions-2763"><span class="linenos">2763</span></a> -</span><span id="Generator.expressions-2764"><a href="#Generator.expressions-2764"><span class="linenos">2764</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-2765"><a href="#Generator.expressions-2765"><span class="linenos">2765</span></a> <span class="k">return</span> <span class="s2">""</span> -</span><span id="Generator.expressions-2766"><a href="#Generator.expressions-2766"><span class="linenos">2766</span></a> -</span><span id="Generator.expressions-2767"><a href="#Generator.expressions-2767"><span class="linenos">2767</span></a> <span class="k">if</span> <span class="n">flat</span><span class="p">:</span> -</span><span id="Generator.expressions-2768"><a href="#Generator.expressions-2768"><span class="linenos">2768</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-2769"><a href="#Generator.expressions-2769"><span class="linenos">2769</span></a> -</span><span id="Generator.expressions-2770"><a href="#Generator.expressions-2770"><span class="linenos">2770</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-2771"><a href="#Generator.expressions-2771"><span class="linenos">2771</span></a> -</span><span id="Generator.expressions-2772"><a href="#Generator.expressions-2772"><span class="linenos">2772</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-2773"><a href="#Generator.expressions-2773"><span class="linenos">2773</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-2774"><a href="#Generator.expressions-2774"><span class="linenos">2774</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-2775"><a href="#Generator.expressions-2775"><span class="linenos">2775</span></a> -</span><span id="Generator.expressions-2776"><a href="#Generator.expressions-2776"><span class="linenos">2776</span></a> <span class="n">result_sqls</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="Generator.expressions-2777"><a href="#Generator.expressions-2777"><span class="linenos">2777</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-2778"><a href="#Generator.expressions-2778"><span class="linenos">2778</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-2779"><a href="#Generator.expressions-2779"><span class="linenos">2779</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-2780"><a href="#Generator.expressions-2780"><span class="linenos">2780</span></a> <span class="k">continue</span> -</span><span id="Generator.expressions-2781"><a href="#Generator.expressions-2781"><span class="linenos">2781</span></a> -</span><span id="Generator.expressions-2782"><a href="#Generator.expressions-2782"><span class="linenos">2782</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-2783"><a href="#Generator.expressions-2783"><span class="linenos">2783</span></a> -</span><span id="Generator.expressions-2784"><a href="#Generator.expressions-2784"><span class="linenos">2784</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-2785"><a href="#Generator.expressions-2785"><span class="linenos">2785</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-2786"><a href="#Generator.expressions-2786"><span class="linenos">2786</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-2787"><a href="#Generator.expressions-2787"><span class="linenos">2787</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator.expressions-2788"><a href="#Generator.expressions-2788"><span class="linenos">2788</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-2789"><a href="#Generator.expressions-2789"><span class="linenos">2789</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-2790"><a href="#Generator.expressions-2790"><span class="linenos">2790</span></a> <span class="p">)</span> -</span><span id="Generator.expressions-2791"><a href="#Generator.expressions-2791"><span class="linenos">2791</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator.expressions-2792"><a href="#Generator.expressions-2792"><span class="linenos">2792</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-2793"><a href="#Generator.expressions-2793"><span class="linenos">2793</span></a> -</span><span id="Generator.expressions-2794"><a href="#Generator.expressions-2794"><span class="linenos">2794</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-2795"><a href="#Generator.expressions-2795"><span class="linenos">2795</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> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.expressions-2777"><a href="#Generator.expressions-2777"><span class="linenos">2777</span></a> <span class="k">def</span> <span class="nf">expressions</span><span class="p">(</span> +</span><span id="Generator.expressions-2778"><a href="#Generator.expressions-2778"><span class="linenos">2778</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Generator.expressions-2779"><a href="#Generator.expressions-2779"><span class="linenos">2779</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-2780"><a href="#Generator.expressions-2780"><span class="linenos">2780</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-2781"><a href="#Generator.expressions-2781"><span class="linenos">2781</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-2782"><a href="#Generator.expressions-2782"><span class="linenos">2782</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-2783"><a href="#Generator.expressions-2783"><span class="linenos">2783</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-2784"><a href="#Generator.expressions-2784"><span class="linenos">2784</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-2785"><a href="#Generator.expressions-2785"><span class="linenos">2785</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-2786"><a href="#Generator.expressions-2786"><span class="linenos">2786</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-2787"><a href="#Generator.expressions-2787"><span class="linenos">2787</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.expressions-2788"><a href="#Generator.expressions-2788"><span class="linenos">2788</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-2789"><a href="#Generator.expressions-2789"><span class="linenos">2789</span></a> +</span><span id="Generator.expressions-2790"><a href="#Generator.expressions-2790"><span class="linenos">2790</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-2791"><a href="#Generator.expressions-2791"><span class="linenos">2791</span></a> <span class="k">return</span> <span class="s2">""</span> +</span><span id="Generator.expressions-2792"><a href="#Generator.expressions-2792"><span class="linenos">2792</span></a> +</span><span id="Generator.expressions-2793"><a href="#Generator.expressions-2793"><span class="linenos">2793</span></a> <span class="k">if</span> <span class="n">flat</span><span class="p">:</span> +</span><span id="Generator.expressions-2794"><a href="#Generator.expressions-2794"><span class="linenos">2794</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-2795"><a href="#Generator.expressions-2795"><span class="linenos">2795</span></a> +</span><span id="Generator.expressions-2796"><a href="#Generator.expressions-2796"><span class="linenos">2796</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-2797"><a href="#Generator.expressions-2797"><span class="linenos">2797</span></a> +</span><span id="Generator.expressions-2798"><a href="#Generator.expressions-2798"><span class="linenos">2798</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-2799"><a href="#Generator.expressions-2799"><span class="linenos">2799</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-2800"><a href="#Generator.expressions-2800"><span class="linenos">2800</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-2801"><a href="#Generator.expressions-2801"><span class="linenos">2801</span></a> +</span><span id="Generator.expressions-2802"><a href="#Generator.expressions-2802"><span class="linenos">2802</span></a> <span class="n">result_sqls</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="Generator.expressions-2803"><a href="#Generator.expressions-2803"><span class="linenos">2803</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-2804"><a href="#Generator.expressions-2804"><span class="linenos">2804</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-2805"><a href="#Generator.expressions-2805"><span class="linenos">2805</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-2806"><a href="#Generator.expressions-2806"><span class="linenos">2806</span></a> <span class="k">continue</span> +</span><span id="Generator.expressions-2807"><a href="#Generator.expressions-2807"><span class="linenos">2807</span></a> +</span><span id="Generator.expressions-2808"><a href="#Generator.expressions-2808"><span class="linenos">2808</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-2809"><a href="#Generator.expressions-2809"><span class="linenos">2809</span></a> +</span><span id="Generator.expressions-2810"><a href="#Generator.expressions-2810"><span class="linenos">2810</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-2811"><a href="#Generator.expressions-2811"><span class="linenos">2811</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-2812"><a href="#Generator.expressions-2812"><span class="linenos">2812</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-2813"><a href="#Generator.expressions-2813"><span class="linenos">2813</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator.expressions-2814"><a href="#Generator.expressions-2814"><span class="linenos">2814</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-2815"><a href="#Generator.expressions-2815"><span class="linenos">2815</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-2816"><a href="#Generator.expressions-2816"><span class="linenos">2816</span></a> <span class="p">)</span> +</span><span id="Generator.expressions-2817"><a href="#Generator.expressions-2817"><span class="linenos">2817</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator.expressions-2818"><a href="#Generator.expressions-2818"><span class="linenos">2818</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-2819"><a href="#Generator.expressions-2819"><span class="linenos">2819</span></a> +</span><span id="Generator.expressions-2820"><a href="#Generator.expressions-2820"><span class="linenos">2820</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-2821"><a href="#Generator.expressions-2821"><span class="linenos">2821</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> @@ -14446,12 +14607,12 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.op_expressions"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.op_expressions-2797"><a href="#Generator.op_expressions-2797"><span class="linenos">2797</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-2798"><a href="#Generator.op_expressions-2798"><span class="linenos">2798</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-2799"><a href="#Generator.op_expressions-2799"><span class="linenos">2799</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-2800"><a href="#Generator.op_expressions-2800"><span class="linenos">2800</span></a> <span class="k">if</span> <span class="n">flat</span><span class="p">:</span> -</span><span id="Generator.op_expressions-2801"><a href="#Generator.op_expressions-2801"><span class="linenos">2801</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-2802"><a href="#Generator.op_expressions-2802"><span class="linenos">2802</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-2823"><a href="#Generator.op_expressions-2823"><span class="linenos">2823</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-2824"><a href="#Generator.op_expressions-2824"><span class="linenos">2824</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-2825"><a href="#Generator.op_expressions-2825"><span class="linenos">2825</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-2826"><a href="#Generator.op_expressions-2826"><span class="linenos">2826</span></a> <span class="k">if</span> <span class="n">flat</span><span class="p">:</span> +</span><span id="Generator.op_expressions-2827"><a href="#Generator.op_expressions-2827"><span class="linenos">2827</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-2828"><a href="#Generator.op_expressions-2828"><span class="linenos">2828</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> @@ -14469,11 +14630,11 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.naked_property"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.naked_property-2804"><a href="#Generator.naked_property-2804"><span class="linenos">2804</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-2805"><a href="#Generator.naked_property-2805"><span class="linenos">2805</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-2806"><a href="#Generator.naked_property-2806"><span class="linenos">2806</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-2807"><a href="#Generator.naked_property-2807"><span class="linenos">2807</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-2808"><a href="#Generator.naked_property-2808"><span class="linenos">2808</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-2830"><a href="#Generator.naked_property-2830"><span class="linenos">2830</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-2831"><a href="#Generator.naked_property-2831"><span class="linenos">2831</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-2832"><a href="#Generator.naked_property-2832"><span class="linenos">2832</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-2833"><a href="#Generator.naked_property-2833"><span class="linenos">2833</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-2834"><a href="#Generator.naked_property-2834"><span class="linenos">2834</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> @@ -14491,12 +14652,12 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.set_operation"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.set_operation-2810"><a href="#Generator.set_operation-2810"><span class="linenos">2810</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">Union</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-2811"><a href="#Generator.set_operation-2811"><span class="linenos">2811</span></a> <span class="n">this</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="bp">self</span><span 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">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.set_operation-2812"><a href="#Generator.set_operation-2812"><span class="linenos">2812</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-2813"><a href="#Generator.set_operation-2813"><span class="linenos">2813</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-2814"><a href="#Generator.set_operation-2814"><span class="linenos">2814</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-2815"><a href="#Generator.set_operation-2815"><span class="linenos">2815</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.set_operation-2836"><a href="#Generator.set_operation-2836"><span class="linenos">2836</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">Union</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-2837"><a href="#Generator.set_operation-2837"><span class="linenos">2837</span></a> <span class="n">this</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="bp">self</span><span 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">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.set_operation-2838"><a href="#Generator.set_operation-2838"><span class="linenos">2838</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-2839"><a href="#Generator.set_operation-2839"><span class="linenos">2839</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-2840"><a href="#Generator.set_operation-2840"><span class="linenos">2840</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-2841"><a href="#Generator.set_operation-2841"><span class="linenos">2841</span></a> <span class="p">)</span> </span></pre></div> @@ -14514,8 +14675,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.tag_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.tag_sql-2817"><a href="#Generator.tag_sql-2817"><span class="linenos">2817</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-2818"><a href="#Generator.tag_sql-2818"><span class="linenos">2818</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-2843"><a href="#Generator.tag_sql-2843"><span class="linenos">2843</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-2844"><a href="#Generator.tag_sql-2844"><span class="linenos">2844</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> @@ -14527,14 +14688,14 @@ it is safer to copy.</li> <div class="attr function"> <span class="def">def</span> - <span class="name">token_sql</span><span class="signature pdoc-code condensed">(<span class="param"><span class="bp">self</span>, </span><span class="param"><span class="n">token_type</span><span class="p">:</span> <span class="n"><a href="tokens.html#TokenType">sqlglot.tokens.TokenType</a></span></span><span class="return-annotation">) -> <span class="nb">str</span>:</span></span> + <span class="name">token_sql</span><span class="signature pdoc-code condensed">(<span class="param"><span class="bp">self</span>, </span><span class="param"><span class="n">token_type</span><span class="p">:</span> <span class="n"><a href="token_type.html#TokenType">sqlglot.token_type.TokenType</a></span></span><span class="return-annotation">) -> <span class="nb">str</span>:</span></span> <label class="view-source-button" for="Generator.token_sql-view-source"><span>View Source</span></label> </div> <a class="headerlink" href="#Generator.token_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.token_sql-2820"><a href="#Generator.token_sql-2820"><span class="linenos">2820</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-2821"><a href="#Generator.token_sql-2821"><span class="linenos">2821</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-2846"><a href="#Generator.token_sql-2846"><span class="linenos">2846</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-2847"><a href="#Generator.token_sql-2847"><span class="linenos">2847</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> @@ -14552,13 +14713,13 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.userdefinedfunction_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.userdefinedfunction_sql-2823"><a href="#Generator.userdefinedfunction_sql-2823"><span class="linenos">2823</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-2824"><a href="#Generator.userdefinedfunction_sql-2824"><span class="linenos">2824</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-2825"><a href="#Generator.userdefinedfunction_sql-2825"><span class="linenos">2825</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-2826"><a href="#Generator.userdefinedfunction_sql-2826"><span class="linenos">2826</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Generator.userdefinedfunction_sql-2827"><a href="#Generator.userdefinedfunction_sql-2827"><span class="linenos">2827</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-2828"><a href="#Generator.userdefinedfunction_sql-2828"><span class="linenos">2828</span></a> <span class="p">)</span> -</span><span id="Generator.userdefinedfunction_sql-2829"><a href="#Generator.userdefinedfunction_sql-2829"><span class="linenos">2829</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-2849"><a href="#Generator.userdefinedfunction_sql-2849"><span class="linenos">2849</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-2850"><a href="#Generator.userdefinedfunction_sql-2850"><span class="linenos">2850</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-2851"><a href="#Generator.userdefinedfunction_sql-2851"><span class="linenos">2851</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-2852"><a href="#Generator.userdefinedfunction_sql-2852"><span class="linenos">2852</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Generator.userdefinedfunction_sql-2853"><a href="#Generator.userdefinedfunction_sql-2853"><span class="linenos">2853</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-2854"><a href="#Generator.userdefinedfunction_sql-2854"><span class="linenos">2854</span></a> <span class="p">)</span> +</span><span id="Generator.userdefinedfunction_sql-2855"><a href="#Generator.userdefinedfunction_sql-2855"><span class="linenos">2855</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> @@ -14576,10 +14737,10 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.joinhint_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.joinhint_sql-2831"><a href="#Generator.joinhint_sql-2831"><span class="linenos">2831</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-2832"><a href="#Generator.joinhint_sql-2832"><span class="linenos">2832</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-2833"><a href="#Generator.joinhint_sql-2833"><span class="linenos">2833</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-2834"><a href="#Generator.joinhint_sql-2834"><span class="linenos">2834</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-2857"><a href="#Generator.joinhint_sql-2857"><span class="linenos">2857</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-2858"><a href="#Generator.joinhint_sql-2858"><span class="linenos">2858</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-2859"><a href="#Generator.joinhint_sql-2859"><span class="linenos">2859</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-2860"><a href="#Generator.joinhint_sql-2860"><span class="linenos">2860</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> @@ -14597,8 +14758,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.kwarg_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.kwarg_sql-2836"><a href="#Generator.kwarg_sql-2836"><span class="linenos">2836</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-2837"><a href="#Generator.kwarg_sql-2837"><span class="linenos">2837</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-2862"><a href="#Generator.kwarg_sql-2862"><span class="linenos">2862</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-2863"><a href="#Generator.kwarg_sql-2863"><span class="linenos">2863</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> @@ -14616,25 +14777,25 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.when_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.when_sql-2839"><a href="#Generator.when_sql-2839"><span class="linenos">2839</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-2840"><a href="#Generator.when_sql-2840"><span class="linenos">2840</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-2841"><a href="#Generator.when_sql-2841"><span class="linenos">2841</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-2842"><a href="#Generator.when_sql-2842"><span class="linenos">2842</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-2843"><a href="#Generator.when_sql-2843"><span class="linenos">2843</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-2844"><a href="#Generator.when_sql-2844"><span class="linenos">2844</span></a> -</span><span id="Generator.when_sql-2845"><a href="#Generator.when_sql-2845"><span class="linenos">2845</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-2846"><a href="#Generator.when_sql-2846"><span class="linenos">2846</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-2847"><a href="#Generator.when_sql-2847"><span class="linenos">2847</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-2848"><a href="#Generator.when_sql-2848"><span class="linenos">2848</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-2849"><a href="#Generator.when_sql-2849"><span class="linenos">2849</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-2850"><a href="#Generator.when_sql-2850"><span class="linenos">2850</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-2851"><a href="#Generator.when_sql-2851"><span class="linenos">2851</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-2852"><a href="#Generator.when_sql-2852"><span class="linenos">2852</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-2853"><a href="#Generator.when_sql-2853"><span class="linenos">2853</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator.when_sql-2854"><a href="#Generator.when_sql-2854"><span class="linenos">2854</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-2855"><a href="#Generator.when_sql-2855"><span class="linenos">2855</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator.when_sql-2856"><a href="#Generator.when_sql-2856"><span class="linenos">2856</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-2857"><a href="#Generator.when_sql-2857"><span class="linenos">2857</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-2865"><a href="#Generator.when_sql-2865"><span class="linenos">2865</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-2866"><a href="#Generator.when_sql-2866"><span class="linenos">2866</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-2867"><a href="#Generator.when_sql-2867"><span class="linenos">2867</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-2868"><a href="#Generator.when_sql-2868"><span class="linenos">2868</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-2869"><a href="#Generator.when_sql-2869"><span class="linenos">2869</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-2870"><a href="#Generator.when_sql-2870"><span class="linenos">2870</span></a> +</span><span id="Generator.when_sql-2871"><a href="#Generator.when_sql-2871"><span class="linenos">2871</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-2872"><a href="#Generator.when_sql-2872"><span class="linenos">2872</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-2873"><a href="#Generator.when_sql-2873"><span class="linenos">2873</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-2874"><a href="#Generator.when_sql-2874"><span class="linenos">2874</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-2875"><a href="#Generator.when_sql-2875"><span class="linenos">2875</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-2876"><a href="#Generator.when_sql-2876"><span class="linenos">2876</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-2877"><a href="#Generator.when_sql-2877"><span class="linenos">2877</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-2878"><a href="#Generator.when_sql-2878"><span class="linenos">2878</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-2879"><a href="#Generator.when_sql-2879"><span class="linenos">2879</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator.when_sql-2880"><a href="#Generator.when_sql-2880"><span class="linenos">2880</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-2881"><a href="#Generator.when_sql-2881"><span class="linenos">2881</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator.when_sql-2882"><a href="#Generator.when_sql-2882"><span class="linenos">2882</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-2883"><a href="#Generator.when_sql-2883"><span class="linenos">2883</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> @@ -14652,23 +14813,23 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.merge_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.merge_sql-2859"><a href="#Generator.merge_sql-2859"><span class="linenos">2859</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-2860"><a href="#Generator.merge_sql-2860"><span class="linenos">2860</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-2861"><a href="#Generator.merge_sql-2861"><span class="linenos">2861</span></a> <span class="n">table_alias</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator.merge_sql-2862"><a href="#Generator.merge_sql-2862"><span class="linenos">2862</span></a> -</span><span id="Generator.merge_sql-2863"><a href="#Generator.merge_sql-2863"><span class="linenos">2863</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-2864"><a href="#Generator.merge_sql-2864"><span class="linenos">2864</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-2865"><a href="#Generator.merge_sql-2865"><span class="linenos">2865</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-2866"><a href="#Generator.merge_sql-2866"><span class="linenos">2866</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-2867"><a href="#Generator.merge_sql-2867"><span class="linenos">2867</span></a> -</span><span id="Generator.merge_sql-2868"><a href="#Generator.merge_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">table</span><span class="p">)</span> -</span><span id="Generator.merge_sql-2869"><a href="#Generator.merge_sql-2869"><span class="linenos">2869</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-2870"><a href="#Generator.merge_sql-2870"><span class="linenos">2870</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-2871"><a href="#Generator.merge_sql-2871"><span class="linenos">2871</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-2872"><a href="#Generator.merge_sql-2872"><span class="linenos">2872</span></a> -</span><span id="Generator.merge_sql-2873"><a href="#Generator.merge_sql-2873"><span class="linenos">2873</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><span id="Generator.merge_sql-2874"><a href="#Generator.merge_sql-2874"><span class="linenos">2874</span></a> <span class="n">expression</span><span class="p">,</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.merge_sql-2875"><a href="#Generator.merge_sql-2875"><span class="linenos">2875</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.merge_sql-2885"><a href="#Generator.merge_sql-2885"><span class="linenos">2885</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-2886"><a href="#Generator.merge_sql-2886"><span class="linenos">2886</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-2887"><a href="#Generator.merge_sql-2887"><span class="linenos">2887</span></a> <span class="n">table_alias</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator.merge_sql-2888"><a href="#Generator.merge_sql-2888"><span class="linenos">2888</span></a> +</span><span id="Generator.merge_sql-2889"><a href="#Generator.merge_sql-2889"><span class="linenos">2889</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-2890"><a href="#Generator.merge_sql-2890"><span class="linenos">2890</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-2891"><a href="#Generator.merge_sql-2891"><span class="linenos">2891</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-2892"><a href="#Generator.merge_sql-2892"><span class="linenos">2892</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-2893"><a href="#Generator.merge_sql-2893"><span class="linenos">2893</span></a> +</span><span id="Generator.merge_sql-2894"><a href="#Generator.merge_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">table</span><span class="p">)</span> +</span><span id="Generator.merge_sql-2895"><a href="#Generator.merge_sql-2895"><span class="linenos">2895</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-2896"><a href="#Generator.merge_sql-2896"><span class="linenos">2896</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-2897"><a href="#Generator.merge_sql-2897"><span class="linenos">2897</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-2898"><a href="#Generator.merge_sql-2898"><span class="linenos">2898</span></a> +</span><span id="Generator.merge_sql-2899"><a href="#Generator.merge_sql-2899"><span class="linenos">2899</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><span id="Generator.merge_sql-2900"><a href="#Generator.merge_sql-2900"><span class="linenos">2900</span></a> <span class="n">expression</span><span class="p">,</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.merge_sql-2901"><a href="#Generator.merge_sql-2901"><span class="linenos">2901</span></a> <span class="p">)</span> </span></pre></div> @@ -14686,11 +14847,11 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.tochar_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.tochar_sql-2877"><a href="#Generator.tochar_sql-2877"><span class="linenos">2877</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-2878"><a href="#Generator.tochar_sql-2878"><span class="linenos">2878</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-2879"><a href="#Generator.tochar_sql-2879"><span class="linenos">2879</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-2880"><a href="#Generator.tochar_sql-2880"><span class="linenos">2880</span></a> -</span><span id="Generator.tochar_sql-2881"><a href="#Generator.tochar_sql-2881"><span class="linenos">2881</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-2903"><a href="#Generator.tochar_sql-2903"><span class="linenos">2903</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-2904"><a href="#Generator.tochar_sql-2904"><span class="linenos">2904</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-2905"><a href="#Generator.tochar_sql-2905"><span class="linenos">2905</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-2906"><a href="#Generator.tochar_sql-2906"><span class="linenos">2906</span></a> +</span><span id="Generator.tochar_sql-2907"><a href="#Generator.tochar_sql-2907"><span class="linenos">2907</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> @@ -14708,12 +14869,12 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.dictproperty_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.dictproperty_sql-2883"><a href="#Generator.dictproperty_sql-2883"><span class="linenos">2883</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-2884"><a href="#Generator.dictproperty_sql-2884"><span class="linenos">2884</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-2885"><a href="#Generator.dictproperty_sql-2885"><span class="linenos">2885</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-2886"><a href="#Generator.dictproperty_sql-2886"><span class="linenos">2886</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-2887"><a href="#Generator.dictproperty_sql-2887"><span class="linenos">2887</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-2888"><a href="#Generator.dictproperty_sql-2888"><span class="linenos">2888</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-2909"><a href="#Generator.dictproperty_sql-2909"><span class="linenos">2909</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-2910"><a href="#Generator.dictproperty_sql-2910"><span class="linenos">2910</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-2911"><a href="#Generator.dictproperty_sql-2911"><span class="linenos">2911</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-2912"><a href="#Generator.dictproperty_sql-2912"><span class="linenos">2912</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-2913"><a href="#Generator.dictproperty_sql-2913"><span class="linenos">2913</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-2914"><a href="#Generator.dictproperty_sql-2914"><span class="linenos">2914</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> @@ -14731,11 +14892,11 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.dictrange_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.dictrange_sql-2890"><a href="#Generator.dictrange_sql-2890"><span class="linenos">2890</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-2891"><a href="#Generator.dictrange_sql-2891"><span class="linenos">2891</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-2892"><a href="#Generator.dictrange_sql-2892"><span class="linenos">2892</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-2893"><a href="#Generator.dictrange_sql-2893"><span class="linenos">2893</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-2894"><a href="#Generator.dictrange_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="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-2916"><a href="#Generator.dictrange_sql-2916"><span class="linenos">2916</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-2917"><a href="#Generator.dictrange_sql-2917"><span class="linenos">2917</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-2918"><a href="#Generator.dictrange_sql-2918"><span class="linenos">2918</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-2919"><a href="#Generator.dictrange_sql-2919"><span class="linenos">2919</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-2920"><a href="#Generator.dictrange_sql-2920"><span class="linenos">2920</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> @@ -14753,8 +14914,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.dictsubproperty_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.dictsubproperty_sql-2896"><a href="#Generator.dictsubproperty_sql-2896"><span class="linenos">2896</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-2897"><a href="#Generator.dictsubproperty_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">'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-2922"><a href="#Generator.dictsubproperty_sql-2922"><span class="linenos">2922</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-2923"><a href="#Generator.dictsubproperty_sql-2923"><span class="linenos">2923</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> @@ -14772,8 +14933,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.oncluster_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.oncluster_sql-2899"><a href="#Generator.oncluster_sql-2899"><span class="linenos">2899</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-2900"><a href="#Generator.oncluster_sql-2900"><span class="linenos">2900</span></a> <span class="k">return</span> <span class="s2">""</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.oncluster_sql-2925"><a href="#Generator.oncluster_sql-2925"><span class="linenos">2925</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-2926"><a href="#Generator.oncluster_sql-2926"><span class="linenos">2926</span></a> <span class="k">return</span> <span class="s2">""</span> </span></pre></div> @@ -14791,12 +14952,12 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.clusteredbyproperty_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.clusteredbyproperty_sql-2902"><a href="#Generator.clusteredbyproperty_sql-2902"><span class="linenos">2902</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-2903"><a href="#Generator.clusteredbyproperty_sql-2903"><span class="linenos">2903</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-2904"><a href="#Generator.clusteredbyproperty_sql-2904"><span class="linenos">2904</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-2905"><a href="#Generator.clusteredbyproperty_sql-2905"><span class="linenos">2905</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-2906"><a href="#Generator.clusteredbyproperty_sql-2906"><span class="linenos">2906</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-2907"><a href="#Generator.clusteredbyproperty_sql-2907"><span class="linenos">2907</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-2928"><a href="#Generator.clusteredbyproperty_sql-2928"><span class="linenos">2928</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-2929"><a href="#Generator.clusteredbyproperty_sql-2929"><span class="linenos">2929</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-2930"><a href="#Generator.clusteredbyproperty_sql-2930"><span class="linenos">2930</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-2931"><a href="#Generator.clusteredbyproperty_sql-2931"><span class="linenos">2931</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-2932"><a href="#Generator.clusteredbyproperty_sql-2932"><span class="linenos">2932</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-2933"><a href="#Generator.clusteredbyproperty_sql-2933"><span class="linenos">2933</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> @@ -14814,14 +14975,14 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.anyvalue_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.anyvalue_sql-2909"><a href="#Generator.anyvalue_sql-2909"><span class="linenos">2909</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-2910"><a href="#Generator.anyvalue_sql-2910"><span class="linenos">2910</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-2911"><a href="#Generator.anyvalue_sql-2911"><span class="linenos">2911</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-2912"><a href="#Generator.anyvalue_sql-2912"><span class="linenos">2912</span></a> -</span><span id="Generator.anyvalue_sql-2913"><a href="#Generator.anyvalue_sql-2913"><span class="linenos">2913</span></a> <span class="k">if</span> <span class="n">having</span><span class="p">:</span> -</span><span id="Generator.anyvalue_sql-2914"><a href="#Generator.anyvalue_sql-2914"><span class="linenos">2914</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-2915"><a href="#Generator.anyvalue_sql-2915"><span class="linenos">2915</span></a> -</span><span id="Generator.anyvalue_sql-2916"><a href="#Generator.anyvalue_sql-2916"><span class="linenos">2916</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-2935"><a href="#Generator.anyvalue_sql-2935"><span class="linenos">2935</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-2936"><a href="#Generator.anyvalue_sql-2936"><span class="linenos">2936</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-2937"><a href="#Generator.anyvalue_sql-2937"><span class="linenos">2937</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-2938"><a href="#Generator.anyvalue_sql-2938"><span class="linenos">2938</span></a> +</span><span id="Generator.anyvalue_sql-2939"><a href="#Generator.anyvalue_sql-2939"><span class="linenos">2939</span></a> <span class="k">if</span> <span class="n">having</span><span class="p">:</span> +</span><span id="Generator.anyvalue_sql-2940"><a href="#Generator.anyvalue_sql-2940"><span class="linenos">2940</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-2941"><a href="#Generator.anyvalue_sql-2941"><span class="linenos">2941</span></a> +</span><span id="Generator.anyvalue_sql-2942"><a href="#Generator.anyvalue_sql-2942"><span class="linenos">2942</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> @@ -14839,20 +15000,20 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.querytransform_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.querytransform_sql-2918"><a href="#Generator.querytransform_sql-2918"><span class="linenos">2918</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-2919"><a href="#Generator.querytransform_sql-2919"><span class="linenos">2919</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-2920"><a href="#Generator.querytransform_sql-2920"><span class="linenos">2920</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-2921"><a href="#Generator.querytransform_sql-2921"><span class="linenos">2921</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-2922"><a href="#Generator.querytransform_sql-2922"><span class="linenos">2922</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-2923"><a href="#Generator.querytransform_sql-2923"><span class="linenos">2923</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-2924"><a href="#Generator.querytransform_sql-2924"><span class="linenos">2924</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-2925"><a href="#Generator.querytransform_sql-2925"><span class="linenos">2925</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-2926"><a href="#Generator.querytransform_sql-2926"><span class="linenos">2926</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-2927"><a href="#Generator.querytransform_sql-2927"><span class="linenos">2927</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-2928"><a href="#Generator.querytransform_sql-2928"><span class="linenos">2928</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-2929"><a href="#Generator.querytransform_sql-2929"><span class="linenos">2929</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-2930"><a href="#Generator.querytransform_sql-2930"><span class="linenos">2930</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-2931"><a href="#Generator.querytransform_sql-2931"><span class="linenos">2931</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-2944"><a href="#Generator.querytransform_sql-2944"><span class="linenos">2944</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-2945"><a href="#Generator.querytransform_sql-2945"><span class="linenos">2945</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-2946"><a href="#Generator.querytransform_sql-2946"><span class="linenos">2946</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-2947"><a href="#Generator.querytransform_sql-2947"><span class="linenos">2947</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-2948"><a href="#Generator.querytransform_sql-2948"><span class="linenos">2948</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-2949"><a href="#Generator.querytransform_sql-2949"><span class="linenos">2949</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-2950"><a href="#Generator.querytransform_sql-2950"><span class="linenos">2950</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-2951"><a href="#Generator.querytransform_sql-2951"><span class="linenos">2951</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-2952"><a href="#Generator.querytransform_sql-2952"><span class="linenos">2952</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-2953"><a href="#Generator.querytransform_sql-2953"><span class="linenos">2953</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-2954"><a href="#Generator.querytransform_sql-2954"><span class="linenos">2954</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-2955"><a href="#Generator.querytransform_sql-2955"><span class="linenos">2955</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-2956"><a href="#Generator.querytransform_sql-2956"><span class="linenos">2956</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-2957"><a href="#Generator.querytransform_sql-2957"><span class="linenos">2957</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> @@ -14870,37 +15031,37 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.indexconstraintoption_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.indexconstraintoption_sql-2933"><a href="#Generator.indexconstraintoption_sql-2933"><span class="linenos">2933</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-2934"><a href="#Generator.indexconstraintoption_sql-2934"><span class="linenos">2934</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-2935"><a href="#Generator.indexconstraintoption_sql-2935"><span class="linenos">2935</span></a> <span class="k">if</span> <span class="n">key_block_size</span><span class="p">:</span> -</span><span id="Generator.indexconstraintoption_sql-2936"><a href="#Generator.indexconstraintoption_sql-2936"><span class="linenos">2936</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-2937"><a href="#Generator.indexconstraintoption_sql-2937"><span class="linenos">2937</span></a> -</span><span id="Generator.indexconstraintoption_sql-2938"><a href="#Generator.indexconstraintoption_sql-2938"><span class="linenos">2938</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-2939"><a href="#Generator.indexconstraintoption_sql-2939"><span class="linenos">2939</span></a> <span class="k">if</span> <span class="n">using</span><span class="p">:</span> -</span><span id="Generator.indexconstraintoption_sql-2940"><a href="#Generator.indexconstraintoption_sql-2940"><span class="linenos">2940</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-2941"><a href="#Generator.indexconstraintoption_sql-2941"><span class="linenos">2941</span></a> -</span><span id="Generator.indexconstraintoption_sql-2942"><a href="#Generator.indexconstraintoption_sql-2942"><span class="linenos">2942</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-2943"><a href="#Generator.indexconstraintoption_sql-2943"><span class="linenos">2943</span></a> <span class="k">if</span> <span class="n">parser</span><span class="p">:</span> -</span><span id="Generator.indexconstraintoption_sql-2944"><a href="#Generator.indexconstraintoption_sql-2944"><span class="linenos">2944</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-2945"><a href="#Generator.indexconstraintoption_sql-2945"><span class="linenos">2945</span></a> -</span><span id="Generator.indexconstraintoption_sql-2946"><a href="#Generator.indexconstraintoption_sql-2946"><span class="linenos">2946</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-2947"><a href="#Generator.indexconstraintoption_sql-2947"><span class="linenos">2947</span></a> <span class="k">if</span> <span class="n">comment</span><span class="p">:</span> -</span><span id="Generator.indexconstraintoption_sql-2948"><a href="#Generator.indexconstraintoption_sql-2948"><span class="linenos">2948</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-2949"><a href="#Generator.indexconstraintoption_sql-2949"><span class="linenos">2949</span></a> -</span><span id="Generator.indexconstraintoption_sql-2950"><a href="#Generator.indexconstraintoption_sql-2950"><span class="linenos">2950</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-2951"><a href="#Generator.indexconstraintoption_sql-2951"><span class="linenos">2951</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-2952"><a href="#Generator.indexconstraintoption_sql-2952"><span class="linenos">2952</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-2953"><a href="#Generator.indexconstraintoption_sql-2953"><span class="linenos">2953</span></a> -</span><span id="Generator.indexconstraintoption_sql-2954"><a href="#Generator.indexconstraintoption_sql-2954"><span class="linenos">2954</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-2955"><a href="#Generator.indexconstraintoption_sql-2955"><span class="linenos">2955</span></a> <span class="k">if</span> <span class="n">engine_attr</span><span class="p">:</span> -</span><span id="Generator.indexconstraintoption_sql-2956"><a href="#Generator.indexconstraintoption_sql-2956"><span class="linenos">2956</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-2957"><a href="#Generator.indexconstraintoption_sql-2957"><span class="linenos">2957</span></a> -</span><span id="Generator.indexconstraintoption_sql-2958"><a href="#Generator.indexconstraintoption_sql-2958"><span class="linenos">2958</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-2959"><a href="#Generator.indexconstraintoption_sql-2959"><span class="linenos">2959</span></a> <span class="k">if</span> <span class="n">secondary_engine_attr</span><span class="p">:</span> -</span><span id="Generator.indexconstraintoption_sql-2960"><a href="#Generator.indexconstraintoption_sql-2960"><span class="linenos">2960</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-2961"><a href="#Generator.indexconstraintoption_sql-2961"><span class="linenos">2961</span></a> -</span><span id="Generator.indexconstraintoption_sql-2962"><a href="#Generator.indexconstraintoption_sql-2962"><span class="linenos">2962</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-2963"><a href="#Generator.indexconstraintoption_sql-2963"><span class="linenos">2963</span></a> <span class="k">return</span> <span class="s2">""</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.indexconstraintoption_sql-2959"><a href="#Generator.indexconstraintoption_sql-2959"><span class="linenos">2959</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-2960"><a href="#Generator.indexconstraintoption_sql-2960"><span class="linenos">2960</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-2961"><a href="#Generator.indexconstraintoption_sql-2961"><span class="linenos">2961</span></a> <span class="k">if</span> <span class="n">key_block_size</span><span class="p">:</span> +</span><span id="Generator.indexconstraintoption_sql-2962"><a href="#Generator.indexconstraintoption_sql-2962"><span class="linenos">2962</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-2963"><a href="#Generator.indexconstraintoption_sql-2963"><span class="linenos">2963</span></a> +</span><span id="Generator.indexconstraintoption_sql-2964"><a href="#Generator.indexconstraintoption_sql-2964"><span class="linenos">2964</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-2965"><a href="#Generator.indexconstraintoption_sql-2965"><span class="linenos">2965</span></a> <span class="k">if</span> <span class="n">using</span><span class="p">:</span> +</span><span id="Generator.indexconstraintoption_sql-2966"><a href="#Generator.indexconstraintoption_sql-2966"><span class="linenos">2966</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-2967"><a href="#Generator.indexconstraintoption_sql-2967"><span class="linenos">2967</span></a> +</span><span id="Generator.indexconstraintoption_sql-2968"><a href="#Generator.indexconstraintoption_sql-2968"><span class="linenos">2968</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-2969"><a href="#Generator.indexconstraintoption_sql-2969"><span class="linenos">2969</span></a> <span class="k">if</span> <span class="n">parser</span><span class="p">:</span> +</span><span id="Generator.indexconstraintoption_sql-2970"><a href="#Generator.indexconstraintoption_sql-2970"><span class="linenos">2970</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-2971"><a href="#Generator.indexconstraintoption_sql-2971"><span class="linenos">2971</span></a> +</span><span id="Generator.indexconstraintoption_sql-2972"><a href="#Generator.indexconstraintoption_sql-2972"><span class="linenos">2972</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-2973"><a href="#Generator.indexconstraintoption_sql-2973"><span class="linenos">2973</span></a> <span class="k">if</span> <span class="n">comment</span><span class="p">:</span> +</span><span id="Generator.indexconstraintoption_sql-2974"><a href="#Generator.indexconstraintoption_sql-2974"><span class="linenos">2974</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-2975"><a href="#Generator.indexconstraintoption_sql-2975"><span class="linenos">2975</span></a> +</span><span id="Generator.indexconstraintoption_sql-2976"><a href="#Generator.indexconstraintoption_sql-2976"><span class="linenos">2976</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-2977"><a href="#Generator.indexconstraintoption_sql-2977"><span class="linenos">2977</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-2978"><a href="#Generator.indexconstraintoption_sql-2978"><span class="linenos">2978</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-2979"><a href="#Generator.indexconstraintoption_sql-2979"><span class="linenos">2979</span></a> +</span><span id="Generator.indexconstraintoption_sql-2980"><a href="#Generator.indexconstraintoption_sql-2980"><span class="linenos">2980</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-2981"><a href="#Generator.indexconstraintoption_sql-2981"><span class="linenos">2981</span></a> <span class="k">if</span> <span class="n">engine_attr</span><span class="p">:</span> +</span><span id="Generator.indexconstraintoption_sql-2982"><a href="#Generator.indexconstraintoption_sql-2982"><span class="linenos">2982</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-2983"><a href="#Generator.indexconstraintoption_sql-2983"><span class="linenos">2983</span></a> +</span><span id="Generator.indexconstraintoption_sql-2984"><a href="#Generator.indexconstraintoption_sql-2984"><span class="linenos">2984</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-2985"><a href="#Generator.indexconstraintoption_sql-2985"><span class="linenos">2985</span></a> <span class="k">if</span> <span class="n">secondary_engine_attr</span><span class="p">:</span> +</span><span id="Generator.indexconstraintoption_sql-2986"><a href="#Generator.indexconstraintoption_sql-2986"><span class="linenos">2986</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-2987"><a href="#Generator.indexconstraintoption_sql-2987"><span class="linenos">2987</span></a> +</span><span id="Generator.indexconstraintoption_sql-2988"><a href="#Generator.indexconstraintoption_sql-2988"><span class="linenos">2988</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-2989"><a href="#Generator.indexconstraintoption_sql-2989"><span class="linenos">2989</span></a> <span class="k">return</span> <span class="s2">""</span> </span></pre></div> @@ -14918,18 +15079,18 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.indexcolumnconstraint_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.indexcolumnconstraint_sql-2965"><a href="#Generator.indexcolumnconstraint_sql-2965"><span class="linenos">2965</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-2966"><a href="#Generator.indexcolumnconstraint_sql-2966"><span class="linenos">2966</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-2967"><a href="#Generator.indexcolumnconstraint_sql-2967"><span class="linenos">2967</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-2968"><a href="#Generator.indexcolumnconstraint_sql-2968"><span class="linenos">2968</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-2969"><a href="#Generator.indexcolumnconstraint_sql-2969"><span class="linenos">2969</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-2970"><a href="#Generator.indexcolumnconstraint_sql-2970"><span class="linenos">2970</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-2971"><a href="#Generator.indexcolumnconstraint_sql-2971"><span class="linenos">2971</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-2972"><a href="#Generator.indexcolumnconstraint_sql-2972"><span class="linenos">2972</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-2973"><a href="#Generator.indexcolumnconstraint_sql-2973"><span class="linenos">2973</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-2974"><a href="#Generator.indexcolumnconstraint_sql-2974"><span class="linenos">2974</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-2975"><a href="#Generator.indexcolumnconstraint_sql-2975"><span class="linenos">2975</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-2976"><a href="#Generator.indexcolumnconstraint_sql-2976"><span class="linenos">2976</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-2991"><a href="#Generator.indexcolumnconstraint_sql-2991"><span class="linenos">2991</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-2992"><a href="#Generator.indexcolumnconstraint_sql-2992"><span class="linenos">2992</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-2993"><a href="#Generator.indexcolumnconstraint_sql-2993"><span class="linenos">2993</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-2994"><a href="#Generator.indexcolumnconstraint_sql-2994"><span class="linenos">2994</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-2995"><a href="#Generator.indexcolumnconstraint_sql-2995"><span class="linenos">2995</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-2996"><a href="#Generator.indexcolumnconstraint_sql-2996"><span class="linenos">2996</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-2997"><a href="#Generator.indexcolumnconstraint_sql-2997"><span class="linenos">2997</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-2998"><a href="#Generator.indexcolumnconstraint_sql-2998"><span class="linenos">2998</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-2999"><a href="#Generator.indexcolumnconstraint_sql-2999"><span class="linenos">2999</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-3000"><a href="#Generator.indexcolumnconstraint_sql-3000"><span class="linenos">3000</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-3001"><a href="#Generator.indexcolumnconstraint_sql-3001"><span class="linenos">3001</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-3002"><a href="#Generator.indexcolumnconstraint_sql-3002"><span class="linenos">3002</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> @@ -14947,20 +15108,20 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.nvl2_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.nvl2_sql-2978"><a href="#Generator.nvl2_sql-2978"><span class="linenos">2978</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-2979"><a href="#Generator.nvl2_sql-2979"><span class="linenos">2979</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-2980"><a href="#Generator.nvl2_sql-2980"><span class="linenos">2980</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-2981"><a href="#Generator.nvl2_sql-2981"><span class="linenos">2981</span></a> -</span><span id="Generator.nvl2_sql-2982"><a href="#Generator.nvl2_sql-2982"><span class="linenos">2982</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-2983"><a href="#Generator.nvl2_sql-2983"><span class="linenos">2983</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-2984"><a href="#Generator.nvl2_sql-2984"><span class="linenos">2984</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><span id="Generator.nvl2_sql-2985"><a href="#Generator.nvl2_sql-2985"><span class="linenos">2985</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-2986"><a href="#Generator.nvl2_sql-2986"><span class="linenos">2986</span></a> <span class="p">)</span> -</span><span id="Generator.nvl2_sql-2987"><a href="#Generator.nvl2_sql-2987"><span class="linenos">2987</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-2988"><a href="#Generator.nvl2_sql-2988"><span class="linenos">2988</span></a> <span class="k">if</span> <span class="n">else_cond</span><span class="p">:</span> -</span><span id="Generator.nvl2_sql-2989"><a href="#Generator.nvl2_sql-2989"><span class="linenos">2989</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="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-2990"><a href="#Generator.nvl2_sql-2990"><span class="linenos">2990</span></a> -</span><span id="Generator.nvl2_sql-2991"><a href="#Generator.nvl2_sql-2991"><span class="linenos">2991</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-3004"><a href="#Generator.nvl2_sql-3004"><span class="linenos">3004</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-3005"><a href="#Generator.nvl2_sql-3005"><span class="linenos">3005</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-3006"><a href="#Generator.nvl2_sql-3006"><span class="linenos">3006</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-3007"><a href="#Generator.nvl2_sql-3007"><span class="linenos">3007</span></a> +</span><span id="Generator.nvl2_sql-3008"><a href="#Generator.nvl2_sql-3008"><span class="linenos">3008</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-3009"><a href="#Generator.nvl2_sql-3009"><span class="linenos">3009</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-3010"><a href="#Generator.nvl2_sql-3010"><span class="linenos">3010</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><span id="Generator.nvl2_sql-3011"><a href="#Generator.nvl2_sql-3011"><span class="linenos">3011</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-3012"><a href="#Generator.nvl2_sql-3012"><span class="linenos">3012</span></a> <span class="p">)</span> +</span><span id="Generator.nvl2_sql-3013"><a href="#Generator.nvl2_sql-3013"><span class="linenos">3013</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-3014"><a href="#Generator.nvl2_sql-3014"><span class="linenos">3014</span></a> <span class="k">if</span> <span class="n">else_cond</span><span class="p">:</span> +</span><span id="Generator.nvl2_sql-3015"><a href="#Generator.nvl2_sql-3015"><span class="linenos">3015</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="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-3016"><a href="#Generator.nvl2_sql-3016"><span class="linenos">3016</span></a> +</span><span id="Generator.nvl2_sql-3017"><a href="#Generator.nvl2_sql-3017"><span class="linenos">3017</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> @@ -14978,13 +15139,13 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.comprehension_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.comprehension_sql-2993"><a href="#Generator.comprehension_sql-2993"><span class="linenos">2993</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-2994"><a href="#Generator.comprehension_sql-2994"><span class="linenos">2994</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-2995"><a href="#Generator.comprehension_sql-2995"><span class="linenos">2995</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-2996"><a href="#Generator.comprehension_sql-2996"><span class="linenos">2996</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-2997"><a href="#Generator.comprehension_sql-2997"><span class="linenos">2997</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-2998"><a href="#Generator.comprehension_sql-2998"><span class="linenos">2998</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-2999"><a href="#Generator.comprehension_sql-2999"><span class="linenos">2999</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-3019"><a href="#Generator.comprehension_sql-3019"><span class="linenos">3019</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-3020"><a href="#Generator.comprehension_sql-3020"><span class="linenos">3020</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-3021"><a href="#Generator.comprehension_sql-3021"><span class="linenos">3021</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-3022"><a href="#Generator.comprehension_sql-3022"><span class="linenos">3022</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-3023"><a href="#Generator.comprehension_sql-3023"><span class="linenos">3023</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-3024"><a href="#Generator.comprehension_sql-3024"><span class="linenos">3024</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-3025"><a href="#Generator.comprehension_sql-3025"><span class="linenos">3025</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> @@ -15002,8 +15163,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.columnprefix_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.columnprefix_sql-3001"><a href="#Generator.columnprefix_sql-3001"><span class="linenos">3001</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-3002"><a href="#Generator.columnprefix_sql-3002"><span class="linenos">3002</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-3027"><a href="#Generator.columnprefix_sql-3027"><span class="linenos">3027</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-3028"><a href="#Generator.columnprefix_sql-3028"><span class="linenos">3028</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> @@ -15021,8 +15182,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.opclass_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.opclass_sql-3004"><a href="#Generator.opclass_sql-3004"><span class="linenos">3004</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-3005"><a href="#Generator.opclass_sql-3005"><span class="linenos">3005</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-3030"><a href="#Generator.opclass_sql-3030"><span class="linenos">3030</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-3031"><a href="#Generator.opclass_sql-3031"><span class="linenos">3031</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> @@ -15040,13 +15201,13 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.predict_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.predict_sql-3007"><a href="#Generator.predict_sql-3007"><span class="linenos">3007</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-3008"><a href="#Generator.predict_sql-3008"><span class="linenos">3008</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-3009"><a href="#Generator.predict_sql-3009"><span class="linenos">3009</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-3010"><a href="#Generator.predict_sql-3010"><span class="linenos">3010</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-3011"><a href="#Generator.predict_sql-3011"><span class="linenos">3011</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-3012"><a href="#Generator.predict_sql-3012"><span class="linenos">3012</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-3013"><a href="#Generator.predict_sql-3013"><span class="linenos">3013</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-3033"><a href="#Generator.predict_sql-3033"><span class="linenos">3033</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-3034"><a href="#Generator.predict_sql-3034"><span class="linenos">3034</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-3035"><a href="#Generator.predict_sql-3035"><span class="linenos">3035</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-3036"><a href="#Generator.predict_sql-3036"><span class="linenos">3036</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-3037"><a href="#Generator.predict_sql-3037"><span class="linenos">3037</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-3038"><a href="#Generator.predict_sql-3038"><span class="linenos">3038</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-3039"><a href="#Generator.predict_sql-3039"><span class="linenos">3039</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> @@ -15064,10 +15225,10 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.forin_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.forin_sql-3015"><a href="#Generator.forin_sql-3015"><span class="linenos">3015</span></a> <span class="k">def</span> <span class="nf">forin_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ForIn</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.forin_sql-3016"><a href="#Generator.forin_sql-3016"><span class="linenos">3016</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.forin_sql-3017"><a href="#Generator.forin_sql-3017"><span class="linenos">3017</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.forin_sql-3018"><a href="#Generator.forin_sql-3018"><span class="linenos">3018</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"FOR </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> DO </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.forin_sql-3041"><a href="#Generator.forin_sql-3041"><span class="linenos">3041</span></a> <span class="k">def</span> <span class="nf">forin_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ForIn</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.forin_sql-3042"><a href="#Generator.forin_sql-3042"><span class="linenos">3042</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.forin_sql-3043"><a href="#Generator.forin_sql-3043"><span class="linenos">3043</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.forin_sql-3044"><a href="#Generator.forin_sql-3044"><span class="linenos">3044</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"FOR </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> DO </span><span class="si">{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -15085,10 +15246,10 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.refresh_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.refresh_sql-3020"><a href="#Generator.refresh_sql-3020"><span class="linenos">3020</span></a> <span class="k">def</span> <span class="nf">refresh_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Refresh</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.refresh_sql-3021"><a href="#Generator.refresh_sql-3021"><span class="linenos">3021</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.refresh_sql-3022"><a href="#Generator.refresh_sql-3022"><span class="linenos">3022</span></a> <span class="n">table</span> <span class="o">=</span> <span class="s2">""</span> <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">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="p">)</span> <span class="k">else</span> <span class="s2">"TABLE "</span> -</span><span id="Generator.refresh_sql-3023"><a href="#Generator.refresh_sql-3023"><span class="linenos">3023</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"REFRESH </span><span class="si">{</span><span class="n">table</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.refresh_sql-3046"><a href="#Generator.refresh_sql-3046"><span class="linenos">3046</span></a> <span class="k">def</span> <span class="nf">refresh_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Refresh</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.refresh_sql-3047"><a href="#Generator.refresh_sql-3047"><span class="linenos">3047</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.refresh_sql-3048"><a href="#Generator.refresh_sql-3048"><span class="linenos">3048</span></a> <span class="n">table</span> <span class="o">=</span> <span class="s2">""</span> <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">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="p">)</span> <span class="k">else</span> <span class="s2">"TABLE "</span> +</span><span id="Generator.refresh_sql-3049"><a href="#Generator.refresh_sql-3049"><span class="linenos">3049</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"REFRESH </span><span class="si">{</span><span class="n">table</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -15106,8 +15267,8 @@ it is safer to copy.</li> </div> <a class="headerlink" href="#Generator.operator_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.operator_sql-3025"><a href="#Generator.operator_sql-3025"><span class="linenos">3025</span></a> <span class="k">def</span> <span class="nf">operator_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Operator</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.operator_sql-3026"><a href="#Generator.operator_sql-3026"><span class="linenos">3026</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="sa">f</span><span class="s2">"OPERATOR(</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">'operator'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.operator_sql-3051"><a href="#Generator.operator_sql-3051"><span class="linenos">3051</span></a> <span class="k">def</span> <span class="nf">operator_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Operator</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.operator_sql-3052"><a href="#Generator.operator_sql-3052"><span class="linenos">3052</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="sa">f</span><span class="s2">"OPERATOR(</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">'operator'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">)</span> </span></pre></div> |