diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-01-31 05:44:37 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-01-31 05:44:37 +0000 |
commit | 5f8be2e0852f3c925fb873a48946caee3050899f (patch) | |
tree | 1f31666277e226f47180321c08be7ebbedc2780e /docs/sqlglot/dialects/dialect.html | |
parent | Adding upstream version 20.9.0. (diff) | |
download | sqlglot-5f8be2e0852f3c925fb873a48946caee3050899f.tar.xz sqlglot-5f8be2e0852f3c925fb873a48946caee3050899f.zip |
Adding upstream version 20.11.0.upstream/20.11.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'docs/sqlglot/dialects/dialect.html')
-rw-r--r-- | docs/sqlglot/dialects/dialect.html | 413 |
1 files changed, 229 insertions, 184 deletions
diff --git a/docs/sqlglot/dialects/dialect.html b/docs/sqlglot/dialects/dialect.html index 4778d9e..a16f7e8 100644 --- a/docs/sqlglot/dialects/dialect.html +++ b/docs/sqlglot/dialects/dialect.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.3.0"/> + <meta name="generator" content="pdoc 14.4.0"/> <title>sqlglot.dialects.dialect 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> @@ -463,9 +463,6 @@ <a class="function" href="#bool_xor_sql">bool_xor_sql</a> </li> <li> - <a class="function" href="#json_keyvalue_comma_sql">json_keyvalue_comma_sql</a> - </li> - <li> <a class="function" href="#is_parse_json">is_parse_json</a> </li> <li> @@ -492,6 +489,9 @@ <li> <a class="function" href="#no_last_day_sql">no_last_day_sql</a> </li> + <li> + <a class="function" href="#merge_without_target_sql">merge_without_target_sql</a> + </li> </ul> @@ -1050,7 +1050,7 @@ </span><span id="L-533"><a href="#L-533"><span class="linenos"> 533</span></a><span class="k">def</span> <span class="nf">no_safe_divide_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SafeDivide</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> </span><span id="L-534"><a href="#L-534"><span class="linenos"> 534</span></a> <span class="n">n</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-535"><a href="#L-535"><span class="linenos"> 535</span></a> <span class="n">d</span> <span class="o">=</span> <span class="bp">self</span><span 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-536"><a href="#L-536"><span class="linenos"> 536</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"IF(</span><span class="si">{</span><span class="n">d</span><span class="si">}</span><span class="s2"> <> 0, </span><span class="si">{</span><span class="n">n</span><span class="si">}</span><span class="s2"> / </span><span class="si">{</span><span class="n">d</span><span class="si">}</span><span class="s2">, NULL)"</span> +</span><span id="L-536"><a href="#L-536"><span class="linenos"> 536</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"IF((</span><span class="si">{</span><span class="n">d</span><span class="si">}</span><span class="s2">) <> 0, (</span><span class="si">{</span><span class="n">n</span><span class="si">}</span><span class="s2">) / (</span><span class="si">{</span><span class="n">d</span><span class="si">}</span><span class="s2">), NULL)"</span> </span><span id="L-537"><a href="#L-537"><span class="linenos"> 537</span></a> </span><span id="L-538"><a href="#L-538"><span class="linenos"> 538</span></a> </span><span id="L-539"><a href="#L-539"><span class="linenos"> 539</span></a><span class="k">def</span> <span class="nf">no_tablesample_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span 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="o">-></span> <span class="nb">str</span><span class="p">:</span> @@ -1422,99 +1422,120 @@ </span><span id="L-905"><a href="#L-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="n">a</span><span class="si">}</span><span class="s2"> AND (NOT </span><span class="si">{</span><span class="n">b</span><span class="si">}</span><span class="s2">)) OR ((NOT </span><span class="si">{</span><span class="n">a</span><span class="si">}</span><span class="s2">) AND </span><span class="si">{</span><span class="n">b</span><span class="si">}</span><span class="s2">)"</span> </span><span id="L-906"><a href="#L-906"><span class="linenos"> 906</span></a> </span><span id="L-907"><a href="#L-907"><span class="linenos"> 907</span></a> -</span><span id="L-908"><a href="#L-908"><span class="linenos"> 908</span></a><span class="c1"># Used to generate JSON_OBJECT with a comma in BigQuery and MySQL instead of colon</span> -</span><span id="L-909"><a href="#L-909"><span class="linenos"> 909</span></a><span class="k">def</span> <span class="nf">json_keyvalue_comma_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span 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-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="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><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-911"><a href="#L-911"><span class="linenos"> 911</span></a> +</span><span id="L-908"><a href="#L-908"><span class="linenos"> 908</span></a><span class="k">def</span> <span class="nf">is_parse_json</span><span 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="nb">bool</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="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">ParseJSON</span><span class="p">)</span> <span class="ow">or</span> <span class="p">(</span> +</span><span id="L-910"><a href="#L-910"><span class="linenos"> 910</span></a> <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">Cast</span><span class="p">)</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="s2">"json"</span><span class="p">)</span> +</span><span id="L-911"><a href="#L-911"><span class="linenos"> 911</span></a> <span class="p">)</span> </span><span id="L-912"><a href="#L-912"><span class="linenos"> 912</span></a> -</span><span id="L-913"><a href="#L-913"><span class="linenos"> 913</span></a><span class="k">def</span> <span class="nf">is_parse_json</span><span 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="nb">bool</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="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">ParseJSON</span><span class="p">)</span> <span class="ow">or</span> <span class="p">(</span> -</span><span id="L-915"><a href="#L-915"><span class="linenos"> 915</span></a> <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">Cast</span><span class="p">)</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="s2">"json"</span><span class="p">)</span> -</span><span id="L-916"><a href="#L-916"><span class="linenos"> 916</span></a> <span class="p">)</span> +</span><span id="L-913"><a href="#L-913"><span class="linenos"> 913</span></a> +</span><span id="L-914"><a href="#L-914"><span class="linenos"> 914</span></a><span class="k">def</span> <span class="nf">isnull_to_is_null</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">List</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-915"><a href="#L-915"><span class="linenos"> 915</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">Paren</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">Is</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</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">null</span><span class="p">()))</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><span id="L-918"><a href="#L-918"><span class="linenos"> 918</span></a> -</span><span id="L-919"><a href="#L-919"><span class="linenos"> 919</span></a><span class="k">def</span> <span class="nf">isnull_to_is_null</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">List</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-920"><a href="#L-920"><span class="linenos"> 920</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">Paren</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">Is</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</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">null</span><span class="p">()))</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><span id="L-923"><a href="#L-923"><span class="linenos"> 923</span></a><span class="k">def</span> <span class="nf">generatedasidentitycolumnconstraint_sql</span><span class="p">(</span> -</span><span id="L-924"><a href="#L-924"><span class="linenos"> 924</span></a> <span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span 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-925"><a href="#L-925"><span class="linenos"> 925</span></a><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-926"><a href="#L-926"><span class="linenos"> 926</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 class="ow">or</span> <span class="s2">"1"</span> -</span><span id="L-927"><a href="#L-927"><span class="linenos"> 927</span></a> <span class="n">increment</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"increment"</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">"1"</span> -</span><span id="L-928"><a href="#L-928"><span class="linenos"> 928</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"IDENTITY(</span><span class="si">{</span><span class="n">start</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="n">increment</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="L-929"><a href="#L-929"><span class="linenos"> 929</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">generatedasidentitycolumnconstraint_sql</span><span class="p">(</span> +</span><span id="L-919"><a href="#L-919"><span class="linenos"> 919</span></a> <span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span 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-920"><a href="#L-920"><span class="linenos"> 920</span></a><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-921"><a href="#L-921"><span class="linenos"> 921</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 class="ow">or</span> <span class="s2">"1"</span> +</span><span id="L-922"><a href="#L-922"><span class="linenos"> 922</span></a> <span class="n">increment</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"increment"</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">"1"</span> +</span><span id="L-923"><a href="#L-923"><span class="linenos"> 923</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"IDENTITY(</span><span class="si">{</span><span class="n">start</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="n">increment</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="L-924"><a href="#L-924"><span class="linenos"> 924</span></a> +</span><span id="L-925"><a href="#L-925"><span class="linenos"> 925</span></a> +</span><span id="L-926"><a href="#L-926"><span class="linenos"> 926</span></a><span class="k">def</span> <span class="nf">arg_max_or_min_no_count</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="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">[[</span><span class="n">Generator</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArgMax</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArgMin</span><span class="p">],</span> <span class="nb">str</span><span class="p">]:</span> +</span><span id="L-927"><a href="#L-927"><span class="linenos"> 927</span></a> <span class="k">def</span> <span class="nf">_arg_max_or_min_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArgMax</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArgMin</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="k">if</span> <span class="n">expression</span><span 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-929"><a href="#L-929"><span class="linenos"> 929</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">"Only two arguments are supported in function </span><span class="si">{</span><span class="n">name</span><span class="si">}</span><span class="s2">."</span><span class="p">)</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">def</span> <span class="nf">arg_max_or_min_no_count</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="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">[[</span><span class="n">Generator</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArgMax</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArgMin</span><span class="p">],</span> <span class="nb">str</span><span class="p">]:</span> -</span><span id="L-932"><a href="#L-932"><span class="linenos"> 932</span></a> <span class="k">def</span> <span class="nf">_arg_max_or_min_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArgMax</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArgMin</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-933"><a href="#L-933"><span class="linenos"> 933</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">"count"</span><span class="p">):</span> -</span><span id="L-934"><a href="#L-934"><span class="linenos"> 934</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">"Only two arguments are supported in function </span><span class="si">{</span><span class="n">name</span><span class="si">}</span><span class="s2">."</span><span class="p">)</span> +</span><span id="L-931"><a href="#L-931"><span class="linenos"> 931</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="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-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">return</span> <span class="n">_arg_max_or_min_sql</span> +</span><span id="L-934"><a href="#L-934"><span class="linenos"> 934</span></a> </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">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="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-937"><a href="#L-937"><span class="linenos"> 937</span></a> -</span><span id="L-938"><a href="#L-938"><span class="linenos"> 938</span></a> <span class="k">return</span> <span class="n">_arg_max_or_min_sql</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><span id="L-941"><a href="#L-941"><span class="linenos"> 941</span></a><span class="k">def</span> <span class="nf">ts_or_ds_add_cast</span><span class="p">(</span><span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsAdd</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsAdd</span><span class="p">:</span> -</span><span id="L-942"><a href="#L-942"><span class="linenos"> 942</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">copy</span><span class="p">()</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="n">return_type</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">return_type</span> -</span><span id="L-945"><a href="#L-945"><span class="linenos"> 945</span></a> <span class="k">if</span> <span class="n">return_type</span><span class="o">.</span><span class="n">is_type</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="o">.</span><span class="n">DATE</span><span class="p">):</span> -</span><span id="L-946"><a href="#L-946"><span class="linenos"> 946</span></a> <span class="c1"># If we need to cast to a DATE, we cast to TIMESTAMP first to make sure we</span> -</span><span id="L-947"><a href="#L-947"><span class="linenos"> 947</span></a> <span class="c1"># can truncate timestamp strings, because some dialects can't cast them to DATE</span> -</span><span id="L-948"><a href="#L-948"><span class="linenos"> 948</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">this</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="o">.</span><span class="n">TIMESTAMP</span><span class="p">)</span> -</span><span id="L-949"><a href="#L-949"><span class="linenos"> 949</span></a> -</span><span id="L-950"><a href="#L-950"><span class="linenos"> 950</span></a> <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="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">this</span><span class="p">,</span> <span class="n">return_type</span><span class="p">))</span> -</span><span id="L-951"><a href="#L-951"><span class="linenos"> 951</span></a> <span class="k">return</span> <span class="n">expression</span> -</span><span id="L-952"><a href="#L-952"><span class="linenos"> 952</span></a> +</span><span id="L-936"><a href="#L-936"><span class="linenos"> 936</span></a><span class="k">def</span> <span class="nf">ts_or_ds_add_cast</span><span class="p">(</span><span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsAdd</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsAdd</span><span class="p">:</span> +</span><span id="L-937"><a href="#L-937"><span class="linenos"> 937</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">copy</span><span class="p">()</span> +</span><span id="L-938"><a href="#L-938"><span class="linenos"> 938</span></a> +</span><span id="L-939"><a href="#L-939"><span class="linenos"> 939</span></a> <span class="n">return_type</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">return_type</span> +</span><span id="L-940"><a href="#L-940"><span class="linenos"> 940</span></a> <span class="k">if</span> <span class="n">return_type</span><span class="o">.</span><span class="n">is_type</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="o">.</span><span class="n">DATE</span><span class="p">):</span> +</span><span id="L-941"><a href="#L-941"><span class="linenos"> 941</span></a> <span class="c1"># If we need to cast to a DATE, we cast to TIMESTAMP first to make sure we</span> +</span><span id="L-942"><a href="#L-942"><span class="linenos"> 942</span></a> <span class="c1"># can truncate timestamp strings, because some dialects can't cast them to DATE</span> +</span><span id="L-943"><a href="#L-943"><span class="linenos"> 943</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">this</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="o">.</span><span class="n">TIMESTAMP</span><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">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="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">this</span><span class="p">,</span> <span class="n">return_type</span><span class="p">))</span> +</span><span id="L-946"><a href="#L-946"><span class="linenos"> 946</span></a> <span class="k">return</span> <span class="n">expression</span> +</span><span id="L-947"><a href="#L-947"><span class="linenos"> 947</span></a> +</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">def</span> <span class="nf">date_delta_sql</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="n">cast</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="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">[[</span><span class="n">Generator</span><span class="p">,</span> <span class="n">DATE_ADD_OR_DIFF</span><span class="p">],</span> <span class="nb">str</span><span class="p">]:</span> +</span><span id="L-950"><a href="#L-950"><span class="linenos"> 950</span></a> <span class="k">def</span> <span class="nf">_delta_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">DATE_ADD_OR_DIFF</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-951"><a href="#L-951"><span class="linenos"> 951</span></a> <span class="k">if</span> <span class="n">cast</span> <span class="ow">and</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">TsOrDsAdd</span><span class="p">):</span> +</span><span id="L-952"><a href="#L-952"><span class="linenos"> 952</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">ts_or_ds_add_cast</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> </span><span id="L-953"><a href="#L-953"><span class="linenos"> 953</span></a> -</span><span id="L-954"><a href="#L-954"><span class="linenos"> 954</span></a><span class="k">def</span> <span class="nf">date_delta_sql</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="n">cast</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="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">[[</span><span class="n">Generator</span><span class="p">,</span> <span class="n">DATE_ADD_OR_DIFF</span><span class="p">],</span> <span class="nb">str</span><span class="p">]:</span> -</span><span id="L-955"><a href="#L-955"><span class="linenos"> 955</span></a> <span class="k">def</span> <span class="nf">_delta_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">DATE_ADD_OR_DIFF</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-956"><a href="#L-956"><span class="linenos"> 956</span></a> <span class="k">if</span> <span class="n">cast</span> <span class="ow">and</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">TsOrDsAdd</span><span class="p">):</span> -</span><span id="L-957"><a href="#L-957"><span class="linenos"> 957</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">ts_or_ds_add_cast</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="L-958"><a href="#L-958"><span class="linenos"> 958</span></a> -</span><span id="L-959"><a href="#L-959"><span class="linenos"> 959</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-960"><a href="#L-960"><span class="linenos"> 960</span></a> <span class="n">name</span><span class="p">,</span> -</span><span id="L-961"><a href="#L-961"><span class="linenos"> 961</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> <span class="ow">or</span> <span class="s2">"DAY"</span><span class="p">),</span> -</span><span id="L-962"><a href="#L-962"><span class="linenos"> 962</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> -</span><span id="L-963"><a href="#L-963"><span class="linenos"> 963</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> -</span><span id="L-964"><a href="#L-964"><span class="linenos"> 964</span></a> <span class="p">)</span> -</span><span id="L-965"><a href="#L-965"><span class="linenos"> 965</span></a> -</span><span id="L-966"><a href="#L-966"><span class="linenos"> 966</span></a> <span class="k">return</span> <span class="n">_delta_sql</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><span id="L-969"><a href="#L-969"><span class="linenos"> 969</span></a><span class="k">def</span> <span class="nf">prepend_dollar_to_path</span><span class="p">(</span><span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GetPath</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">GetPath</span><span class="p">:</span> -</span><span id="L-970"><a href="#L-970"><span class="linenos"> 970</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-971"><a href="#L-971"><span class="linenos"> 971</span></a> -</span><span id="L-972"><a href="#L-972"><span class="linenos"> 972</span></a> <span class="c1"># Makes sure the path will be evaluated correctly at runtime to include the path root.</span> -</span><span id="L-973"><a href="#L-973"><span class="linenos"> 973</span></a> <span class="c1"># For example, `[0].foo` will become `$[0].foo`, and `foo` will become `$.foo`.</span> -</span><span id="L-974"><a href="#L-974"><span class="linenos"> 974</span></a> <span class="n">path</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span> -</span><span id="L-975"><a href="#L-975"><span class="linenos"> 975</span></a> <span class="n">path</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="L-976"><a href="#L-976"><span class="linenos"> 976</span></a> <span class="s2">"if"</span><span class="p">,</span> -</span><span id="L-977"><a href="#L-977"><span class="linenos"> 977</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"startswith"</span><span class="p">,</span> <span class="n">path</span><span class="p">,</span> <span class="s2">"'['"</span><span class="p">),</span> -</span><span id="L-978"><a href="#L-978"><span class="linenos"> 978</span></a> <span class="n">exp</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="s2">"'$'"</span><span class="p">,</span> <span class="n">path</span><span class="p">),</span> -</span><span id="L-979"><a href="#L-979"><span class="linenos"> 979</span></a> <span class="n">exp</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="s2">"'$.'"</span><span class="p">,</span> <span class="n">path</span><span class="p">),</span> -</span><span id="L-980"><a href="#L-980"><span class="linenos"> 980</span></a> <span class="p">)</span> -</span><span id="L-981"><a href="#L-981"><span class="linenos"> 981</span></a> -</span><span id="L-982"><a href="#L-982"><span class="linenos"> 982</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="n">simplify</span><span class="p">(</span><span class="n">path</span><span class="p">))</span> -</span><span id="L-983"><a href="#L-983"><span class="linenos"> 983</span></a> <span class="k">return</span> <span class="n">expression</span> -</span><span id="L-984"><a href="#L-984"><span class="linenos"> 984</span></a> -</span><span id="L-985"><a href="#L-985"><span class="linenos"> 985</span></a> -</span><span id="L-986"><a href="#L-986"><span class="linenos"> 986</span></a><span class="k">def</span> <span class="nf">path_to_jsonpath</span><span class="p">(</span> -</span><span id="L-987"><a href="#L-987"><span class="linenos"> 987</span></a> <span class="n">name</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"JSON_EXTRACT"</span><span class="p">,</span> -</span><span id="L-988"><a href="#L-988"><span class="linenos"> 988</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">[[</span><span class="n">Generator</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">GetPath</span><span class="p">],</span> <span class="nb">str</span><span class="p">]:</span> -</span><span id="L-989"><a href="#L-989"><span class="linenos"> 989</span></a> <span class="k">def</span> <span class="nf">_transform</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GetPath</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-990"><a href="#L-990"><span class="linenos"> 990</span></a> <span class="k">return</span> <span class="n">rename_func</span><span class="p">(</span><span class="n">name</span><span class="p">)(</span><span class="bp">self</span><span class="p">,</span> <span class="n">prepend_dollar_to_path</span><span class="p">(</span><span class="n">expression</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">return</span> <span class="n">_transform</span> -</span><span id="L-993"><a href="#L-993"><span class="linenos"> 993</span></a> +</span><span id="L-954"><a href="#L-954"><span class="linenos"> 954</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-955"><a href="#L-955"><span class="linenos"> 955</span></a> <span class="n">name</span><span class="p">,</span> +</span><span id="L-956"><a href="#L-956"><span class="linenos"> 956</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> <span class="ow">or</span> <span class="s2">"DAY"</span><span class="p">),</span> +</span><span id="L-957"><a href="#L-957"><span class="linenos"> 957</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> +</span><span id="L-958"><a href="#L-958"><span class="linenos"> 958</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> +</span><span id="L-959"><a href="#L-959"><span class="linenos"> 959</span></a> <span class="p">)</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="k">return</span> <span class="n">_delta_sql</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><span id="L-964"><a href="#L-964"><span class="linenos"> 964</span></a><span class="k">def</span> <span class="nf">prepend_dollar_to_path</span><span class="p">(</span><span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GetPath</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">GetPath</span><span class="p">:</span> +</span><span id="L-965"><a href="#L-965"><span class="linenos"> 965</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-966"><a href="#L-966"><span class="linenos"> 966</span></a> +</span><span id="L-967"><a href="#L-967"><span class="linenos"> 967</span></a> <span class="c1"># Makes sure the path will be evaluated correctly at runtime to include the path root.</span> +</span><span id="L-968"><a href="#L-968"><span class="linenos"> 968</span></a> <span class="c1"># For example, `[0].foo` will become `$[0].foo`, and `foo` will become `$.foo`.</span> +</span><span id="L-969"><a href="#L-969"><span class="linenos"> 969</span></a> <span class="n">path</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span> +</span><span id="L-970"><a href="#L-970"><span class="linenos"> 970</span></a> <span class="n">path</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> +</span><span id="L-971"><a href="#L-971"><span class="linenos"> 971</span></a> <span class="s2">"if"</span><span class="p">,</span> +</span><span id="L-972"><a href="#L-972"><span class="linenos"> 972</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"startswith"</span><span class="p">,</span> <span class="n">path</span><span class="p">,</span> <span class="s2">"'['"</span><span class="p">),</span> +</span><span id="L-973"><a href="#L-973"><span class="linenos"> 973</span></a> <span class="n">exp</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="s2">"'$'"</span><span class="p">,</span> <span class="n">path</span><span class="p">),</span> +</span><span id="L-974"><a href="#L-974"><span class="linenos"> 974</span></a> <span class="n">exp</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="s2">"'$.'"</span><span class="p">,</span> <span class="n">path</span><span class="p">),</span> +</span><span id="L-975"><a href="#L-975"><span class="linenos"> 975</span></a> <span class="p">)</span> +</span><span id="L-976"><a href="#L-976"><span class="linenos"> 976</span></a> +</span><span id="L-977"><a href="#L-977"><span class="linenos"> 977</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="n">simplify</span><span class="p">(</span><span class="n">path</span><span class="p">))</span> +</span><span id="L-978"><a href="#L-978"><span class="linenos"> 978</span></a> <span class="k">return</span> <span class="n">expression</span> +</span><span id="L-979"><a href="#L-979"><span class="linenos"> 979</span></a> +</span><span id="L-980"><a href="#L-980"><span class="linenos"> 980</span></a> +</span><span id="L-981"><a href="#L-981"><span class="linenos"> 981</span></a><span class="k">def</span> <span class="nf">path_to_jsonpath</span><span class="p">(</span> +</span><span id="L-982"><a href="#L-982"><span class="linenos"> 982</span></a> <span class="n">name</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"JSON_EXTRACT"</span><span class="p">,</span> +</span><span id="L-983"><a href="#L-983"><span class="linenos"> 983</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">[[</span><span class="n">Generator</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">GetPath</span><span class="p">],</span> <span class="nb">str</span><span class="p">]:</span> +</span><span id="L-984"><a href="#L-984"><span class="linenos"> 984</span></a> <span class="k">def</span> <span class="nf">_transform</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GetPath</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-985"><a href="#L-985"><span class="linenos"> 985</span></a> <span class="k">return</span> <span class="n">rename_func</span><span class="p">(</span><span class="n">name</span><span class="p">)(</span><span class="bp">self</span><span class="p">,</span> <span class="n">prepend_dollar_to_path</span><span class="p">(</span><span class="n">expression</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">return</span> <span class="n">_transform</span> +</span><span id="L-988"><a href="#L-988"><span class="linenos"> 988</span></a> +</span><span id="L-989"><a href="#L-989"><span class="linenos"> 989</span></a> +</span><span id="L-990"><a href="#L-990"><span class="linenos"> 990</span></a><span class="k">def</span> <span class="nf">no_last_day_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">LastDay</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-991"><a href="#L-991"><span class="linenos"> 991</span></a> <span class="n">trunc_curr_date</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"date_trunc"</span><span class="p">,</span> <span class="s2">"month"</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-992"><a href="#L-992"><span class="linenos"> 992</span></a> <span class="n">plus_one_month</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"date_add"</span><span class="p">,</span> <span class="n">trunc_curr_date</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s2">"month"</span><span class="p">)</span> +</span><span id="L-993"><a href="#L-993"><span class="linenos"> 993</span></a> <span class="n">minus_one_day</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"date_sub"</span><span class="p">,</span> <span class="n">plus_one_month</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s2">"day"</span><span class="p">)</span> </span><span id="L-994"><a href="#L-994"><span class="linenos"> 994</span></a> -</span><span id="L-995"><a href="#L-995"><span class="linenos"> 995</span></a><span class="k">def</span> <span class="nf">no_last_day_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">LastDay</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-996"><a href="#L-996"><span class="linenos"> 996</span></a> <span class="n">trunc_curr_date</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"date_trunc"</span><span class="p">,</span> <span class="s2">"month"</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-997"><a href="#L-997"><span class="linenos"> 997</span></a> <span class="n">plus_one_month</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"date_add"</span><span class="p">,</span> <span class="n">trunc_curr_date</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s2">"month"</span><span class="p">)</span> -</span><span id="L-998"><a href="#L-998"><span class="linenos"> 998</span></a> <span class="n">minus_one_day</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"date_sub"</span><span class="p">,</span> <span class="n">plus_one_month</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s2">"day"</span><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">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">minus_one_day</span><span class="p">,</span> <span class="s2">"date"</span><span class="p">))</span> +</span><span id="L-995"><a href="#L-995"><span class="linenos"> 995</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">minus_one_day</span><span class="p">,</span> <span class="s2">"date"</span><span class="p">))</span> +</span><span id="L-996"><a href="#L-996"><span class="linenos"> 996</span></a> +</span><span id="L-997"><a href="#L-997"><span class="linenos"> 997</span></a> +</span><span id="L-998"><a href="#L-998"><span class="linenos"> 998</span></a><span class="k">def</span> <span class="nf">merge_without_target_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span 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-999"><a href="#L-999"><span class="linenos"> 999</span></a><span class="w"> </span><span class="sd">"""Remove table refs from columns in when statements."""</span> +</span><span id="L-1000"><a href="#L-1000"><span class="linenos">1000</span></a> <span class="n">alias</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">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-1001"><a href="#L-1001"><span class="linenos">1001</span></a> +</span><span id="L-1002"><a href="#L-1002"><span class="linenos">1002</span></a> <span class="n">normalize</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="L-1003"><a href="#L-1003"><span class="linenos">1003</span></a> <span class="k">lambda</span> <span class="n">identifier</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">normalize_identifier</span><span class="p">(</span><span class="n">identifier</span><span class="p">)</span><span class="o">.</span><span class="n">name</span> +</span><span id="L-1004"><a href="#L-1004"><span class="linenos">1004</span></a> <span class="k">if</span> <span class="n">identifier</span> +</span><span id="L-1005"><a href="#L-1005"><span class="linenos">1005</span></a> <span class="k">else</span> <span class="kc">None</span> +</span><span id="L-1006"><a href="#L-1006"><span class="linenos">1006</span></a> <span class="p">)</span> +</span><span id="L-1007"><a href="#L-1007"><span class="linenos">1007</span></a> +</span><span id="L-1008"><a href="#L-1008"><span class="linenos">1008</span></a> <span class="n">targets</span> <span class="o">=</span> <span class="p">{</span><span class="n">normalize</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">this</span><span class="p">)}</span> +</span><span id="L-1009"><a href="#L-1009"><span class="linenos">1009</span></a> +</span><span id="L-1010"><a href="#L-1010"><span class="linenos">1010</span></a> <span class="k">if</span> <span class="n">alias</span><span class="p">:</span> +</span><span id="L-1011"><a href="#L-1011"><span class="linenos">1011</span></a> <span class="n">targets</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">normalize</span><span class="p">(</span><span class="n">alias</span><span class="o">.</span><span class="n">this</span><span class="p">))</span> +</span><span id="L-1012"><a href="#L-1012"><span class="linenos">1012</span></a> +</span><span id="L-1013"><a href="#L-1013"><span class="linenos">1013</span></a> <span class="k">for</span> <span class="n">when</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-1014"><a href="#L-1014"><span class="linenos">1014</span></a> <span class="n">when</span><span class="o">.</span><span class="n">transform</span><span class="p">(</span> +</span><span id="L-1015"><a href="#L-1015"><span class="linenos">1015</span></a> <span class="k">lambda</span> <span class="n">node</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">column</span><span class="p">(</span><span class="n">node</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> +</span><span id="L-1016"><a href="#L-1016"><span class="linenos">1016</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">node</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">)</span> <span class="ow">and</span> <span class="n">normalize</span><span class="p">(</span><span class="n">node</span><span 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 class="ow">in</span> <span class="n">targets</span> +</span><span id="L-1017"><a href="#L-1017"><span class="linenos">1017</span></a> <span class="k">else</span> <span class="n">node</span><span class="p">,</span> +</span><span id="L-1018"><a href="#L-1018"><span class="linenos">1018</span></a> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> +</span><span id="L-1019"><a href="#L-1019"><span class="linenos">1019</span></a> <span class="p">)</span> +</span><span id="L-1020"><a href="#L-1020"><span class="linenos">1020</span></a> +</span><span id="L-1021"><a href="#L-1021"><span class="linenos">1021</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">merge_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> </span></pre></div> @@ -3732,7 +3753,7 @@ that it can analyze queries in the optimizer and successfully capture their sema <div class="pdoc-code codehilite"><pre><span></span><span id="no_safe_divide_sql-534"><a href="#no_safe_divide_sql-534"><span class="linenos">534</span></a><span class="k">def</span> <span class="nf">no_safe_divide_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SafeDivide</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> </span><span id="no_safe_divide_sql-535"><a href="#no_safe_divide_sql-535"><span class="linenos">535</span></a> <span class="n">n</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> </span><span id="no_safe_divide_sql-536"><a href="#no_safe_divide_sql-536"><span class="linenos">536</span></a> <span class="n">d</span> <span class="o">=</span> <span class="bp">self</span><span 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="no_safe_divide_sql-537"><a href="#no_safe_divide_sql-537"><span class="linenos">537</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"IF(</span><span class="si">{</span><span class="n">d</span><span class="si">}</span><span class="s2"> <> 0, </span><span class="si">{</span><span class="n">n</span><span class="si">}</span><span class="s2"> / </span><span class="si">{</span><span class="n">d</span><span class="si">}</span><span class="s2">, NULL)"</span> +</span><span id="no_safe_divide_sql-537"><a href="#no_safe_divide_sql-537"><span class="linenos">537</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"IF((</span><span class="si">{</span><span class="n">d</span><span class="si">}</span><span class="s2">) <> 0, (</span><span class="si">{</span><span class="n">n</span><span class="si">}</span><span class="s2">) / (</span><span class="si">{</span><span class="n">d</span><span class="si">}</span><span class="s2">), NULL)"</span> </span></pre></div> @@ -4711,25 +4732,6 @@ columns are removed from the create statement.</p> </section> - <section id="json_keyvalue_comma_sql"> - <input id="json_keyvalue_comma_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">json_keyvalue_comma_sql</span><span class="signature pdoc-code multiline">(<span class="param"> <span class="bp">self</span><span class="p">:</span> <span class="n"><a href="../generator.html#Generator">sqlglot.generator.Generator</a></span>,</span><span class="param"> <span class="n">expression</span><span class="p">:</span> <span class="n"><a href="../expressions.html#JSONKeyValue">sqlglot.expressions.JSONKeyValue</a></span></span><span class="return-annotation">) -> <span class="nb">str</span>:</span></span> - - <label class="view-source-button" for="json_keyvalue_comma_sql-view-source"><span>View Source</span></label> - - </div> - <a class="headerlink" href="#json_keyvalue_comma_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="json_keyvalue_comma_sql-910"><a href="#json_keyvalue_comma_sql-910"><span class="linenos">910</span></a><span class="k">def</span> <span class="nf">json_keyvalue_comma_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span 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="json_keyvalue_comma_sql-911"><a href="#json_keyvalue_comma_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="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><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> - - - - - </section> <section id="is_parse_json"> <input id="is_parse_json-view-source" class="view-source-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1"> <div class="attr function"> @@ -4741,10 +4743,10 @@ columns are removed from the create statement.</p> </div> <a class="headerlink" href="#is_parse_json"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="is_parse_json-914"><a href="#is_parse_json-914"><span class="linenos">914</span></a><span class="k">def</span> <span class="nf">is_parse_json</span><span 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="nb">bool</span><span class="p">:</span> -</span><span id="is_parse_json-915"><a href="#is_parse_json-915"><span class="linenos">915</span></a> <span class="k">return</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">ParseJSON</span><span class="p">)</span> <span class="ow">or</span> <span class="p">(</span> -</span><span id="is_parse_json-916"><a href="#is_parse_json-916"><span class="linenos">916</span></a> <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">Cast</span><span class="p">)</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="s2">"json"</span><span class="p">)</span> -</span><span id="is_parse_json-917"><a href="#is_parse_json-917"><span class="linenos">917</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="is_parse_json-909"><a href="#is_parse_json-909"><span class="linenos">909</span></a><span class="k">def</span> <span class="nf">is_parse_json</span><span 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="nb">bool</span><span class="p">:</span> +</span><span id="is_parse_json-910"><a href="#is_parse_json-910"><span class="linenos">910</span></a> <span class="k">return</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">ParseJSON</span><span class="p">)</span> <span class="ow">or</span> <span class="p">(</span> +</span><span id="is_parse_json-911"><a href="#is_parse_json-911"><span class="linenos">911</span></a> <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">Cast</span><span class="p">)</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="s2">"json"</span><span class="p">)</span> +</span><span id="is_parse_json-912"><a href="#is_parse_json-912"><span class="linenos">912</span></a> <span class="p">)</span> </span></pre></div> @@ -4762,8 +4764,8 @@ columns are removed from the create statement.</p> </div> <a class="headerlink" href="#isnull_to_is_null"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="isnull_to_is_null-920"><a href="#isnull_to_is_null-920"><span class="linenos">920</span></a><span class="k">def</span> <span class="nf">isnull_to_is_null</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">List</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="isnull_to_is_null-921"><a href="#isnull_to_is_null-921"><span class="linenos">921</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">Paren</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">Is</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</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">null</span><span class="p">()))</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="isnull_to_is_null-915"><a href="#isnull_to_is_null-915"><span class="linenos">915</span></a><span class="k">def</span> <span class="nf">isnull_to_is_null</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">List</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="isnull_to_is_null-916"><a href="#isnull_to_is_null-916"><span class="linenos">916</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">Paren</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">Is</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</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">null</span><span class="p">()))</span> </span></pre></div> @@ -4781,12 +4783,12 @@ columns are removed from the create statement.</p> </div> <a class="headerlink" href="#generatedasidentitycolumnconstraint_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="generatedasidentitycolumnconstraint_sql-924"><a href="#generatedasidentitycolumnconstraint_sql-924"><span class="linenos">924</span></a><span class="k">def</span> <span class="nf">generatedasidentitycolumnconstraint_sql</span><span class="p">(</span> -</span><span id="generatedasidentitycolumnconstraint_sql-925"><a href="#generatedasidentitycolumnconstraint_sql-925"><span class="linenos">925</span></a> <span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span 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="generatedasidentitycolumnconstraint_sql-926"><a href="#generatedasidentitycolumnconstraint_sql-926"><span class="linenos">926</span></a><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="generatedasidentitycolumnconstraint_sql-927"><a href="#generatedasidentitycolumnconstraint_sql-927"><span class="linenos">927</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 class="ow">or</span> <span class="s2">"1"</span> -</span><span id="generatedasidentitycolumnconstraint_sql-928"><a href="#generatedasidentitycolumnconstraint_sql-928"><span class="linenos">928</span></a> <span class="n">increment</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"increment"</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">"1"</span> -</span><span id="generatedasidentitycolumnconstraint_sql-929"><a href="#generatedasidentitycolumnconstraint_sql-929"><span class="linenos">929</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"IDENTITY(</span><span class="si">{</span><span class="n">start</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="n">increment</span><span class="si">}</span><span class="s2">)"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="generatedasidentitycolumnconstraint_sql-919"><a href="#generatedasidentitycolumnconstraint_sql-919"><span class="linenos">919</span></a><span class="k">def</span> <span class="nf">generatedasidentitycolumnconstraint_sql</span><span class="p">(</span> +</span><span id="generatedasidentitycolumnconstraint_sql-920"><a href="#generatedasidentitycolumnconstraint_sql-920"><span class="linenos">920</span></a> <span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span 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="generatedasidentitycolumnconstraint_sql-921"><a href="#generatedasidentitycolumnconstraint_sql-921"><span class="linenos">921</span></a><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="generatedasidentitycolumnconstraint_sql-922"><a href="#generatedasidentitycolumnconstraint_sql-922"><span class="linenos">922</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 class="ow">or</span> <span class="s2">"1"</span> +</span><span id="generatedasidentitycolumnconstraint_sql-923"><a href="#generatedasidentitycolumnconstraint_sql-923"><span class="linenos">923</span></a> <span class="n">increment</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"increment"</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">"1"</span> +</span><span id="generatedasidentitycolumnconstraint_sql-924"><a href="#generatedasidentitycolumnconstraint_sql-924"><span class="linenos">924</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"IDENTITY(</span><span class="si">{</span><span class="n">start</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="n">increment</span><span class="si">}</span><span class="s2">)"</span> </span></pre></div> @@ -4804,14 +4806,14 @@ columns are removed from the create statement.</p> </div> <a class="headerlink" href="#arg_max_or_min_no_count"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="arg_max_or_min_no_count-932"><a href="#arg_max_or_min_no_count-932"><span class="linenos">932</span></a><span class="k">def</span> <span class="nf">arg_max_or_min_no_count</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="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">[[</span><span class="n">Generator</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArgMax</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArgMin</span><span class="p">],</span> <span class="nb">str</span><span class="p">]:</span> -</span><span id="arg_max_or_min_no_count-933"><a href="#arg_max_or_min_no_count-933"><span class="linenos">933</span></a> <span class="k">def</span> <span class="nf">_arg_max_or_min_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArgMax</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArgMin</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="arg_max_or_min_no_count-934"><a href="#arg_max_or_min_no_count-934"><span class="linenos">934</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">"count"</span><span class="p">):</span> -</span><span id="arg_max_or_min_no_count-935"><a href="#arg_max_or_min_no_count-935"><span class="linenos">935</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">"Only two arguments are supported in function </span><span class="si">{</span><span class="n">name</span><span class="si">}</span><span class="s2">."</span><span class="p">)</span> -</span><span id="arg_max_or_min_no_count-936"><a href="#arg_max_or_min_no_count-936"><span class="linenos">936</span></a> -</span><span id="arg_max_or_min_no_count-937"><a href="#arg_max_or_min_no_count-937"><span class="linenos">937</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="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="arg_max_or_min_no_count-938"><a href="#arg_max_or_min_no_count-938"><span class="linenos">938</span></a> -</span><span id="arg_max_or_min_no_count-939"><a href="#arg_max_or_min_no_count-939"><span class="linenos">939</span></a> <span class="k">return</span> <span class="n">_arg_max_or_min_sql</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="arg_max_or_min_no_count-927"><a href="#arg_max_or_min_no_count-927"><span class="linenos">927</span></a><span class="k">def</span> <span class="nf">arg_max_or_min_no_count</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="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">[[</span><span class="n">Generator</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArgMax</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArgMin</span><span class="p">],</span> <span class="nb">str</span><span class="p">]:</span> +</span><span id="arg_max_or_min_no_count-928"><a href="#arg_max_or_min_no_count-928"><span class="linenos">928</span></a> <span class="k">def</span> <span class="nf">_arg_max_or_min_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArgMax</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArgMin</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="arg_max_or_min_no_count-929"><a href="#arg_max_or_min_no_count-929"><span class="linenos">929</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">"count"</span><span class="p">):</span> +</span><span id="arg_max_or_min_no_count-930"><a href="#arg_max_or_min_no_count-930"><span class="linenos">930</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">"Only two arguments are supported in function </span><span class="si">{</span><span class="n">name</span><span class="si">}</span><span class="s2">."</span><span class="p">)</span> +</span><span id="arg_max_or_min_no_count-931"><a href="#arg_max_or_min_no_count-931"><span class="linenos">931</span></a> +</span><span id="arg_max_or_min_no_count-932"><a href="#arg_max_or_min_no_count-932"><span class="linenos">932</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="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="arg_max_or_min_no_count-933"><a href="#arg_max_or_min_no_count-933"><span class="linenos">933</span></a> +</span><span id="arg_max_or_min_no_count-934"><a href="#arg_max_or_min_no_count-934"><span class="linenos">934</span></a> <span class="k">return</span> <span class="n">_arg_max_or_min_sql</span> </span></pre></div> @@ -4829,17 +4831,17 @@ columns are removed from the create statement.</p> </div> <a class="headerlink" href="#ts_or_ds_add_cast"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="ts_or_ds_add_cast-942"><a href="#ts_or_ds_add_cast-942"><span class="linenos">942</span></a><span class="k">def</span> <span class="nf">ts_or_ds_add_cast</span><span class="p">(</span><span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsAdd</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsAdd</span><span class="p">:</span> -</span><span id="ts_or_ds_add_cast-943"><a href="#ts_or_ds_add_cast-943"><span class="linenos">943</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">copy</span><span class="p">()</span> -</span><span id="ts_or_ds_add_cast-944"><a href="#ts_or_ds_add_cast-944"><span class="linenos">944</span></a> -</span><span id="ts_or_ds_add_cast-945"><a href="#ts_or_ds_add_cast-945"><span class="linenos">945</span></a> <span class="n">return_type</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">return_type</span> -</span><span id="ts_or_ds_add_cast-946"><a href="#ts_or_ds_add_cast-946"><span class="linenos">946</span></a> <span class="k">if</span> <span class="n">return_type</span><span class="o">.</span><span class="n">is_type</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="o">.</span><span class="n">DATE</span><span class="p">):</span> -</span><span id="ts_or_ds_add_cast-947"><a href="#ts_or_ds_add_cast-947"><span class="linenos">947</span></a> <span class="c1"># If we need to cast to a DATE, we cast to TIMESTAMP first to make sure we</span> -</span><span id="ts_or_ds_add_cast-948"><a href="#ts_or_ds_add_cast-948"><span class="linenos">948</span></a> <span class="c1"># can truncate timestamp strings, because some dialects can't cast them to DATE</span> -</span><span id="ts_or_ds_add_cast-949"><a href="#ts_or_ds_add_cast-949"><span class="linenos">949</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">this</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="o">.</span><span class="n">TIMESTAMP</span><span class="p">)</span> -</span><span id="ts_or_ds_add_cast-950"><a href="#ts_or_ds_add_cast-950"><span class="linenos">950</span></a> -</span><span id="ts_or_ds_add_cast-951"><a href="#ts_or_ds_add_cast-951"><span class="linenos">951</span></a> <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="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">this</span><span class="p">,</span> <span class="n">return_type</span><span class="p">))</span> -</span><span id="ts_or_ds_add_cast-952"><a href="#ts_or_ds_add_cast-952"><span class="linenos">952</span></a> <span class="k">return</span> <span class="n">expression</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="ts_or_ds_add_cast-937"><a href="#ts_or_ds_add_cast-937"><span class="linenos">937</span></a><span class="k">def</span> <span class="nf">ts_or_ds_add_cast</span><span class="p">(</span><span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsAdd</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsAdd</span><span class="p">:</span> +</span><span id="ts_or_ds_add_cast-938"><a href="#ts_or_ds_add_cast-938"><span class="linenos">938</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">copy</span><span class="p">()</span> +</span><span id="ts_or_ds_add_cast-939"><a href="#ts_or_ds_add_cast-939"><span class="linenos">939</span></a> +</span><span id="ts_or_ds_add_cast-940"><a href="#ts_or_ds_add_cast-940"><span class="linenos">940</span></a> <span class="n">return_type</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">return_type</span> +</span><span id="ts_or_ds_add_cast-941"><a href="#ts_or_ds_add_cast-941"><span class="linenos">941</span></a> <span class="k">if</span> <span class="n">return_type</span><span class="o">.</span><span class="n">is_type</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="o">.</span><span class="n">DATE</span><span class="p">):</span> +</span><span id="ts_or_ds_add_cast-942"><a href="#ts_or_ds_add_cast-942"><span class="linenos">942</span></a> <span class="c1"># If we need to cast to a DATE, we cast to TIMESTAMP first to make sure we</span> +</span><span id="ts_or_ds_add_cast-943"><a href="#ts_or_ds_add_cast-943"><span class="linenos">943</span></a> <span class="c1"># can truncate timestamp strings, because some dialects can't cast them to DATE</span> +</span><span id="ts_or_ds_add_cast-944"><a href="#ts_or_ds_add_cast-944"><span class="linenos">944</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">this</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="o">.</span><span class="n">TIMESTAMP</span><span class="p">)</span> +</span><span id="ts_or_ds_add_cast-945"><a href="#ts_or_ds_add_cast-945"><span class="linenos">945</span></a> +</span><span id="ts_or_ds_add_cast-946"><a href="#ts_or_ds_add_cast-946"><span class="linenos">946</span></a> <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="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">this</span><span class="p">,</span> <span class="n">return_type</span><span class="p">))</span> +</span><span id="ts_or_ds_add_cast-947"><a href="#ts_or_ds_add_cast-947"><span class="linenos">947</span></a> <span class="k">return</span> <span class="n">expression</span> </span></pre></div> @@ -4857,19 +4859,19 @@ columns are removed from the create statement.</p> </div> <a class="headerlink" href="#date_delta_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="date_delta_sql-955"><a href="#date_delta_sql-955"><span class="linenos">955</span></a><span class="k">def</span> <span class="nf">date_delta_sql</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="n">cast</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="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">[[</span><span class="n">Generator</span><span class="p">,</span> <span class="n">DATE_ADD_OR_DIFF</span><span class="p">],</span> <span class="nb">str</span><span class="p">]:</span> -</span><span id="date_delta_sql-956"><a href="#date_delta_sql-956"><span class="linenos">956</span></a> <span class="k">def</span> <span class="nf">_delta_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">DATE_ADD_OR_DIFF</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="date_delta_sql-957"><a href="#date_delta_sql-957"><span class="linenos">957</span></a> <span class="k">if</span> <span class="n">cast</span> <span class="ow">and</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">TsOrDsAdd</span><span class="p">):</span> -</span><span id="date_delta_sql-958"><a href="#date_delta_sql-958"><span class="linenos">958</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">ts_or_ds_add_cast</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="date_delta_sql-959"><a href="#date_delta_sql-959"><span class="linenos">959</span></a> -</span><span id="date_delta_sql-960"><a href="#date_delta_sql-960"><span class="linenos">960</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="date_delta_sql-961"><a href="#date_delta_sql-961"><span class="linenos">961</span></a> <span class="n">name</span><span class="p">,</span> -</span><span id="date_delta_sql-962"><a href="#date_delta_sql-962"><span class="linenos">962</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> <span class="ow">or</span> <span class="s2">"DAY"</span><span class="p">),</span> -</span><span id="date_delta_sql-963"><a href="#date_delta_sql-963"><span class="linenos">963</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> -</span><span id="date_delta_sql-964"><a href="#date_delta_sql-964"><span class="linenos">964</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> -</span><span id="date_delta_sql-965"><a href="#date_delta_sql-965"><span class="linenos">965</span></a> <span class="p">)</span> -</span><span id="date_delta_sql-966"><a href="#date_delta_sql-966"><span class="linenos">966</span></a> -</span><span id="date_delta_sql-967"><a href="#date_delta_sql-967"><span class="linenos">967</span></a> <span class="k">return</span> <span class="n">_delta_sql</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="date_delta_sql-950"><a href="#date_delta_sql-950"><span class="linenos">950</span></a><span class="k">def</span> <span class="nf">date_delta_sql</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="n">cast</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="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">[[</span><span class="n">Generator</span><span class="p">,</span> <span class="n">DATE_ADD_OR_DIFF</span><span class="p">],</span> <span class="nb">str</span><span class="p">]:</span> +</span><span id="date_delta_sql-951"><a href="#date_delta_sql-951"><span class="linenos">951</span></a> <span class="k">def</span> <span class="nf">_delta_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">DATE_ADD_OR_DIFF</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="date_delta_sql-952"><a href="#date_delta_sql-952"><span class="linenos">952</span></a> <span class="k">if</span> <span class="n">cast</span> <span class="ow">and</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">TsOrDsAdd</span><span class="p">):</span> +</span><span id="date_delta_sql-953"><a href="#date_delta_sql-953"><span class="linenos">953</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">ts_or_ds_add_cast</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="date_delta_sql-954"><a href="#date_delta_sql-954"><span class="linenos">954</span></a> +</span><span id="date_delta_sql-955"><a href="#date_delta_sql-955"><span class="linenos">955</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="date_delta_sql-956"><a href="#date_delta_sql-956"><span class="linenos">956</span></a> <span class="n">name</span><span class="p">,</span> +</span><span id="date_delta_sql-957"><a href="#date_delta_sql-957"><span class="linenos">957</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> <span class="ow">or</span> <span class="s2">"DAY"</span><span class="p">),</span> +</span><span id="date_delta_sql-958"><a href="#date_delta_sql-958"><span class="linenos">958</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> +</span><span id="date_delta_sql-959"><a href="#date_delta_sql-959"><span class="linenos">959</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> +</span><span id="date_delta_sql-960"><a href="#date_delta_sql-960"><span class="linenos">960</span></a> <span class="p">)</span> +</span><span id="date_delta_sql-961"><a href="#date_delta_sql-961"><span class="linenos">961</span></a> +</span><span id="date_delta_sql-962"><a href="#date_delta_sql-962"><span class="linenos">962</span></a> <span class="k">return</span> <span class="n">_delta_sql</span> </span></pre></div> @@ -4887,21 +4889,21 @@ columns are removed from the create statement.</p> </div> <a class="headerlink" href="#prepend_dollar_to_path"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="prepend_dollar_to_path-970"><a href="#prepend_dollar_to_path-970"><span class="linenos">970</span></a><span class="k">def</span> <span class="nf">prepend_dollar_to_path</span><span class="p">(</span><span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GetPath</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">GetPath</span><span class="p">:</span> -</span><span id="prepend_dollar_to_path-971"><a href="#prepend_dollar_to_path-971"><span class="linenos">971</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="prepend_dollar_to_path-972"><a href="#prepend_dollar_to_path-972"><span class="linenos">972</span></a> -</span><span id="prepend_dollar_to_path-973"><a href="#prepend_dollar_to_path-973"><span class="linenos">973</span></a> <span class="c1"># Makes sure the path will be evaluated correctly at runtime to include the path root.</span> -</span><span id="prepend_dollar_to_path-974"><a href="#prepend_dollar_to_path-974"><span class="linenos">974</span></a> <span class="c1"># For example, `[0].foo` will become `$[0].foo`, and `foo` will become `$.foo`.</span> -</span><span id="prepend_dollar_to_path-975"><a href="#prepend_dollar_to_path-975"><span class="linenos">975</span></a> <span class="n">path</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span> -</span><span id="prepend_dollar_to_path-976"><a href="#prepend_dollar_to_path-976"><span class="linenos">976</span></a> <span class="n">path</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="prepend_dollar_to_path-977"><a href="#prepend_dollar_to_path-977"><span class="linenos">977</span></a> <span class="s2">"if"</span><span class="p">,</span> -</span><span id="prepend_dollar_to_path-978"><a href="#prepend_dollar_to_path-978"><span class="linenos">978</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"startswith"</span><span class="p">,</span> <span class="n">path</span><span class="p">,</span> <span class="s2">"'['"</span><span class="p">),</span> -</span><span id="prepend_dollar_to_path-979"><a href="#prepend_dollar_to_path-979"><span class="linenos">979</span></a> <span class="n">exp</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="s2">"'$'"</span><span class="p">,</span> <span class="n">path</span><span class="p">),</span> -</span><span id="prepend_dollar_to_path-980"><a href="#prepend_dollar_to_path-980"><span class="linenos">980</span></a> <span class="n">exp</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="s2">"'$.'"</span><span class="p">,</span> <span class="n">path</span><span class="p">),</span> -</span><span id="prepend_dollar_to_path-981"><a href="#prepend_dollar_to_path-981"><span class="linenos">981</span></a> <span class="p">)</span> -</span><span id="prepend_dollar_to_path-982"><a href="#prepend_dollar_to_path-982"><span class="linenos">982</span></a> -</span><span id="prepend_dollar_to_path-983"><a href="#prepend_dollar_to_path-983"><span class="linenos">983</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="n">simplify</span><span class="p">(</span><span class="n">path</span><span class="p">))</span> -</span><span id="prepend_dollar_to_path-984"><a href="#prepend_dollar_to_path-984"><span class="linenos">984</span></a> <span class="k">return</span> <span class="n">expression</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="prepend_dollar_to_path-965"><a href="#prepend_dollar_to_path-965"><span class="linenos">965</span></a><span class="k">def</span> <span class="nf">prepend_dollar_to_path</span><span class="p">(</span><span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GetPath</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">GetPath</span><span class="p">:</span> +</span><span id="prepend_dollar_to_path-966"><a href="#prepend_dollar_to_path-966"><span class="linenos">966</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="prepend_dollar_to_path-967"><a href="#prepend_dollar_to_path-967"><span class="linenos">967</span></a> +</span><span id="prepend_dollar_to_path-968"><a href="#prepend_dollar_to_path-968"><span class="linenos">968</span></a> <span class="c1"># Makes sure the path will be evaluated correctly at runtime to include the path root.</span> +</span><span id="prepend_dollar_to_path-969"><a href="#prepend_dollar_to_path-969"><span class="linenos">969</span></a> <span class="c1"># For example, `[0].foo` will become `$[0].foo`, and `foo` will become `$.foo`.</span> +</span><span id="prepend_dollar_to_path-970"><a href="#prepend_dollar_to_path-970"><span class="linenos">970</span></a> <span class="n">path</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span> +</span><span id="prepend_dollar_to_path-971"><a href="#prepend_dollar_to_path-971"><span class="linenos">971</span></a> <span class="n">path</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> +</span><span id="prepend_dollar_to_path-972"><a href="#prepend_dollar_to_path-972"><span class="linenos">972</span></a> <span class="s2">"if"</span><span class="p">,</span> +</span><span id="prepend_dollar_to_path-973"><a href="#prepend_dollar_to_path-973"><span class="linenos">973</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"startswith"</span><span class="p">,</span> <span class="n">path</span><span class="p">,</span> <span class="s2">"'['"</span><span class="p">),</span> +</span><span id="prepend_dollar_to_path-974"><a href="#prepend_dollar_to_path-974"><span class="linenos">974</span></a> <span class="n">exp</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="s2">"'$'"</span><span class="p">,</span> <span class="n">path</span><span class="p">),</span> +</span><span id="prepend_dollar_to_path-975"><a href="#prepend_dollar_to_path-975"><span class="linenos">975</span></a> <span class="n">exp</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="s2">"'$.'"</span><span class="p">,</span> <span class="n">path</span><span class="p">),</span> +</span><span id="prepend_dollar_to_path-976"><a href="#prepend_dollar_to_path-976"><span class="linenos">976</span></a> <span class="p">)</span> +</span><span id="prepend_dollar_to_path-977"><a href="#prepend_dollar_to_path-977"><span class="linenos">977</span></a> +</span><span id="prepend_dollar_to_path-978"><a href="#prepend_dollar_to_path-978"><span class="linenos">978</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="n">simplify</span><span class="p">(</span><span class="n">path</span><span class="p">))</span> +</span><span id="prepend_dollar_to_path-979"><a href="#prepend_dollar_to_path-979"><span class="linenos">979</span></a> <span class="k">return</span> <span class="n">expression</span> </span></pre></div> @@ -4919,13 +4921,13 @@ columns are removed from the create statement.</p> </div> <a class="headerlink" href="#path_to_jsonpath"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="path_to_jsonpath-987"><a href="#path_to_jsonpath-987"><span class="linenos">987</span></a><span class="k">def</span> <span class="nf">path_to_jsonpath</span><span class="p">(</span> -</span><span id="path_to_jsonpath-988"><a href="#path_to_jsonpath-988"><span class="linenos">988</span></a> <span class="n">name</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"JSON_EXTRACT"</span><span class="p">,</span> -</span><span id="path_to_jsonpath-989"><a href="#path_to_jsonpath-989"><span class="linenos">989</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">[[</span><span class="n">Generator</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">GetPath</span><span class="p">],</span> <span class="nb">str</span><span class="p">]:</span> -</span><span id="path_to_jsonpath-990"><a href="#path_to_jsonpath-990"><span class="linenos">990</span></a> <span class="k">def</span> <span class="nf">_transform</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GetPath</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="path_to_jsonpath-991"><a href="#path_to_jsonpath-991"><span class="linenos">991</span></a> <span class="k">return</span> <span class="n">rename_func</span><span class="p">(</span><span class="n">name</span><span class="p">)(</span><span class="bp">self</span><span class="p">,</span> <span class="n">prepend_dollar_to_path</span><span class="p">(</span><span class="n">expression</span><span class="p">))</span> -</span><span id="path_to_jsonpath-992"><a href="#path_to_jsonpath-992"><span class="linenos">992</span></a> -</span><span id="path_to_jsonpath-993"><a href="#path_to_jsonpath-993"><span class="linenos">993</span></a> <span class="k">return</span> <span class="n">_transform</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="path_to_jsonpath-982"><a href="#path_to_jsonpath-982"><span class="linenos">982</span></a><span class="k">def</span> <span class="nf">path_to_jsonpath</span><span class="p">(</span> +</span><span id="path_to_jsonpath-983"><a href="#path_to_jsonpath-983"><span class="linenos">983</span></a> <span class="n">name</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"JSON_EXTRACT"</span><span class="p">,</span> +</span><span id="path_to_jsonpath-984"><a href="#path_to_jsonpath-984"><span class="linenos">984</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">[[</span><span class="n">Generator</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">GetPath</span><span class="p">],</span> <span class="nb">str</span><span class="p">]:</span> +</span><span id="path_to_jsonpath-985"><a href="#path_to_jsonpath-985"><span class="linenos">985</span></a> <span class="k">def</span> <span class="nf">_transform</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GetPath</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="path_to_jsonpath-986"><a href="#path_to_jsonpath-986"><span class="linenos">986</span></a> <span class="k">return</span> <span class="n">rename_func</span><span class="p">(</span><span class="n">name</span><span class="p">)(</span><span class="bp">self</span><span class="p">,</span> <span class="n">prepend_dollar_to_path</span><span class="p">(</span><span class="n">expression</span><span class="p">))</span> +</span><span id="path_to_jsonpath-987"><a href="#path_to_jsonpath-987"><span class="linenos">987</span></a> +</span><span id="path_to_jsonpath-988"><a href="#path_to_jsonpath-988"><span class="linenos">988</span></a> <span class="k">return</span> <span class="n">_transform</span> </span></pre></div> @@ -4943,18 +4945,61 @@ columns are removed from the create statement.</p> </div> <a class="headerlink" href="#no_last_day_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="no_last_day_sql-996"><a href="#no_last_day_sql-996"><span class="linenos"> 996</span></a><span class="k">def</span> <span class="nf">no_last_day_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">LastDay</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="no_last_day_sql-997"><a href="#no_last_day_sql-997"><span class="linenos"> 997</span></a> <span class="n">trunc_curr_date</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"date_trunc"</span><span class="p">,</span> <span class="s2">"month"</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="no_last_day_sql-998"><a href="#no_last_day_sql-998"><span class="linenos"> 998</span></a> <span class="n">plus_one_month</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"date_add"</span><span class="p">,</span> <span class="n">trunc_curr_date</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s2">"month"</span><span class="p">)</span> -</span><span id="no_last_day_sql-999"><a href="#no_last_day_sql-999"><span class="linenos"> 999</span></a> <span class="n">minus_one_day</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"date_sub"</span><span class="p">,</span> <span class="n">plus_one_month</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s2">"day"</span><span class="p">)</span> -</span><span id="no_last_day_sql-1000"><a href="#no_last_day_sql-1000"><span class="linenos">1000</span></a> -</span><span id="no_last_day_sql-1001"><a href="#no_last_day_sql-1001"><span class="linenos">1001</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">minus_one_day</span><span class="p">,</span> <span class="s2">"date"</span><span class="p">))</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="no_last_day_sql-991"><a href="#no_last_day_sql-991"><span class="linenos">991</span></a><span class="k">def</span> <span class="nf">no_last_day_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">LastDay</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="no_last_day_sql-992"><a href="#no_last_day_sql-992"><span class="linenos">992</span></a> <span class="n">trunc_curr_date</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"date_trunc"</span><span class="p">,</span> <span class="s2">"month"</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="no_last_day_sql-993"><a href="#no_last_day_sql-993"><span class="linenos">993</span></a> <span class="n">plus_one_month</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"date_add"</span><span class="p">,</span> <span class="n">trunc_curr_date</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s2">"month"</span><span class="p">)</span> +</span><span id="no_last_day_sql-994"><a href="#no_last_day_sql-994"><span class="linenos">994</span></a> <span class="n">minus_one_day</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"date_sub"</span><span class="p">,</span> <span class="n">plus_one_month</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s2">"day"</span><span class="p">)</span> +</span><span id="no_last_day_sql-995"><a href="#no_last_day_sql-995"><span class="linenos">995</span></a> +</span><span id="no_last_day_sql-996"><a href="#no_last_day_sql-996"><span class="linenos">996</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">minus_one_day</span><span class="p">,</span> <span class="s2">"date"</span><span class="p">))</span> </span></pre></div> </section> + <section id="merge_without_target_sql"> + <input id="merge_without_target_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">merge_without_target_sql</span><span class="signature pdoc-code multiline">(<span class="param"> <span class="bp">self</span><span class="p">:</span> <span class="n"><a href="../generator.html#Generator">sqlglot.generator.Generator</a></span>,</span><span class="param"> <span class="n">expression</span><span class="p">:</span> <span class="n"><a href="../expressions.html#Merge">sqlglot.expressions.Merge</a></span></span><span class="return-annotation">) -> <span class="nb">str</span>:</span></span> + + <label class="view-source-button" for="merge_without_target_sql-view-source"><span>View Source</span></label> + + </div> + <a class="headerlink" href="#merge_without_target_sql"></a> + <div class="pdoc-code codehilite"><pre><span></span><span id="merge_without_target_sql-999"><a href="#merge_without_target_sql-999"><span class="linenos"> 999</span></a><span class="k">def</span> <span class="nf">merge_without_target_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span 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="merge_without_target_sql-1000"><a href="#merge_without_target_sql-1000"><span class="linenos">1000</span></a><span class="w"> </span><span class="sd">"""Remove table refs from columns in when statements."""</span> +</span><span id="merge_without_target_sql-1001"><a href="#merge_without_target_sql-1001"><span class="linenos">1001</span></a> <span class="n">alias</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">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="merge_without_target_sql-1002"><a href="#merge_without_target_sql-1002"><span class="linenos">1002</span></a> +</span><span id="merge_without_target_sql-1003"><a href="#merge_without_target_sql-1003"><span class="linenos">1003</span></a> <span class="n">normalize</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="merge_without_target_sql-1004"><a href="#merge_without_target_sql-1004"><span class="linenos">1004</span></a> <span class="k">lambda</span> <span class="n">identifier</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">normalize_identifier</span><span class="p">(</span><span class="n">identifier</span><span class="p">)</span><span class="o">.</span><span class="n">name</span> +</span><span id="merge_without_target_sql-1005"><a href="#merge_without_target_sql-1005"><span class="linenos">1005</span></a> <span class="k">if</span> <span class="n">identifier</span> +</span><span id="merge_without_target_sql-1006"><a href="#merge_without_target_sql-1006"><span class="linenos">1006</span></a> <span class="k">else</span> <span class="kc">None</span> +</span><span id="merge_without_target_sql-1007"><a href="#merge_without_target_sql-1007"><span class="linenos">1007</span></a> <span class="p">)</span> +</span><span id="merge_without_target_sql-1008"><a href="#merge_without_target_sql-1008"><span class="linenos">1008</span></a> +</span><span id="merge_without_target_sql-1009"><a href="#merge_without_target_sql-1009"><span class="linenos">1009</span></a> <span class="n">targets</span> <span class="o">=</span> <span class="p">{</span><span class="n">normalize</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">this</span><span class="p">)}</span> +</span><span id="merge_without_target_sql-1010"><a href="#merge_without_target_sql-1010"><span class="linenos">1010</span></a> +</span><span id="merge_without_target_sql-1011"><a href="#merge_without_target_sql-1011"><span class="linenos">1011</span></a> <span class="k">if</span> <span class="n">alias</span><span class="p">:</span> +</span><span id="merge_without_target_sql-1012"><a href="#merge_without_target_sql-1012"><span class="linenos">1012</span></a> <span class="n">targets</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">normalize</span><span class="p">(</span><span class="n">alias</span><span class="o">.</span><span class="n">this</span><span class="p">))</span> +</span><span id="merge_without_target_sql-1013"><a href="#merge_without_target_sql-1013"><span class="linenos">1013</span></a> +</span><span id="merge_without_target_sql-1014"><a href="#merge_without_target_sql-1014"><span class="linenos">1014</span></a> <span class="k">for</span> <span class="n">when</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="merge_without_target_sql-1015"><a href="#merge_without_target_sql-1015"><span class="linenos">1015</span></a> <span class="n">when</span><span class="o">.</span><span class="n">transform</span><span class="p">(</span> +</span><span id="merge_without_target_sql-1016"><a href="#merge_without_target_sql-1016"><span class="linenos">1016</span></a> <span class="k">lambda</span> <span class="n">node</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">column</span><span class="p">(</span><span class="n">node</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> +</span><span id="merge_without_target_sql-1017"><a href="#merge_without_target_sql-1017"><span class="linenos">1017</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">node</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">)</span> <span class="ow">and</span> <span class="n">normalize</span><span class="p">(</span><span class="n">node</span><span 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 class="ow">in</span> <span class="n">targets</span> +</span><span id="merge_without_target_sql-1018"><a href="#merge_without_target_sql-1018"><span class="linenos">1018</span></a> <span class="k">else</span> <span class="n">node</span><span class="p">,</span> +</span><span id="merge_without_target_sql-1019"><a href="#merge_without_target_sql-1019"><span class="linenos">1019</span></a> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> +</span><span id="merge_without_target_sql-1020"><a href="#merge_without_target_sql-1020"><span class="linenos">1020</span></a> <span class="p">)</span> +</span><span id="merge_without_target_sql-1021"><a href="#merge_without_target_sql-1021"><span class="linenos">1021</span></a> +</span><span id="merge_without_target_sql-1022"><a href="#merge_without_target_sql-1022"><span class="linenos">1022</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">merge_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span></pre></div> + + + <div class="docstring"><p>Remove table refs from columns in when statements.</p> +</div> + + + </section> </main> <script> function escapeHTML(html) { |