diff options
Diffstat (limited to 'docs/sqlglot/dialects/duckdb.html')
-rw-r--r-- | docs/sqlglot/dialects/duckdb.html | 1313 |
1 files changed, 789 insertions, 524 deletions
diff --git a/docs/sqlglot/dialects/duckdb.html b/docs/sqlglot/dialects/duckdb.html index 6b95f91..9a92403 100644 --- a/docs/sqlglot/dialects/duckdb.html +++ b/docs/sqlglot/dialects/duckdb.html @@ -190,6 +190,9 @@ <a class="variable" href="#DuckDB.Generator.TYPE_MAPPING">TYPE_MAPPING</a> </li> <li> + <a class="variable" href="#DuckDB.Generator.RESERVED_KEYWORDS">RESERVED_KEYWORDS</a> + </li> + <li> <a class="variable" href="#DuckDB.Generator.UNWRAPPED_INTERVAL_VALUES">UNWRAPPED_INTERVAL_VALUES</a> </li> <li> @@ -663,7 +666,7 @@ </span><span id="L-341"><a href="#L-341"><span class="linenos">341</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">L_BRACE</span><span class="p">,</span> <span class="n">advance</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span> </span><span id="L-342"><a href="#L-342"><span class="linenos">342</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">ToMap</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_bracket</span><span class="p">())</span> </span><span id="L-343"><a href="#L-343"><span class="linenos">343</span></a> -</span><span id="L-344"><a href="#L-344"><span class="linenos">344</span></a> <span class="n">args</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_wrapped_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">)</span> +</span><span id="L-344"><a href="#L-344"><span class="linenos">344</span></a> <span class="n">args</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_wrapped_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_assignment</span><span class="p">)</span> </span><span id="L-345"><a href="#L-345"><span class="linenos">345</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Map</span><span class="p">,</span> <span class="n">keys</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">values</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">1</span><span class="p">))</span> </span><span id="L-346"><a href="#L-346"><span class="linenos">346</span></a> </span><span id="L-347"><a href="#L-347"><span class="linenos">347</span></a> <span class="k">def</span> <span class="nf">_parse_struct_types</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">type_required</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">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]:</span> @@ -825,145 +828,227 @@ </span><span id="L-503"><a href="#L-503"><span class="linenos">503</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">VARBINARY</span><span class="p">:</span> <span class="s2">"BLOB"</span><span class="p">,</span> </span><span id="L-504"><a href="#L-504"><span class="linenos">504</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">ROWVERSION</span><span class="p">:</span> <span class="s2">"BLOB"</span><span class="p">,</span> </span><span id="L-505"><a href="#L-505"><span class="linenos">505</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">VARCHAR</span><span class="p">:</span> <span class="s2">"TEXT"</span><span class="p">,</span> -</span><span id="L-506"><a href="#L-506"><span class="linenos">506</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMP_S</span><span class="p">:</span> <span class="s2">"TIMESTAMP_S"</span><span class="p">,</span> -</span><span id="L-507"><a href="#L-507"><span class="linenos">507</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMP_MS</span><span class="p">:</span> <span class="s2">"TIMESTAMP_MS"</span><span class="p">,</span> -</span><span id="L-508"><a href="#L-508"><span class="linenos">508</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMP_NS</span><span class="p">:</span> <span class="s2">"TIMESTAMP_NS"</span><span class="p">,</span> -</span><span id="L-509"><a href="#L-509"><span class="linenos">509</span></a> <span class="p">}</span> -</span><span id="L-510"><a href="#L-510"><span class="linenos">510</span></a> -</span><span id="L-511"><a href="#L-511"><span class="linenos">511</span></a> <span class="n">UNWRAPPED_INTERVAL_VALUES</span> <span class="o">=</span> <span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Paren</span><span class="p">)</span> -</span><span id="L-512"><a href="#L-512"><span class="linenos">512</span></a> -</span><span id="L-513"><a href="#L-513"><span class="linenos">513</span></a> <span class="c1"># DuckDB doesn't generally support CREATE TABLE .. properties</span> -</span><span id="L-514"><a href="#L-514"><span class="linenos">514</span></a> <span class="c1"># https://duckdb.org/docs/sql/statements/create_table.html</span> -</span><span id="L-515"><a href="#L-515"><span class="linenos">515</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-516"><a href="#L-516"><span class="linenos">516</span></a> <span class="n">prop</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span> -</span><span id="L-517"><a href="#L-517"><span class="linenos">517</span></a> <span class="k">for</span> <span class="n">prop</span> <span class="ow">in</span> <span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">PROPERTIES_LOCATION</span> -</span><span id="L-518"><a href="#L-518"><span class="linenos">518</span></a> <span class="p">}</span> -</span><span id="L-519"><a href="#L-519"><span class="linenos">519</span></a> -</span><span id="L-520"><a href="#L-520"><span class="linenos">520</span></a> <span class="c1"># There are a few exceptions (e.g. temporary tables) which are supported or</span> -</span><span id="L-521"><a href="#L-521"><span class="linenos">521</span></a> <span class="c1"># can be transpiled to DuckDB, so we explicitly override them accordingly</span> -</span><span id="L-522"><a href="#L-522"><span class="linenos">522</span></a> <span class="n">PROPERTIES_LOCATION</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">LikeProperty</span><span class="p">]</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span> -</span><span id="L-523"><a href="#L-523"><span class="linenos">523</span></a> <span class="n">PROPERTIES_LOCATION</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">TemporaryProperty</span><span class="p">]</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span> -</span><span id="L-524"><a href="#L-524"><span class="linenos">524</span></a> -</span><span id="L-525"><a href="#L-525"><span class="linenos">525</span></a> <span class="k">def</span> <span class="nf">timefromparts_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TimeFromParts</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-526"><a href="#L-526"><span class="linenos">526</span></a> <span class="n">nano</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"nano"</span><span class="p">)</span> -</span><span id="L-527"><a href="#L-527"><span class="linenos">527</span></a> <span class="k">if</span> <span class="n">nano</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="L-528"><a href="#L-528"><span class="linenos">528</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> -</span><span id="L-529"><a href="#L-529"><span class="linenos">529</span></a> <span class="s2">"sec"</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"sec"</span><span class="p">]</span> <span class="o">+</span> <span class="n">nano</span><span class="o">.</span><span class="n">pop</span><span class="p">()</span> <span class="o">/</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">number</span><span class="p">(</span><span class="mf">1000000000.0</span><span class="p">)</span> -</span><span id="L-530"><a href="#L-530"><span class="linenos">530</span></a> <span class="p">)</span> -</span><span id="L-531"><a href="#L-531"><span class="linenos">531</span></a> -</span><span id="L-532"><a href="#L-532"><span class="linenos">532</span></a> <span class="k">return</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"MAKE_TIME"</span><span class="p">)(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> -</span><span id="L-533"><a href="#L-533"><span class="linenos">533</span></a> -</span><span id="L-534"><a href="#L-534"><span class="linenos">534</span></a> <span class="k">def</span> <span class="nf">timestampfromparts_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TimestampFromParts</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-535"><a href="#L-535"><span class="linenos">535</span></a> <span class="n">sec</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"sec"</span><span class="p">]</span> -</span><span id="L-536"><a href="#L-536"><span class="linenos">536</span></a> -</span><span id="L-537"><a href="#L-537"><span class="linenos">537</span></a> <span class="n">milli</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"milli"</span><span class="p">)</span> -</span><span id="L-538"><a href="#L-538"><span class="linenos">538</span></a> <span class="k">if</span> <span class="n">milli</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="L-539"><a href="#L-539"><span class="linenos">539</span></a> <span class="n">sec</span> <span class="o">+=</span> <span class="n">milli</span><span class="o">.</span><span class="n">pop</span><span class="p">()</span> <span class="o">/</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">number</span><span class="p">(</span><span class="mf">1000.0</span><span class="p">)</span> -</span><span id="L-540"><a href="#L-540"><span class="linenos">540</span></a> -</span><span id="L-541"><a href="#L-541"><span class="linenos">541</span></a> <span class="n">nano</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"nano"</span><span class="p">)</span> -</span><span id="L-542"><a href="#L-542"><span class="linenos">542</span></a> <span class="k">if</span> <span class="n">nano</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="L-543"><a href="#L-543"><span class="linenos">543</span></a> <span class="n">sec</span> <span class="o">+=</span> <span class="n">nano</span><span class="o">.</span><span class="n">pop</span><span class="p">()</span> <span class="o">/</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">number</span><span class="p">(</span><span class="mf">1000000000.0</span><span class="p">)</span> -</span><span id="L-544"><a href="#L-544"><span class="linenos">544</span></a> -</span><span id="L-545"><a href="#L-545"><span class="linenos">545</span></a> <span class="k">if</span> <span class="n">milli</span> <span class="ow">or</span> <span class="n">nano</span><span class="p">:</span> -</span><span id="L-546"><a href="#L-546"><span class="linenos">546</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"sec"</span><span class="p">,</span> <span class="n">sec</span><span class="p">)</span> -</span><span id="L-547"><a href="#L-547"><span class="linenos">547</span></a> -</span><span id="L-548"><a href="#L-548"><span class="linenos">548</span></a> <span class="k">return</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"MAKE_TIMESTAMP"</span><span class="p">)(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> -</span><span id="L-549"><a href="#L-549"><span class="linenos">549</span></a> -</span><span id="L-550"><a href="#L-550"><span class="linenos">550</span></a> <span class="k">def</span> <span class="nf">tablesample_sql</span><span class="p">(</span> -</span><span id="L-551"><a href="#L-551"><span class="linenos">551</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="L-552"><a href="#L-552"><span class="linenos">552</span></a> <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><span id="L-553"><a href="#L-553"><span class="linenos">553</span></a> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">" AS "</span><span class="p">,</span> -</span><span id="L-554"><a href="#L-554"><span class="linenos">554</span></a> <span class="n">tablesample_keyword</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-555"><a href="#L-555"><span class="linenos">555</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-556"><a href="#L-556"><span class="linenos">556</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">parent</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">):</span> -</span><span id="L-557"><a href="#L-557"><span class="linenos">557</span></a> <span class="c1"># This sample clause only applies to a single source, not the entire resulting relation</span> -</span><span id="L-558"><a href="#L-558"><span class="linenos">558</span></a> <span class="n">tablesample_keyword</span> <span class="o">=</span> <span class="s2">"TABLESAMPLE"</span> -</span><span id="L-559"><a href="#L-559"><span class="linenos">559</span></a> -</span><span id="L-560"><a href="#L-560"><span class="linenos">560</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">"size"</span><span class="p">):</span> -</span><span id="L-561"><a href="#L-561"><span class="linenos">561</span></a> <span class="n">method</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"method"</span><span class="p">)</span> -</span><span id="L-562"><a href="#L-562"><span class="linenos">562</span></a> <span class="k">if</span> <span class="n">method</span> <span class="ow">and</span> <span class="n">method</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> <span class="o">!=</span> <span class="s2">"RESERVOIR"</span><span class="p">:</span> -</span><span id="L-563"><a href="#L-563"><span class="linenos">563</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span> -</span><span id="L-564"><a href="#L-564"><span class="linenos">564</span></a> <span class="sa">f</span><span class="s2">"Sampling method </span><span class="si">{</span><span class="n">method</span><span class="si">}</span><span class="s2"> is not supported with a discrete sample count, "</span> -</span><span id="L-565"><a href="#L-565"><span class="linenos">565</span></a> <span class="s2">"defaulting to reservoir sampling"</span> -</span><span id="L-566"><a href="#L-566"><span class="linenos">566</span></a> <span class="p">)</span> -</span><span id="L-567"><a href="#L-567"><span class="linenos">567</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"method"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="s2">"RESERVOIR"</span><span class="p">))</span> -</span><span id="L-568"><a href="#L-568"><span class="linenos">568</span></a> -</span><span id="L-569"><a href="#L-569"><span class="linenos">569</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">tablesample_sql</span><span class="p">(</span> -</span><span id="L-570"><a href="#L-570"><span class="linenos">570</span></a> <span class="n">expression</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="n">sep</span><span class="p">,</span> <span class="n">tablesample_keyword</span><span class="o">=</span><span class="n">tablesample_keyword</span> -</span><span id="L-571"><a href="#L-571"><span class="linenos">571</span></a> <span class="p">)</span> -</span><span id="L-572"><a href="#L-572"><span class="linenos">572</span></a> -</span><span id="L-573"><a href="#L-573"><span class="linenos">573</span></a> <span class="k">def</span> <span class="nf">interval_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Interval</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-574"><a href="#L-574"><span class="linenos">574</span></a> <span class="n">multiplier</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">int</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-575"><a href="#L-575"><span class="linenos">575</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> -</span><span id="L-576"><a href="#L-576"><span class="linenos">576</span></a> -</span><span id="L-577"><a href="#L-577"><span class="linenos">577</span></a> <span class="k">if</span> <span class="n">unit</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"week"</span><span class="p">):</span> -</span><span id="L-578"><a href="#L-578"><span class="linenos">578</span></a> <span class="n">multiplier</span> <span class="o">=</span> <span class="mi">7</span> -</span><span id="L-579"><a href="#L-579"><span class="linenos">579</span></a> <span class="k">if</span> <span class="n">unit</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"quarter"</span><span class="p">):</span> -</span><span id="L-580"><a href="#L-580"><span class="linenos">580</span></a> <span class="n">multiplier</span> <span class="o">=</span> <span class="mi">90</span> -</span><span id="L-581"><a href="#L-581"><span class="linenos">581</span></a> -</span><span id="L-582"><a href="#L-582"><span class="linenos">582</span></a> <span class="k">if</span> <span class="n">multiplier</span><span class="p">:</span> -</span><span id="L-583"><a href="#L-583"><span class="linenos">583</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">multiplier</span><span class="si">}</span><span class="s2"> * </span><span class="si">{</span><span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">interval_sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Interval</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span><span class="w"> </span><span class="n">unit</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="s1">'DAY'</span><span class="p">)))</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="L-584"><a href="#L-584"><span class="linenos">584</span></a> -</span><span id="L-585"><a href="#L-585"><span class="linenos">585</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">interval_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="L-586"><a href="#L-586"><span class="linenos">586</span></a> -</span><span id="L-587"><a href="#L-587"><span class="linenos">587</span></a> <span class="k">def</span> <span class="nf">columndef_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ColumnDef</span><span class="p">,</span> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">" "</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-588"><a href="#L-588"><span class="linenos">588</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">parent</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">UserDefinedFunction</span><span class="p">):</span> -</span><span id="L-589"><a href="#L-589"><span class="linenos">589</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-590"><a href="#L-590"><span class="linenos">590</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">columndef_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">sep</span><span class="p">)</span> -</span><span id="L-591"><a href="#L-591"><span class="linenos">591</span></a> -</span><span id="L-592"><a href="#L-592"><span class="linenos">592</span></a> <span class="k">def</span> <span class="nf">join_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Join</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-593"><a href="#L-593"><span class="linenos">593</span></a> <span class="k">if</span> <span class="p">(</span> -</span><span id="L-594"><a href="#L-594"><span class="linenos">594</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">side</span> <span class="o">==</span> <span class="s2">"LEFT"</span> -</span><span id="L-595"><a href="#L-595"><span class="linenos">595</span></a> <span class="ow">and</span> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"on"</span><span class="p">)</span> -</span><span id="L-596"><a href="#L-596"><span class="linenos">596</span></a> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Unnest</span><span class="p">)</span> -</span><span id="L-597"><a href="#L-597"><span class="linenos">597</span></a> <span class="p">):</span> -</span><span id="L-598"><a href="#L-598"><span class="linenos">598</span></a> <span class="c1"># Some dialects support `LEFT JOIN UNNEST(...)` without an explicit ON clause</span> -</span><span id="L-599"><a href="#L-599"><span class="linenos">599</span></a> <span class="c1"># DuckDB doesn't, but we can just add a dummy ON clause that is always true</span> -</span><span id="L-600"><a href="#L-600"><span class="linenos">600</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">join_sql</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">on</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">true</span><span class="p">()))</span> +</span><span id="L-506"><a href="#L-506"><span class="linenos">506</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMPNTZ</span><span class="p">:</span> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> +</span><span id="L-507"><a href="#L-507"><span class="linenos">507</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMP_S</span><span class="p">:</span> <span class="s2">"TIMESTAMP_S"</span><span class="p">,</span> +</span><span id="L-508"><a href="#L-508"><span class="linenos">508</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMP_MS</span><span class="p">:</span> <span class="s2">"TIMESTAMP_MS"</span><span class="p">,</span> +</span><span id="L-509"><a href="#L-509"><span class="linenos">509</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMP_NS</span><span class="p">:</span> <span class="s2">"TIMESTAMP_NS"</span><span class="p">,</span> +</span><span id="L-510"><a href="#L-510"><span class="linenos">510</span></a> <span class="p">}</span> +</span><span id="L-511"><a href="#L-511"><span class="linenos">511</span></a> +</span><span id="L-512"><a href="#L-512"><span class="linenos">512</span></a> <span class="c1"># https://github.com/duckdb/duckdb/blob/ff7f24fd8e3128d94371827523dae85ebaf58713/third_party/libpg_query/grammar/keywords/reserved_keywords.list#L1-L77</span> +</span><span id="L-513"><a href="#L-513"><span class="linenos">513</span></a> <span class="n">RESERVED_KEYWORDS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-514"><a href="#L-514"><span class="linenos">514</span></a> <span class="s2">"array"</span><span class="p">,</span> +</span><span id="L-515"><a href="#L-515"><span class="linenos">515</span></a> <span class="s2">"analyse"</span><span class="p">,</span> +</span><span id="L-516"><a href="#L-516"><span class="linenos">516</span></a> <span class="s2">"union"</span><span class="p">,</span> +</span><span id="L-517"><a href="#L-517"><span class="linenos">517</span></a> <span class="s2">"all"</span><span class="p">,</span> +</span><span id="L-518"><a href="#L-518"><span class="linenos">518</span></a> <span class="s2">"when"</span><span class="p">,</span> +</span><span id="L-519"><a href="#L-519"><span class="linenos">519</span></a> <span class="s2">"in_p"</span><span class="p">,</span> +</span><span id="L-520"><a href="#L-520"><span class="linenos">520</span></a> <span class="s2">"default"</span><span class="p">,</span> +</span><span id="L-521"><a href="#L-521"><span class="linenos">521</span></a> <span class="s2">"create_p"</span><span class="p">,</span> +</span><span id="L-522"><a href="#L-522"><span class="linenos">522</span></a> <span class="s2">"window"</span><span class="p">,</span> +</span><span id="L-523"><a href="#L-523"><span class="linenos">523</span></a> <span class="s2">"asymmetric"</span><span class="p">,</span> +</span><span id="L-524"><a href="#L-524"><span class="linenos">524</span></a> <span class="s2">"to"</span><span class="p">,</span> +</span><span id="L-525"><a href="#L-525"><span class="linenos">525</span></a> <span class="s2">"else"</span><span class="p">,</span> +</span><span id="L-526"><a href="#L-526"><span class="linenos">526</span></a> <span class="s2">"localtime"</span><span class="p">,</span> +</span><span id="L-527"><a href="#L-527"><span class="linenos">527</span></a> <span class="s2">"from"</span><span class="p">,</span> +</span><span id="L-528"><a href="#L-528"><span class="linenos">528</span></a> <span class="s2">"end_p"</span><span class="p">,</span> +</span><span id="L-529"><a href="#L-529"><span class="linenos">529</span></a> <span class="s2">"select"</span><span class="p">,</span> +</span><span id="L-530"><a href="#L-530"><span class="linenos">530</span></a> <span class="s2">"current_date"</span><span class="p">,</span> +</span><span id="L-531"><a href="#L-531"><span class="linenos">531</span></a> <span class="s2">"foreign"</span><span class="p">,</span> +</span><span id="L-532"><a href="#L-532"><span class="linenos">532</span></a> <span class="s2">"with"</span><span class="p">,</span> +</span><span id="L-533"><a href="#L-533"><span class="linenos">533</span></a> <span class="s2">"grant"</span><span class="p">,</span> +</span><span id="L-534"><a href="#L-534"><span class="linenos">534</span></a> <span class="s2">"session_user"</span><span class="p">,</span> +</span><span id="L-535"><a href="#L-535"><span class="linenos">535</span></a> <span class="s2">"or"</span><span class="p">,</span> +</span><span id="L-536"><a href="#L-536"><span class="linenos">536</span></a> <span class="s2">"except"</span><span class="p">,</span> +</span><span id="L-537"><a href="#L-537"><span class="linenos">537</span></a> <span class="s2">"references"</span><span class="p">,</span> +</span><span id="L-538"><a href="#L-538"><span class="linenos">538</span></a> <span class="s2">"fetch"</span><span class="p">,</span> +</span><span id="L-539"><a href="#L-539"><span class="linenos">539</span></a> <span class="s2">"limit"</span><span class="p">,</span> +</span><span id="L-540"><a href="#L-540"><span class="linenos">540</span></a> <span class="s2">"group_p"</span><span class="p">,</span> +</span><span id="L-541"><a href="#L-541"><span class="linenos">541</span></a> <span class="s2">"leading"</span><span class="p">,</span> +</span><span id="L-542"><a href="#L-542"><span class="linenos">542</span></a> <span class="s2">"into"</span><span class="p">,</span> +</span><span id="L-543"><a href="#L-543"><span class="linenos">543</span></a> <span class="s2">"collate"</span><span class="p">,</span> +</span><span id="L-544"><a href="#L-544"><span class="linenos">544</span></a> <span class="s2">"offset"</span><span class="p">,</span> +</span><span id="L-545"><a href="#L-545"><span class="linenos">545</span></a> <span class="s2">"do"</span><span class="p">,</span> +</span><span id="L-546"><a href="#L-546"><span class="linenos">546</span></a> <span class="s2">"then"</span><span class="p">,</span> +</span><span id="L-547"><a href="#L-547"><span class="linenos">547</span></a> <span class="s2">"localtimestamp"</span><span class="p">,</span> +</span><span id="L-548"><a href="#L-548"><span class="linenos">548</span></a> <span class="s2">"check_p"</span><span class="p">,</span> +</span><span id="L-549"><a href="#L-549"><span class="linenos">549</span></a> <span class="s2">"lateral_p"</span><span class="p">,</span> +</span><span id="L-550"><a href="#L-550"><span class="linenos">550</span></a> <span class="s2">"current_role"</span><span class="p">,</span> +</span><span id="L-551"><a href="#L-551"><span class="linenos">551</span></a> <span class="s2">"where"</span><span class="p">,</span> +</span><span id="L-552"><a href="#L-552"><span class="linenos">552</span></a> <span class="s2">"asc_p"</span><span class="p">,</span> +</span><span id="L-553"><a href="#L-553"><span class="linenos">553</span></a> <span class="s2">"placing"</span><span class="p">,</span> +</span><span id="L-554"><a href="#L-554"><span class="linenos">554</span></a> <span class="s2">"desc_p"</span><span class="p">,</span> +</span><span id="L-555"><a href="#L-555"><span class="linenos">555</span></a> <span class="s2">"user"</span><span class="p">,</span> +</span><span id="L-556"><a href="#L-556"><span class="linenos">556</span></a> <span class="s2">"unique"</span><span class="p">,</span> +</span><span id="L-557"><a href="#L-557"><span class="linenos">557</span></a> <span class="s2">"initially"</span><span class="p">,</span> +</span><span id="L-558"><a href="#L-558"><span class="linenos">558</span></a> <span class="s2">"column"</span><span class="p">,</span> +</span><span id="L-559"><a href="#L-559"><span class="linenos">559</span></a> <span class="s2">"both"</span><span class="p">,</span> +</span><span id="L-560"><a href="#L-560"><span class="linenos">560</span></a> <span class="s2">"some"</span><span class="p">,</span> +</span><span id="L-561"><a href="#L-561"><span class="linenos">561</span></a> <span class="s2">"as"</span><span class="p">,</span> +</span><span id="L-562"><a href="#L-562"><span class="linenos">562</span></a> <span class="s2">"any"</span><span class="p">,</span> +</span><span id="L-563"><a href="#L-563"><span class="linenos">563</span></a> <span class="s2">"only"</span><span class="p">,</span> +</span><span id="L-564"><a href="#L-564"><span class="linenos">564</span></a> <span class="s2">"deferrable"</span><span class="p">,</span> +</span><span id="L-565"><a href="#L-565"><span class="linenos">565</span></a> <span class="s2">"null_p"</span><span class="p">,</span> +</span><span id="L-566"><a href="#L-566"><span class="linenos">566</span></a> <span class="s2">"current_time"</span><span class="p">,</span> +</span><span id="L-567"><a href="#L-567"><span class="linenos">567</span></a> <span class="s2">"true_p"</span><span class="p">,</span> +</span><span id="L-568"><a href="#L-568"><span class="linenos">568</span></a> <span class="s2">"table"</span><span class="p">,</span> +</span><span id="L-569"><a href="#L-569"><span class="linenos">569</span></a> <span class="s2">"case"</span><span class="p">,</span> +</span><span id="L-570"><a href="#L-570"><span class="linenos">570</span></a> <span class="s2">"trailing"</span><span class="p">,</span> +</span><span id="L-571"><a href="#L-571"><span class="linenos">571</span></a> <span class="s2">"variadic"</span><span class="p">,</span> +</span><span id="L-572"><a href="#L-572"><span class="linenos">572</span></a> <span class="s2">"for"</span><span class="p">,</span> +</span><span id="L-573"><a href="#L-573"><span class="linenos">573</span></a> <span class="s2">"on"</span><span class="p">,</span> +</span><span id="L-574"><a href="#L-574"><span class="linenos">574</span></a> <span class="s2">"distinct"</span><span class="p">,</span> +</span><span id="L-575"><a href="#L-575"><span class="linenos">575</span></a> <span class="s2">"false_p"</span><span class="p">,</span> +</span><span id="L-576"><a href="#L-576"><span class="linenos">576</span></a> <span class="s2">"not"</span><span class="p">,</span> +</span><span id="L-577"><a href="#L-577"><span class="linenos">577</span></a> <span class="s2">"constraint"</span><span class="p">,</span> +</span><span id="L-578"><a href="#L-578"><span class="linenos">578</span></a> <span class="s2">"current_timestamp"</span><span class="p">,</span> +</span><span id="L-579"><a href="#L-579"><span class="linenos">579</span></a> <span class="s2">"returning"</span><span class="p">,</span> +</span><span id="L-580"><a href="#L-580"><span class="linenos">580</span></a> <span class="s2">"primary"</span><span class="p">,</span> +</span><span id="L-581"><a href="#L-581"><span class="linenos">581</span></a> <span class="s2">"intersect"</span><span class="p">,</span> +</span><span id="L-582"><a href="#L-582"><span class="linenos">582</span></a> <span class="s2">"having"</span><span class="p">,</span> +</span><span id="L-583"><a href="#L-583"><span class="linenos">583</span></a> <span class="s2">"analyze"</span><span class="p">,</span> +</span><span id="L-584"><a href="#L-584"><span class="linenos">584</span></a> <span class="s2">"current_user"</span><span class="p">,</span> +</span><span id="L-585"><a href="#L-585"><span class="linenos">585</span></a> <span class="s2">"and"</span><span class="p">,</span> +</span><span id="L-586"><a href="#L-586"><span class="linenos">586</span></a> <span class="s2">"cast"</span><span class="p">,</span> +</span><span id="L-587"><a href="#L-587"><span class="linenos">587</span></a> <span class="s2">"symmetric"</span><span class="p">,</span> +</span><span id="L-588"><a href="#L-588"><span class="linenos">588</span></a> <span class="s2">"using"</span><span class="p">,</span> +</span><span id="L-589"><a href="#L-589"><span class="linenos">589</span></a> <span class="s2">"order"</span><span class="p">,</span> +</span><span id="L-590"><a href="#L-590"><span class="linenos">590</span></a> <span class="s2">"current_catalog"</span><span class="p">,</span> +</span><span id="L-591"><a href="#L-591"><span class="linenos">591</span></a> <span class="p">}</span> +</span><span id="L-592"><a href="#L-592"><span class="linenos">592</span></a> +</span><span id="L-593"><a href="#L-593"><span class="linenos">593</span></a> <span class="n">UNWRAPPED_INTERVAL_VALUES</span> <span class="o">=</span> <span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Paren</span><span class="p">)</span> +</span><span id="L-594"><a href="#L-594"><span class="linenos">594</span></a> +</span><span id="L-595"><a href="#L-595"><span class="linenos">595</span></a> <span class="c1"># DuckDB doesn't generally support CREATE TABLE .. properties</span> +</span><span id="L-596"><a href="#L-596"><span class="linenos">596</span></a> <span class="c1"># https://duckdb.org/docs/sql/statements/create_table.html</span> +</span><span id="L-597"><a href="#L-597"><span class="linenos">597</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-598"><a href="#L-598"><span class="linenos">598</span></a> <span class="n">prop</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span> +</span><span id="L-599"><a href="#L-599"><span class="linenos">599</span></a> <span class="k">for</span> <span class="n">prop</span> <span class="ow">in</span> <span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">PROPERTIES_LOCATION</span> +</span><span id="L-600"><a href="#L-600"><span class="linenos">600</span></a> <span class="p">}</span> </span><span id="L-601"><a href="#L-601"><span class="linenos">601</span></a> -</span><span id="L-602"><a href="#L-602"><span class="linenos">602</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">join_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="L-603"><a href="#L-603"><span class="linenos">603</span></a> -</span><span id="L-604"><a href="#L-604"><span class="linenos">604</span></a> <span class="k">def</span> <span class="nf">generateseries_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GenerateSeries</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-605"><a href="#L-605"><span class="linenos">605</span></a> <span class="c1"># GENERATE_SERIES(a, b) -> [a, b], RANGE(a, b) -> [a, b)</span> -</span><span id="L-606"><a href="#L-606"><span class="linenos">606</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">"is_end_exclusive"</span><span class="p">):</span> -</span><span id="L-607"><a href="#L-607"><span class="linenos">607</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"is_end_exclusive"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> -</span><span id="L-608"><a href="#L-608"><span class="linenos">608</span></a> <span class="k">return</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"RANGE"</span><span class="p">)(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> -</span><span id="L-609"><a href="#L-609"><span class="linenos">609</span></a> -</span><span id="L-610"><a href="#L-610"><span class="linenos">610</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">generateseries_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="L-611"><a href="#L-611"><span class="linenos">611</span></a> -</span><span id="L-612"><a href="#L-612"><span class="linenos">612</span></a> <span class="k">def</span> <span class="nf">bracket_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Bracket</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-613"><a href="#L-613"><span class="linenos">613</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> -</span><span id="L-614"><a href="#L-614"><span class="linenos">614</span></a> <span class="k">if</span> <span class="nb">isinstance</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">Array</span><span class="p">):</span> -</span><span id="L-615"><a href="#L-615"><span class="linenos">615</span></a> <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">paren</span><span class="p">(</span><span class="n">this</span><span class="p">))</span> -</span><span id="L-616"><a href="#L-616"><span class="linenos">616</span></a> -</span><span id="L-617"><a href="#L-617"><span class="linenos">617</span></a> <span class="n">bracket</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">bracket_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-602"><a href="#L-602"><span class="linenos">602</span></a> <span class="c1"># There are a few exceptions (e.g. temporary tables) which are supported or</span> +</span><span id="L-603"><a href="#L-603"><span class="linenos">603</span></a> <span class="c1"># can be transpiled to DuckDB, so we explicitly override them accordingly</span> +</span><span id="L-604"><a href="#L-604"><span class="linenos">604</span></a> <span class="n">PROPERTIES_LOCATION</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">LikeProperty</span><span class="p">]</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span> +</span><span id="L-605"><a href="#L-605"><span class="linenos">605</span></a> <span class="n">PROPERTIES_LOCATION</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">TemporaryProperty</span><span class="p">]</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span> +</span><span id="L-606"><a href="#L-606"><span class="linenos">606</span></a> +</span><span id="L-607"><a href="#L-607"><span class="linenos">607</span></a> <span class="k">def</span> <span class="nf">timefromparts_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TimeFromParts</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-608"><a href="#L-608"><span class="linenos">608</span></a> <span class="n">nano</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"nano"</span><span class="p">)</span> +</span><span id="L-609"><a href="#L-609"><span class="linenos">609</span></a> <span class="k">if</span> <span class="n">nano</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-610"><a href="#L-610"><span class="linenos">610</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> +</span><span id="L-611"><a href="#L-611"><span class="linenos">611</span></a> <span class="s2">"sec"</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"sec"</span><span class="p">]</span> <span class="o">+</span> <span class="n">nano</span><span class="o">.</span><span class="n">pop</span><span class="p">()</span> <span class="o">/</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">number</span><span class="p">(</span><span class="mf">1000000000.0</span><span class="p">)</span> +</span><span id="L-612"><a href="#L-612"><span class="linenos">612</span></a> <span class="p">)</span> +</span><span id="L-613"><a href="#L-613"><span class="linenos">613</span></a> +</span><span id="L-614"><a href="#L-614"><span class="linenos">614</span></a> <span class="k">return</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"MAKE_TIME"</span><span class="p">)(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> +</span><span id="L-615"><a href="#L-615"><span class="linenos">615</span></a> +</span><span id="L-616"><a href="#L-616"><span class="linenos">616</span></a> <span class="k">def</span> <span class="nf">timestampfromparts_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TimestampFromParts</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-617"><a href="#L-617"><span class="linenos">617</span></a> <span class="n">sec</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"sec"</span><span class="p">]</span> </span><span id="L-618"><a href="#L-618"><span class="linenos">618</span></a> -</span><span id="L-619"><a href="#L-619"><span class="linenos">619</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"returns_list_for_maps"</span><span class="p">):</span> -</span><span id="L-620"><a href="#L-620"><span class="linenos">620</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">this</span><span class="o">.</span><span class="n">type</span><span class="p">:</span> -</span><span id="L-621"><a href="#L-621"><span class="linenos">621</span></a> <span class="kn">from</span> <span class="nn">sqlglot.optimizer.annotate_types</span> <span class="kn">import</span> <span class="n">annotate_types</span> +</span><span id="L-619"><a href="#L-619"><span class="linenos">619</span></a> <span class="n">milli</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"milli"</span><span class="p">)</span> +</span><span id="L-620"><a href="#L-620"><span class="linenos">620</span></a> <span class="k">if</span> <span class="n">milli</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-621"><a href="#L-621"><span class="linenos">621</span></a> <span class="n">sec</span> <span class="o">+=</span> <span class="n">milli</span><span class="o">.</span><span class="n">pop</span><span class="p">()</span> <span class="o">/</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">number</span><span class="p">(</span><span class="mf">1000.0</span><span class="p">)</span> </span><span id="L-622"><a href="#L-622"><span class="linenos">622</span></a> -</span><span id="L-623"><a href="#L-623"><span class="linenos">623</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">annotate_types</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> -</span><span id="L-624"><a href="#L-624"><span class="linenos">624</span></a> -</span><span id="L-625"><a href="#L-625"><span class="linenos">625</span></a> <span class="k">if</span> <span class="n">this</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">MAP</span><span class="p">):</span> -</span><span id="L-626"><a href="#L-626"><span class="linenos">626</span></a> <span class="n">bracket</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">bracket</span><span class="si">}</span><span class="s2">)[1]"</span> -</span><span id="L-627"><a href="#L-627"><span class="linenos">627</span></a> -</span><span id="L-628"><a href="#L-628"><span class="linenos">628</span></a> <span class="k">return</span> <span class="n">bracket</span> +</span><span id="L-623"><a href="#L-623"><span class="linenos">623</span></a> <span class="n">nano</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"nano"</span><span class="p">)</span> +</span><span id="L-624"><a href="#L-624"><span class="linenos">624</span></a> <span class="k">if</span> <span class="n">nano</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-625"><a href="#L-625"><span class="linenos">625</span></a> <span class="n">sec</span> <span class="o">+=</span> <span class="n">nano</span><span class="o">.</span><span class="n">pop</span><span class="p">()</span> <span class="o">/</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">number</span><span class="p">(</span><span class="mf">1000000000.0</span><span class="p">)</span> +</span><span id="L-626"><a href="#L-626"><span class="linenos">626</span></a> +</span><span id="L-627"><a href="#L-627"><span class="linenos">627</span></a> <span class="k">if</span> <span class="n">milli</span> <span class="ow">or</span> <span class="n">nano</span><span class="p">:</span> +</span><span id="L-628"><a href="#L-628"><span class="linenos">628</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"sec"</span><span class="p">,</span> <span class="n">sec</span><span class="p">)</span> </span><span id="L-629"><a href="#L-629"><span class="linenos">629</span></a> -</span><span id="L-630"><a href="#L-630"><span class="linenos">630</span></a> <span class="k">def</span> <span class="nf">withingroup_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">WithinGroup</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-631"><a href="#L-631"><span class="linenos">631</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> -</span><span id="L-632"><a href="#L-632"><span class="linenos">632</span></a> -</span><span id="L-633"><a href="#L-633"><span class="linenos">633</span></a> <span class="n">func</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> -</span><span id="L-634"><a href="#L-634"><span class="linenos">634</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">func</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">PERCENTILES</span><span class="p">):</span> -</span><span id="L-635"><a href="#L-635"><span class="linenos">635</span></a> <span class="c1"># Make the order key the first arg and slide the fraction to the right</span> -</span><span id="L-636"><a href="#L-636"><span class="linenos">636</span></a> <span class="c1"># https://duckdb.org/docs/sql/aggregates#ordered-set-aggregate-functions</span> -</span><span id="L-637"><a href="#L-637"><span class="linenos">637</span></a> <span class="n">order_col</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">find</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Ordered</span><span class="p">)</span> -</span><span id="L-638"><a href="#L-638"><span class="linenos">638</span></a> <span class="k">if</span> <span class="n">order_col</span><span class="p">:</span> -</span><span id="L-639"><a href="#L-639"><span class="linenos">639</span></a> <span class="n">func</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"expression"</span><span class="p">,</span> <span class="n">func</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> -</span><span id="L-640"><a href="#L-640"><span class="linenos">640</span></a> <span class="n">func</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"this"</span><span class="p">,</span> <span class="n">order_col</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> +</span><span id="L-630"><a href="#L-630"><span class="linenos">630</span></a> <span class="k">return</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"MAKE_TIMESTAMP"</span><span class="p">)(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> +</span><span id="L-631"><a href="#L-631"><span class="linenos">631</span></a> +</span><span id="L-632"><a href="#L-632"><span class="linenos">632</span></a> <span class="k">def</span> <span class="nf">tablesample_sql</span><span class="p">(</span> +</span><span id="L-633"><a href="#L-633"><span class="linenos">633</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="L-634"><a href="#L-634"><span class="linenos">634</span></a> <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><span id="L-635"><a href="#L-635"><span class="linenos">635</span></a> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">" AS "</span><span class="p">,</span> +</span><span id="L-636"><a href="#L-636"><span class="linenos">636</span></a> <span class="n">tablesample_keyword</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-637"><a href="#L-637"><span class="linenos">637</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-638"><a href="#L-638"><span class="linenos">638</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">parent</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">):</span> +</span><span id="L-639"><a href="#L-639"><span class="linenos">639</span></a> <span class="c1"># This sample clause only applies to a single source, not the entire resulting relation</span> +</span><span id="L-640"><a href="#L-640"><span class="linenos">640</span></a> <span class="n">tablesample_keyword</span> <span class="o">=</span> <span class="s2">"TABLESAMPLE"</span> </span><span id="L-641"><a href="#L-641"><span class="linenos">641</span></a> -</span><span id="L-642"><a href="#L-642"><span class="linenos">642</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span><span class="o">.</span><span class="n">rstrip</span><span class="p">(</span><span class="s2">")"</span><span class="p">)</span> -</span><span id="L-643"><a href="#L-643"><span class="linenos">643</span></a> -</span><span id="L-644"><a href="#L-644"><span class="linenos">644</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="L-642"><a href="#L-642"><span class="linenos">642</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">"size"</span><span class="p">):</span> +</span><span id="L-643"><a href="#L-643"><span class="linenos">643</span></a> <span class="n">method</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"method"</span><span class="p">)</span> +</span><span id="L-644"><a href="#L-644"><span class="linenos">644</span></a> <span class="k">if</span> <span class="n">method</span> <span class="ow">and</span> <span class="n">method</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> <span class="o">!=</span> <span class="s2">"RESERVOIR"</span><span class="p">:</span> +</span><span id="L-645"><a href="#L-645"><span class="linenos">645</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span> +</span><span id="L-646"><a href="#L-646"><span class="linenos">646</span></a> <span class="sa">f</span><span class="s2">"Sampling method </span><span class="si">{</span><span class="n">method</span><span class="si">}</span><span class="s2"> is not supported with a discrete sample count, "</span> +</span><span id="L-647"><a href="#L-647"><span class="linenos">647</span></a> <span class="s2">"defaulting to reservoir sampling"</span> +</span><span id="L-648"><a href="#L-648"><span class="linenos">648</span></a> <span class="p">)</span> +</span><span id="L-649"><a href="#L-649"><span class="linenos">649</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"method"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="s2">"RESERVOIR"</span><span class="p">))</span> +</span><span id="L-650"><a href="#L-650"><span class="linenos">650</span></a> +</span><span id="L-651"><a href="#L-651"><span class="linenos">651</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">tablesample_sql</span><span class="p">(</span> +</span><span id="L-652"><a href="#L-652"><span class="linenos">652</span></a> <span class="n">expression</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="n">sep</span><span class="p">,</span> <span class="n">tablesample_keyword</span><span class="o">=</span><span class="n">tablesample_keyword</span> +</span><span id="L-653"><a href="#L-653"><span class="linenos">653</span></a> <span class="p">)</span> +</span><span id="L-654"><a href="#L-654"><span class="linenos">654</span></a> +</span><span id="L-655"><a href="#L-655"><span class="linenos">655</span></a> <span class="k">def</span> <span class="nf">interval_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Interval</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-656"><a href="#L-656"><span class="linenos">656</span></a> <span class="n">multiplier</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">int</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-657"><a href="#L-657"><span class="linenos">657</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> +</span><span id="L-658"><a href="#L-658"><span class="linenos">658</span></a> +</span><span id="L-659"><a href="#L-659"><span class="linenos">659</span></a> <span class="k">if</span> <span class="n">unit</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"week"</span><span class="p">):</span> +</span><span id="L-660"><a href="#L-660"><span class="linenos">660</span></a> <span class="n">multiplier</span> <span class="o">=</span> <span class="mi">7</span> +</span><span id="L-661"><a href="#L-661"><span class="linenos">661</span></a> <span class="k">if</span> <span class="n">unit</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"quarter"</span><span class="p">):</span> +</span><span id="L-662"><a href="#L-662"><span class="linenos">662</span></a> <span class="n">multiplier</span> <span class="o">=</span> <span class="mi">90</span> +</span><span id="L-663"><a href="#L-663"><span class="linenos">663</span></a> +</span><span id="L-664"><a href="#L-664"><span class="linenos">664</span></a> <span class="k">if</span> <span class="n">multiplier</span><span class="p">:</span> +</span><span id="L-665"><a href="#L-665"><span class="linenos">665</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">multiplier</span><span class="si">}</span><span class="s2"> * </span><span class="si">{</span><span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">interval_sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Interval</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span><span class="w"> </span><span class="n">unit</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="s1">'DAY'</span><span class="p">)))</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="L-666"><a href="#L-666"><span class="linenos">666</span></a> +</span><span id="L-667"><a href="#L-667"><span class="linenos">667</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">interval_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-668"><a href="#L-668"><span class="linenos">668</span></a> +</span><span id="L-669"><a href="#L-669"><span class="linenos">669</span></a> <span class="k">def</span> <span class="nf">columndef_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ColumnDef</span><span class="p">,</span> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">" "</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-670"><a href="#L-670"><span class="linenos">670</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">parent</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">UserDefinedFunction</span><span class="p">):</span> +</span><span id="L-671"><a href="#L-671"><span class="linenos">671</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="L-672"><a href="#L-672"><span class="linenos">672</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">columndef_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">sep</span><span class="p">)</span> +</span><span id="L-673"><a href="#L-673"><span class="linenos">673</span></a> +</span><span id="L-674"><a href="#L-674"><span class="linenos">674</span></a> <span class="k">def</span> <span class="nf">join_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Join</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-675"><a href="#L-675"><span class="linenos">675</span></a> <span class="k">if</span> <span class="p">(</span> +</span><span id="L-676"><a href="#L-676"><span class="linenos">676</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">side</span> <span class="o">==</span> <span class="s2">"LEFT"</span> +</span><span id="L-677"><a href="#L-677"><span class="linenos">677</span></a> <span class="ow">and</span> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"on"</span><span class="p">)</span> +</span><span id="L-678"><a href="#L-678"><span class="linenos">678</span></a> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Unnest</span><span class="p">)</span> +</span><span id="L-679"><a href="#L-679"><span class="linenos">679</span></a> <span class="p">):</span> +</span><span id="L-680"><a href="#L-680"><span class="linenos">680</span></a> <span class="c1"># Some dialects support `LEFT JOIN UNNEST(...)` without an explicit ON clause</span> +</span><span id="L-681"><a href="#L-681"><span class="linenos">681</span></a> <span class="c1"># DuckDB doesn't, but we can just add a dummy ON clause that is always true</span> +</span><span id="L-682"><a href="#L-682"><span class="linenos">682</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">join_sql</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">on</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">true</span><span class="p">()))</span> +</span><span id="L-683"><a href="#L-683"><span class="linenos">683</span></a> +</span><span id="L-684"><a href="#L-684"><span class="linenos">684</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">join_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-685"><a href="#L-685"><span class="linenos">685</span></a> +</span><span id="L-686"><a href="#L-686"><span class="linenos">686</span></a> <span class="k">def</span> <span class="nf">generateseries_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GenerateSeries</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-687"><a href="#L-687"><span class="linenos">687</span></a> <span class="c1"># GENERATE_SERIES(a, b) -> [a, b], RANGE(a, b) -> [a, b)</span> +</span><span id="L-688"><a href="#L-688"><span class="linenos">688</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"is_end_exclusive"</span><span class="p">):</span> +</span><span id="L-689"><a href="#L-689"><span class="linenos">689</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"is_end_exclusive"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> +</span><span id="L-690"><a href="#L-690"><span class="linenos">690</span></a> <span class="k">return</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"RANGE"</span><span class="p">)(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> +</span><span id="L-691"><a href="#L-691"><span class="linenos">691</span></a> +</span><span id="L-692"><a href="#L-692"><span class="linenos">692</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">generateseries_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-693"><a href="#L-693"><span class="linenos">693</span></a> +</span><span id="L-694"><a href="#L-694"><span class="linenos">694</span></a> <span class="k">def</span> <span class="nf">bracket_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Bracket</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-695"><a href="#L-695"><span class="linenos">695</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> +</span><span id="L-696"><a href="#L-696"><span class="linenos">696</span></a> <span class="k">if</span> <span class="nb">isinstance</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">Array</span><span class="p">):</span> +</span><span id="L-697"><a href="#L-697"><span class="linenos">697</span></a> <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">paren</span><span class="p">(</span><span class="n">this</span><span class="p">))</span> +</span><span id="L-698"><a href="#L-698"><span class="linenos">698</span></a> +</span><span id="L-699"><a href="#L-699"><span class="linenos">699</span></a> <span class="n">bracket</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">bracket_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-700"><a href="#L-700"><span class="linenos">700</span></a> +</span><span id="L-701"><a href="#L-701"><span class="linenos">701</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"returns_list_for_maps"</span><span class="p">):</span> +</span><span id="L-702"><a href="#L-702"><span class="linenos">702</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">this</span><span class="o">.</span><span class="n">type</span><span class="p">:</span> +</span><span id="L-703"><a href="#L-703"><span class="linenos">703</span></a> <span class="kn">from</span> <span class="nn">sqlglot.optimizer.annotate_types</span> <span class="kn">import</span> <span class="n">annotate_types</span> +</span><span id="L-704"><a href="#L-704"><span class="linenos">704</span></a> +</span><span id="L-705"><a href="#L-705"><span class="linenos">705</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">annotate_types</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> +</span><span id="L-706"><a href="#L-706"><span class="linenos">706</span></a> +</span><span id="L-707"><a href="#L-707"><span class="linenos">707</span></a> <span class="k">if</span> <span class="n">this</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">MAP</span><span class="p">):</span> +</span><span id="L-708"><a href="#L-708"><span class="linenos">708</span></a> <span class="n">bracket</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">bracket</span><span class="si">}</span><span class="s2">)[1]"</span> +</span><span id="L-709"><a href="#L-709"><span class="linenos">709</span></a> +</span><span id="L-710"><a href="#L-710"><span class="linenos">710</span></a> <span class="k">return</span> <span class="n">bracket</span> +</span><span id="L-711"><a href="#L-711"><span class="linenos">711</span></a> +</span><span id="L-712"><a href="#L-712"><span class="linenos">712</span></a> <span class="k">def</span> <span class="nf">withingroup_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">WithinGroup</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-713"><a href="#L-713"><span class="linenos">713</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> +</span><span id="L-714"><a href="#L-714"><span class="linenos">714</span></a> +</span><span id="L-715"><a href="#L-715"><span class="linenos">715</span></a> <span class="n">func</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> +</span><span id="L-716"><a href="#L-716"><span class="linenos">716</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">func</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">PERCENTILES</span><span class="p">):</span> +</span><span id="L-717"><a href="#L-717"><span class="linenos">717</span></a> <span class="c1"># Make the order key the first arg and slide the fraction to the right</span> +</span><span id="L-718"><a href="#L-718"><span class="linenos">718</span></a> <span class="c1"># https://duckdb.org/docs/sql/aggregates#ordered-set-aggregate-functions</span> +</span><span id="L-719"><a href="#L-719"><span class="linenos">719</span></a> <span class="n">order_col</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">find</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Ordered</span><span class="p">)</span> +</span><span id="L-720"><a href="#L-720"><span class="linenos">720</span></a> <span class="k">if</span> <span class="n">order_col</span><span class="p">:</span> +</span><span id="L-721"><a href="#L-721"><span class="linenos">721</span></a> <span class="n">func</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"expression"</span><span class="p">,</span> <span class="n">func</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> +</span><span id="L-722"><a href="#L-722"><span class="linenos">722</span></a> <span class="n">func</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"this"</span><span class="p">,</span> <span class="n">order_col</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> +</span><span id="L-723"><a href="#L-723"><span class="linenos">723</span></a> +</span><span id="L-724"><a href="#L-724"><span class="linenos">724</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span><span class="o">.</span><span class="n">rstrip</span><span class="p">(</span><span class="s2">")"</span><span class="p">)</span> +</span><span id="L-725"><a href="#L-725"><span class="linenos">725</span></a> +</span><span id="L-726"><a href="#L-726"><span class="linenos">726</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">)"</span> </span></pre></div> @@ -1156,7 +1241,7 @@ </span><span id="DuckDB-342"><a href="#DuckDB-342"><span class="linenos">342</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">L_BRACE</span><span class="p">,</span> <span class="n">advance</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span> </span><span id="DuckDB-343"><a href="#DuckDB-343"><span class="linenos">343</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">ToMap</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_bracket</span><span class="p">())</span> </span><span id="DuckDB-344"><a href="#DuckDB-344"><span class="linenos">344</span></a> -</span><span id="DuckDB-345"><a href="#DuckDB-345"><span class="linenos">345</span></a> <span class="n">args</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_wrapped_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">)</span> +</span><span id="DuckDB-345"><a href="#DuckDB-345"><span class="linenos">345</span></a> <span class="n">args</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_wrapped_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_assignment</span><span class="p">)</span> </span><span id="DuckDB-346"><a href="#DuckDB-346"><span class="linenos">346</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Map</span><span class="p">,</span> <span class="n">keys</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">values</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">1</span><span class="p">))</span> </span><span id="DuckDB-347"><a href="#DuckDB-347"><span class="linenos">347</span></a> </span><span id="DuckDB-348"><a href="#DuckDB-348"><span class="linenos">348</span></a> <span class="k">def</span> <span class="nf">_parse_struct_types</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">type_required</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">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]:</span> @@ -1318,145 +1403,227 @@ </span><span id="DuckDB-504"><a href="#DuckDB-504"><span class="linenos">504</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">VARBINARY</span><span class="p">:</span> <span class="s2">"BLOB"</span><span class="p">,</span> </span><span id="DuckDB-505"><a href="#DuckDB-505"><span class="linenos">505</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">ROWVERSION</span><span class="p">:</span> <span class="s2">"BLOB"</span><span class="p">,</span> </span><span id="DuckDB-506"><a href="#DuckDB-506"><span class="linenos">506</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">VARCHAR</span><span class="p">:</span> <span class="s2">"TEXT"</span><span class="p">,</span> -</span><span id="DuckDB-507"><a href="#DuckDB-507"><span class="linenos">507</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMP_S</span><span class="p">:</span> <span class="s2">"TIMESTAMP_S"</span><span class="p">,</span> -</span><span id="DuckDB-508"><a href="#DuckDB-508"><span class="linenos">508</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMP_MS</span><span class="p">:</span> <span class="s2">"TIMESTAMP_MS"</span><span class="p">,</span> -</span><span id="DuckDB-509"><a href="#DuckDB-509"><span class="linenos">509</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMP_NS</span><span class="p">:</span> <span class="s2">"TIMESTAMP_NS"</span><span class="p">,</span> -</span><span id="DuckDB-510"><a href="#DuckDB-510"><span class="linenos">510</span></a> <span class="p">}</span> -</span><span id="DuckDB-511"><a href="#DuckDB-511"><span class="linenos">511</span></a> -</span><span id="DuckDB-512"><a href="#DuckDB-512"><span class="linenos">512</span></a> <span class="n">UNWRAPPED_INTERVAL_VALUES</span> <span class="o">=</span> <span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Paren</span><span class="p">)</span> -</span><span id="DuckDB-513"><a href="#DuckDB-513"><span class="linenos">513</span></a> -</span><span id="DuckDB-514"><a href="#DuckDB-514"><span class="linenos">514</span></a> <span class="c1"># DuckDB doesn't generally support CREATE TABLE .. properties</span> -</span><span id="DuckDB-515"><a href="#DuckDB-515"><span class="linenos">515</span></a> <span class="c1"># https://duckdb.org/docs/sql/statements/create_table.html</span> -</span><span id="DuckDB-516"><a href="#DuckDB-516"><span class="linenos">516</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="DuckDB-517"><a href="#DuckDB-517"><span class="linenos">517</span></a> <span class="n">prop</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span> -</span><span id="DuckDB-518"><a href="#DuckDB-518"><span class="linenos">518</span></a> <span class="k">for</span> <span class="n">prop</span> <span class="ow">in</span> <span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">PROPERTIES_LOCATION</span> -</span><span id="DuckDB-519"><a href="#DuckDB-519"><span class="linenos">519</span></a> <span class="p">}</span> -</span><span id="DuckDB-520"><a href="#DuckDB-520"><span class="linenos">520</span></a> -</span><span id="DuckDB-521"><a href="#DuckDB-521"><span class="linenos">521</span></a> <span class="c1"># There are a few exceptions (e.g. temporary tables) which are supported or</span> -</span><span id="DuckDB-522"><a href="#DuckDB-522"><span class="linenos">522</span></a> <span class="c1"># can be transpiled to DuckDB, so we explicitly override them accordingly</span> -</span><span id="DuckDB-523"><a href="#DuckDB-523"><span class="linenos">523</span></a> <span class="n">PROPERTIES_LOCATION</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">LikeProperty</span><span class="p">]</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span> -</span><span id="DuckDB-524"><a href="#DuckDB-524"><span class="linenos">524</span></a> <span class="n">PROPERTIES_LOCATION</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">TemporaryProperty</span><span class="p">]</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span> -</span><span id="DuckDB-525"><a href="#DuckDB-525"><span class="linenos">525</span></a> -</span><span id="DuckDB-526"><a href="#DuckDB-526"><span class="linenos">526</span></a> <span class="k">def</span> <span class="nf">timefromparts_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TimeFromParts</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="DuckDB-527"><a href="#DuckDB-527"><span class="linenos">527</span></a> <span class="n">nano</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"nano"</span><span class="p">)</span> -</span><span id="DuckDB-528"><a href="#DuckDB-528"><span class="linenos">528</span></a> <span class="k">if</span> <span class="n">nano</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="DuckDB-529"><a href="#DuckDB-529"><span class="linenos">529</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> -</span><span id="DuckDB-530"><a href="#DuckDB-530"><span class="linenos">530</span></a> <span class="s2">"sec"</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"sec"</span><span class="p">]</span> <span class="o">+</span> <span class="n">nano</span><span class="o">.</span><span class="n">pop</span><span class="p">()</span> <span class="o">/</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">number</span><span class="p">(</span><span class="mf">1000000000.0</span><span class="p">)</span> -</span><span id="DuckDB-531"><a href="#DuckDB-531"><span class="linenos">531</span></a> <span class="p">)</span> -</span><span id="DuckDB-532"><a href="#DuckDB-532"><span class="linenos">532</span></a> -</span><span id="DuckDB-533"><a href="#DuckDB-533"><span class="linenos">533</span></a> <span class="k">return</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"MAKE_TIME"</span><span class="p">)(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> -</span><span id="DuckDB-534"><a href="#DuckDB-534"><span class="linenos">534</span></a> -</span><span id="DuckDB-535"><a href="#DuckDB-535"><span class="linenos">535</span></a> <span class="k">def</span> <span class="nf">timestampfromparts_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TimestampFromParts</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="DuckDB-536"><a href="#DuckDB-536"><span class="linenos">536</span></a> <span class="n">sec</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"sec"</span><span class="p">]</span> -</span><span id="DuckDB-537"><a href="#DuckDB-537"><span class="linenos">537</span></a> -</span><span id="DuckDB-538"><a href="#DuckDB-538"><span class="linenos">538</span></a> <span class="n">milli</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"milli"</span><span class="p">)</span> -</span><span id="DuckDB-539"><a href="#DuckDB-539"><span class="linenos">539</span></a> <span class="k">if</span> <span class="n">milli</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="DuckDB-540"><a href="#DuckDB-540"><span class="linenos">540</span></a> <span class="n">sec</span> <span class="o">+=</span> <span class="n">milli</span><span class="o">.</span><span class="n">pop</span><span class="p">()</span> <span class="o">/</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">number</span><span class="p">(</span><span class="mf">1000.0</span><span class="p">)</span> -</span><span id="DuckDB-541"><a href="#DuckDB-541"><span class="linenos">541</span></a> -</span><span id="DuckDB-542"><a href="#DuckDB-542"><span class="linenos">542</span></a> <span class="n">nano</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"nano"</span><span class="p">)</span> -</span><span id="DuckDB-543"><a href="#DuckDB-543"><span class="linenos">543</span></a> <span class="k">if</span> <span class="n">nano</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="DuckDB-544"><a href="#DuckDB-544"><span class="linenos">544</span></a> <span class="n">sec</span> <span class="o">+=</span> <span class="n">nano</span><span class="o">.</span><span class="n">pop</span><span class="p">()</span> <span class="o">/</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">number</span><span class="p">(</span><span class="mf">1000000000.0</span><span class="p">)</span> -</span><span id="DuckDB-545"><a href="#DuckDB-545"><span class="linenos">545</span></a> -</span><span id="DuckDB-546"><a href="#DuckDB-546"><span class="linenos">546</span></a> <span class="k">if</span> <span class="n">milli</span> <span class="ow">or</span> <span class="n">nano</span><span class="p">:</span> -</span><span id="DuckDB-547"><a href="#DuckDB-547"><span class="linenos">547</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"sec"</span><span class="p">,</span> <span class="n">sec</span><span class="p">)</span> -</span><span id="DuckDB-548"><a href="#DuckDB-548"><span class="linenos">548</span></a> -</span><span id="DuckDB-549"><a href="#DuckDB-549"><span class="linenos">549</span></a> <span class="k">return</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"MAKE_TIMESTAMP"</span><span class="p">)(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> -</span><span id="DuckDB-550"><a href="#DuckDB-550"><span class="linenos">550</span></a> -</span><span id="DuckDB-551"><a href="#DuckDB-551"><span class="linenos">551</span></a> <span class="k">def</span> <span class="nf">tablesample_sql</span><span class="p">(</span> -</span><span id="DuckDB-552"><a href="#DuckDB-552"><span class="linenos">552</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="DuckDB-553"><a href="#DuckDB-553"><span class="linenos">553</span></a> <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><span id="DuckDB-554"><a href="#DuckDB-554"><span class="linenos">554</span></a> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">" AS "</span><span class="p">,</span> -</span><span id="DuckDB-555"><a href="#DuckDB-555"><span class="linenos">555</span></a> <span class="n">tablesample_keyword</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="DuckDB-556"><a href="#DuckDB-556"><span class="linenos">556</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="DuckDB-557"><a href="#DuckDB-557"><span class="linenos">557</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">parent</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">):</span> -</span><span id="DuckDB-558"><a href="#DuckDB-558"><span class="linenos">558</span></a> <span class="c1"># This sample clause only applies to a single source, not the entire resulting relation</span> -</span><span id="DuckDB-559"><a href="#DuckDB-559"><span class="linenos">559</span></a> <span class="n">tablesample_keyword</span> <span class="o">=</span> <span class="s2">"TABLESAMPLE"</span> -</span><span id="DuckDB-560"><a href="#DuckDB-560"><span class="linenos">560</span></a> -</span><span id="DuckDB-561"><a href="#DuckDB-561"><span class="linenos">561</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">"size"</span><span class="p">):</span> -</span><span id="DuckDB-562"><a href="#DuckDB-562"><span class="linenos">562</span></a> <span class="n">method</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"method"</span><span class="p">)</span> -</span><span id="DuckDB-563"><a href="#DuckDB-563"><span class="linenos">563</span></a> <span class="k">if</span> <span class="n">method</span> <span class="ow">and</span> <span class="n">method</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> <span class="o">!=</span> <span class="s2">"RESERVOIR"</span><span class="p">:</span> -</span><span id="DuckDB-564"><a href="#DuckDB-564"><span class="linenos">564</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span> -</span><span id="DuckDB-565"><a href="#DuckDB-565"><span class="linenos">565</span></a> <span class="sa">f</span><span class="s2">"Sampling method </span><span class="si">{</span><span class="n">method</span><span class="si">}</span><span class="s2"> is not supported with a discrete sample count, "</span> -</span><span id="DuckDB-566"><a href="#DuckDB-566"><span class="linenos">566</span></a> <span class="s2">"defaulting to reservoir sampling"</span> -</span><span id="DuckDB-567"><a href="#DuckDB-567"><span class="linenos">567</span></a> <span class="p">)</span> -</span><span id="DuckDB-568"><a href="#DuckDB-568"><span class="linenos">568</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"method"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="s2">"RESERVOIR"</span><span class="p">))</span> -</span><span id="DuckDB-569"><a href="#DuckDB-569"><span class="linenos">569</span></a> -</span><span id="DuckDB-570"><a href="#DuckDB-570"><span class="linenos">570</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">tablesample_sql</span><span class="p">(</span> -</span><span id="DuckDB-571"><a href="#DuckDB-571"><span class="linenos">571</span></a> <span class="n">expression</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="n">sep</span><span class="p">,</span> <span class="n">tablesample_keyword</span><span class="o">=</span><span class="n">tablesample_keyword</span> -</span><span id="DuckDB-572"><a href="#DuckDB-572"><span class="linenos">572</span></a> <span class="p">)</span> -</span><span id="DuckDB-573"><a href="#DuckDB-573"><span class="linenos">573</span></a> -</span><span id="DuckDB-574"><a href="#DuckDB-574"><span class="linenos">574</span></a> <span class="k">def</span> <span class="nf">interval_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Interval</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="DuckDB-575"><a href="#DuckDB-575"><span class="linenos">575</span></a> <span class="n">multiplier</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">int</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="DuckDB-576"><a href="#DuckDB-576"><span class="linenos">576</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> -</span><span id="DuckDB-577"><a href="#DuckDB-577"><span class="linenos">577</span></a> -</span><span id="DuckDB-578"><a href="#DuckDB-578"><span class="linenos">578</span></a> <span class="k">if</span> <span class="n">unit</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"week"</span><span class="p">):</span> -</span><span id="DuckDB-579"><a href="#DuckDB-579"><span class="linenos">579</span></a> <span class="n">multiplier</span> <span class="o">=</span> <span class="mi">7</span> -</span><span id="DuckDB-580"><a href="#DuckDB-580"><span class="linenos">580</span></a> <span class="k">if</span> <span class="n">unit</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"quarter"</span><span class="p">):</span> -</span><span id="DuckDB-581"><a href="#DuckDB-581"><span class="linenos">581</span></a> <span class="n">multiplier</span> <span class="o">=</span> <span class="mi">90</span> -</span><span id="DuckDB-582"><a href="#DuckDB-582"><span class="linenos">582</span></a> -</span><span id="DuckDB-583"><a href="#DuckDB-583"><span class="linenos">583</span></a> <span class="k">if</span> <span class="n">multiplier</span><span class="p">:</span> -</span><span id="DuckDB-584"><a href="#DuckDB-584"><span class="linenos">584</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">multiplier</span><span class="si">}</span><span class="s2"> * </span><span class="si">{</span><span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">interval_sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Interval</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span><span class="w"> </span><span class="n">unit</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="s1">'DAY'</span><span class="p">)))</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="DuckDB-585"><a href="#DuckDB-585"><span class="linenos">585</span></a> -</span><span id="DuckDB-586"><a href="#DuckDB-586"><span class="linenos">586</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">interval_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="DuckDB-587"><a href="#DuckDB-587"><span class="linenos">587</span></a> -</span><span id="DuckDB-588"><a href="#DuckDB-588"><span class="linenos">588</span></a> <span class="k">def</span> <span class="nf">columndef_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ColumnDef</span><span class="p">,</span> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">" "</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="DuckDB-589"><a href="#DuckDB-589"><span class="linenos">589</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">parent</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">UserDefinedFunction</span><span class="p">):</span> -</span><span id="DuckDB-590"><a href="#DuckDB-590"><span class="linenos">590</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="DuckDB-591"><a href="#DuckDB-591"><span class="linenos">591</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">columndef_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">sep</span><span class="p">)</span> -</span><span id="DuckDB-592"><a href="#DuckDB-592"><span class="linenos">592</span></a> -</span><span id="DuckDB-593"><a href="#DuckDB-593"><span class="linenos">593</span></a> <span class="k">def</span> <span class="nf">join_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Join</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="DuckDB-594"><a href="#DuckDB-594"><span class="linenos">594</span></a> <span class="k">if</span> <span class="p">(</span> -</span><span id="DuckDB-595"><a href="#DuckDB-595"><span class="linenos">595</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">side</span> <span class="o">==</span> <span class="s2">"LEFT"</span> -</span><span id="DuckDB-596"><a href="#DuckDB-596"><span class="linenos">596</span></a> <span class="ow">and</span> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"on"</span><span class="p">)</span> -</span><span id="DuckDB-597"><a href="#DuckDB-597"><span class="linenos">597</span></a> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Unnest</span><span class="p">)</span> -</span><span id="DuckDB-598"><a href="#DuckDB-598"><span class="linenos">598</span></a> <span class="p">):</span> -</span><span id="DuckDB-599"><a href="#DuckDB-599"><span class="linenos">599</span></a> <span class="c1"># Some dialects support `LEFT JOIN UNNEST(...)` without an explicit ON clause</span> -</span><span id="DuckDB-600"><a href="#DuckDB-600"><span class="linenos">600</span></a> <span class="c1"># DuckDB doesn't, but we can just add a dummy ON clause that is always true</span> -</span><span id="DuckDB-601"><a href="#DuckDB-601"><span class="linenos">601</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">join_sql</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">on</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">true</span><span class="p">()))</span> +</span><span id="DuckDB-507"><a href="#DuckDB-507"><span class="linenos">507</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMPNTZ</span><span class="p">:</span> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> +</span><span id="DuckDB-508"><a href="#DuckDB-508"><span class="linenos">508</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMP_S</span><span class="p">:</span> <span class="s2">"TIMESTAMP_S"</span><span class="p">,</span> +</span><span id="DuckDB-509"><a href="#DuckDB-509"><span class="linenos">509</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMP_MS</span><span class="p">:</span> <span class="s2">"TIMESTAMP_MS"</span><span class="p">,</span> +</span><span id="DuckDB-510"><a href="#DuckDB-510"><span class="linenos">510</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMP_NS</span><span class="p">:</span> <span class="s2">"TIMESTAMP_NS"</span><span class="p">,</span> +</span><span id="DuckDB-511"><a href="#DuckDB-511"><span class="linenos">511</span></a> <span class="p">}</span> +</span><span id="DuckDB-512"><a href="#DuckDB-512"><span class="linenos">512</span></a> +</span><span id="DuckDB-513"><a href="#DuckDB-513"><span class="linenos">513</span></a> <span class="c1"># https://github.com/duckdb/duckdb/blob/ff7f24fd8e3128d94371827523dae85ebaf58713/third_party/libpg_query/grammar/keywords/reserved_keywords.list#L1-L77</span> +</span><span id="DuckDB-514"><a href="#DuckDB-514"><span class="linenos">514</span></a> <span class="n">RESERVED_KEYWORDS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="DuckDB-515"><a href="#DuckDB-515"><span class="linenos">515</span></a> <span class="s2">"array"</span><span class="p">,</span> +</span><span id="DuckDB-516"><a href="#DuckDB-516"><span class="linenos">516</span></a> <span class="s2">"analyse"</span><span class="p">,</span> +</span><span id="DuckDB-517"><a href="#DuckDB-517"><span class="linenos">517</span></a> <span class="s2">"union"</span><span class="p">,</span> +</span><span id="DuckDB-518"><a href="#DuckDB-518"><span class="linenos">518</span></a> <span class="s2">"all"</span><span class="p">,</span> +</span><span id="DuckDB-519"><a href="#DuckDB-519"><span class="linenos">519</span></a> <span class="s2">"when"</span><span class="p">,</span> +</span><span id="DuckDB-520"><a href="#DuckDB-520"><span class="linenos">520</span></a> <span class="s2">"in_p"</span><span class="p">,</span> +</span><span id="DuckDB-521"><a href="#DuckDB-521"><span class="linenos">521</span></a> <span class="s2">"default"</span><span class="p">,</span> +</span><span id="DuckDB-522"><a href="#DuckDB-522"><span class="linenos">522</span></a> <span class="s2">"create_p"</span><span class="p">,</span> +</span><span id="DuckDB-523"><a href="#DuckDB-523"><span class="linenos">523</span></a> <span class="s2">"window"</span><span class="p">,</span> +</span><span id="DuckDB-524"><a href="#DuckDB-524"><span class="linenos">524</span></a> <span class="s2">"asymmetric"</span><span class="p">,</span> +</span><span id="DuckDB-525"><a href="#DuckDB-525"><span class="linenos">525</span></a> <span class="s2">"to"</span><span class="p">,</span> +</span><span id="DuckDB-526"><a href="#DuckDB-526"><span class="linenos">526</span></a> <span class="s2">"else"</span><span class="p">,</span> +</span><span id="DuckDB-527"><a href="#DuckDB-527"><span class="linenos">527</span></a> <span class="s2">"localtime"</span><span class="p">,</span> +</span><span id="DuckDB-528"><a href="#DuckDB-528"><span class="linenos">528</span></a> <span class="s2">"from"</span><span class="p">,</span> +</span><span id="DuckDB-529"><a href="#DuckDB-529"><span class="linenos">529</span></a> <span class="s2">"end_p"</span><span class="p">,</span> +</span><span id="DuckDB-530"><a href="#DuckDB-530"><span class="linenos">530</span></a> <span class="s2">"select"</span><span class="p">,</span> +</span><span id="DuckDB-531"><a href="#DuckDB-531"><span class="linenos">531</span></a> <span class="s2">"current_date"</span><span class="p">,</span> +</span><span id="DuckDB-532"><a href="#DuckDB-532"><span class="linenos">532</span></a> <span class="s2">"foreign"</span><span class="p">,</span> +</span><span id="DuckDB-533"><a href="#DuckDB-533"><span class="linenos">533</span></a> <span class="s2">"with"</span><span class="p">,</span> +</span><span id="DuckDB-534"><a href="#DuckDB-534"><span class="linenos">534</span></a> <span class="s2">"grant"</span><span class="p">,</span> +</span><span id="DuckDB-535"><a href="#DuckDB-535"><span class="linenos">535</span></a> <span class="s2">"session_user"</span><span class="p">,</span> +</span><span id="DuckDB-536"><a href="#DuckDB-536"><span class="linenos">536</span></a> <span class="s2">"or"</span><span class="p">,</span> +</span><span id="DuckDB-537"><a href="#DuckDB-537"><span class="linenos">537</span></a> <span class="s2">"except"</span><span class="p">,</span> +</span><span id="DuckDB-538"><a href="#DuckDB-538"><span class="linenos">538</span></a> <span class="s2">"references"</span><span class="p">,</span> +</span><span id="DuckDB-539"><a href="#DuckDB-539"><span class="linenos">539</span></a> <span class="s2">"fetch"</span><span class="p">,</span> +</span><span id="DuckDB-540"><a href="#DuckDB-540"><span class="linenos">540</span></a> <span class="s2">"limit"</span><span class="p">,</span> +</span><span id="DuckDB-541"><a href="#DuckDB-541"><span class="linenos">541</span></a> <span class="s2">"group_p"</span><span class="p">,</span> +</span><span id="DuckDB-542"><a href="#DuckDB-542"><span class="linenos">542</span></a> <span class="s2">"leading"</span><span class="p">,</span> +</span><span id="DuckDB-543"><a href="#DuckDB-543"><span class="linenos">543</span></a> <span class="s2">"into"</span><span class="p">,</span> +</span><span id="DuckDB-544"><a href="#DuckDB-544"><span class="linenos">544</span></a> <span class="s2">"collate"</span><span class="p">,</span> +</span><span id="DuckDB-545"><a href="#DuckDB-545"><span class="linenos">545</span></a> <span class="s2">"offset"</span><span class="p">,</span> +</span><span id="DuckDB-546"><a href="#DuckDB-546"><span class="linenos">546</span></a> <span class="s2">"do"</span><span class="p">,</span> +</span><span id="DuckDB-547"><a href="#DuckDB-547"><span class="linenos">547</span></a> <span class="s2">"then"</span><span class="p">,</span> +</span><span id="DuckDB-548"><a href="#DuckDB-548"><span class="linenos">548</span></a> <span class="s2">"localtimestamp"</span><span class="p">,</span> +</span><span id="DuckDB-549"><a href="#DuckDB-549"><span class="linenos">549</span></a> <span class="s2">"check_p"</span><span class="p">,</span> +</span><span id="DuckDB-550"><a href="#DuckDB-550"><span class="linenos">550</span></a> <span class="s2">"lateral_p"</span><span class="p">,</span> +</span><span id="DuckDB-551"><a href="#DuckDB-551"><span class="linenos">551</span></a> <span class="s2">"current_role"</span><span class="p">,</span> +</span><span id="DuckDB-552"><a href="#DuckDB-552"><span class="linenos">552</span></a> <span class="s2">"where"</span><span class="p">,</span> +</span><span id="DuckDB-553"><a href="#DuckDB-553"><span class="linenos">553</span></a> <span class="s2">"asc_p"</span><span class="p">,</span> +</span><span id="DuckDB-554"><a href="#DuckDB-554"><span class="linenos">554</span></a> <span class="s2">"placing"</span><span class="p">,</span> +</span><span id="DuckDB-555"><a href="#DuckDB-555"><span class="linenos">555</span></a> <span class="s2">"desc_p"</span><span class="p">,</span> +</span><span id="DuckDB-556"><a href="#DuckDB-556"><span class="linenos">556</span></a> <span class="s2">"user"</span><span class="p">,</span> +</span><span id="DuckDB-557"><a href="#DuckDB-557"><span class="linenos">557</span></a> <span class="s2">"unique"</span><span class="p">,</span> +</span><span id="DuckDB-558"><a href="#DuckDB-558"><span class="linenos">558</span></a> <span class="s2">"initially"</span><span class="p">,</span> +</span><span id="DuckDB-559"><a href="#DuckDB-559"><span class="linenos">559</span></a> <span class="s2">"column"</span><span class="p">,</span> +</span><span id="DuckDB-560"><a href="#DuckDB-560"><span class="linenos">560</span></a> <span class="s2">"both"</span><span class="p">,</span> +</span><span id="DuckDB-561"><a href="#DuckDB-561"><span class="linenos">561</span></a> <span class="s2">"some"</span><span class="p">,</span> +</span><span id="DuckDB-562"><a href="#DuckDB-562"><span class="linenos">562</span></a> <span class="s2">"as"</span><span class="p">,</span> +</span><span id="DuckDB-563"><a href="#DuckDB-563"><span class="linenos">563</span></a> <span class="s2">"any"</span><span class="p">,</span> +</span><span id="DuckDB-564"><a href="#DuckDB-564"><span class="linenos">564</span></a> <span class="s2">"only"</span><span class="p">,</span> +</span><span id="DuckDB-565"><a href="#DuckDB-565"><span class="linenos">565</span></a> <span class="s2">"deferrable"</span><span class="p">,</span> +</span><span id="DuckDB-566"><a href="#DuckDB-566"><span class="linenos">566</span></a> <span class="s2">"null_p"</span><span class="p">,</span> +</span><span id="DuckDB-567"><a href="#DuckDB-567"><span class="linenos">567</span></a> <span class="s2">"current_time"</span><span class="p">,</span> +</span><span id="DuckDB-568"><a href="#DuckDB-568"><span class="linenos">568</span></a> <span class="s2">"true_p"</span><span class="p">,</span> +</span><span id="DuckDB-569"><a href="#DuckDB-569"><span class="linenos">569</span></a> <span class="s2">"table"</span><span class="p">,</span> +</span><span id="DuckDB-570"><a href="#DuckDB-570"><span class="linenos">570</span></a> <span class="s2">"case"</span><span class="p">,</span> +</span><span id="DuckDB-571"><a href="#DuckDB-571"><span class="linenos">571</span></a> <span class="s2">"trailing"</span><span class="p">,</span> +</span><span id="DuckDB-572"><a href="#DuckDB-572"><span class="linenos">572</span></a> <span class="s2">"variadic"</span><span class="p">,</span> +</span><span id="DuckDB-573"><a href="#DuckDB-573"><span class="linenos">573</span></a> <span class="s2">"for"</span><span class="p">,</span> +</span><span id="DuckDB-574"><a href="#DuckDB-574"><span class="linenos">574</span></a> <span class="s2">"on"</span><span class="p">,</span> +</span><span id="DuckDB-575"><a href="#DuckDB-575"><span class="linenos">575</span></a> <span class="s2">"distinct"</span><span class="p">,</span> +</span><span id="DuckDB-576"><a href="#DuckDB-576"><span class="linenos">576</span></a> <span class="s2">"false_p"</span><span class="p">,</span> +</span><span id="DuckDB-577"><a href="#DuckDB-577"><span class="linenos">577</span></a> <span class="s2">"not"</span><span class="p">,</span> +</span><span id="DuckDB-578"><a href="#DuckDB-578"><span class="linenos">578</span></a> <span class="s2">"constraint"</span><span class="p">,</span> +</span><span id="DuckDB-579"><a href="#DuckDB-579"><span class="linenos">579</span></a> <span class="s2">"current_timestamp"</span><span class="p">,</span> +</span><span id="DuckDB-580"><a href="#DuckDB-580"><span class="linenos">580</span></a> <span class="s2">"returning"</span><span class="p">,</span> +</span><span id="DuckDB-581"><a href="#DuckDB-581"><span class="linenos">581</span></a> <span class="s2">"primary"</span><span class="p">,</span> +</span><span id="DuckDB-582"><a href="#DuckDB-582"><span class="linenos">582</span></a> <span class="s2">"intersect"</span><span class="p">,</span> +</span><span id="DuckDB-583"><a href="#DuckDB-583"><span class="linenos">583</span></a> <span class="s2">"having"</span><span class="p">,</span> +</span><span id="DuckDB-584"><a href="#DuckDB-584"><span class="linenos">584</span></a> <span class="s2">"analyze"</span><span class="p">,</span> +</span><span id="DuckDB-585"><a href="#DuckDB-585"><span class="linenos">585</span></a> <span class="s2">"current_user"</span><span class="p">,</span> +</span><span id="DuckDB-586"><a href="#DuckDB-586"><span class="linenos">586</span></a> <span class="s2">"and"</span><span class="p">,</span> +</span><span id="DuckDB-587"><a href="#DuckDB-587"><span class="linenos">587</span></a> <span class="s2">"cast"</span><span class="p">,</span> +</span><span id="DuckDB-588"><a href="#DuckDB-588"><span class="linenos">588</span></a> <span class="s2">"symmetric"</span><span class="p">,</span> +</span><span id="DuckDB-589"><a href="#DuckDB-589"><span class="linenos">589</span></a> <span class="s2">"using"</span><span class="p">,</span> +</span><span id="DuckDB-590"><a href="#DuckDB-590"><span class="linenos">590</span></a> <span class="s2">"order"</span><span class="p">,</span> +</span><span id="DuckDB-591"><a href="#DuckDB-591"><span class="linenos">591</span></a> <span class="s2">"current_catalog"</span><span class="p">,</span> +</span><span id="DuckDB-592"><a href="#DuckDB-592"><span class="linenos">592</span></a> <span class="p">}</span> +</span><span id="DuckDB-593"><a href="#DuckDB-593"><span class="linenos">593</span></a> +</span><span id="DuckDB-594"><a href="#DuckDB-594"><span class="linenos">594</span></a> <span class="n">UNWRAPPED_INTERVAL_VALUES</span> <span class="o">=</span> <span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Paren</span><span class="p">)</span> +</span><span id="DuckDB-595"><a href="#DuckDB-595"><span class="linenos">595</span></a> +</span><span id="DuckDB-596"><a href="#DuckDB-596"><span class="linenos">596</span></a> <span class="c1"># DuckDB doesn't generally support CREATE TABLE .. properties</span> +</span><span id="DuckDB-597"><a href="#DuckDB-597"><span class="linenos">597</span></a> <span class="c1"># https://duckdb.org/docs/sql/statements/create_table.html</span> +</span><span id="DuckDB-598"><a href="#DuckDB-598"><span class="linenos">598</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="DuckDB-599"><a href="#DuckDB-599"><span class="linenos">599</span></a> <span class="n">prop</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span> +</span><span id="DuckDB-600"><a href="#DuckDB-600"><span class="linenos">600</span></a> <span class="k">for</span> <span class="n">prop</span> <span class="ow">in</span> <span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">PROPERTIES_LOCATION</span> +</span><span id="DuckDB-601"><a href="#DuckDB-601"><span class="linenos">601</span></a> <span class="p">}</span> </span><span id="DuckDB-602"><a href="#DuckDB-602"><span class="linenos">602</span></a> -</span><span id="DuckDB-603"><a href="#DuckDB-603"><span class="linenos">603</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">join_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="DuckDB-604"><a href="#DuckDB-604"><span class="linenos">604</span></a> -</span><span id="DuckDB-605"><a href="#DuckDB-605"><span class="linenos">605</span></a> <span class="k">def</span> <span class="nf">generateseries_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GenerateSeries</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="DuckDB-606"><a href="#DuckDB-606"><span class="linenos">606</span></a> <span class="c1"># GENERATE_SERIES(a, b) -> [a, b], RANGE(a, b) -> [a, b)</span> -</span><span id="DuckDB-607"><a href="#DuckDB-607"><span class="linenos">607</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">"is_end_exclusive"</span><span class="p">):</span> -</span><span id="DuckDB-608"><a href="#DuckDB-608"><span class="linenos">608</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"is_end_exclusive"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> -</span><span id="DuckDB-609"><a href="#DuckDB-609"><span class="linenos">609</span></a> <span class="k">return</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"RANGE"</span><span class="p">)(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> -</span><span id="DuckDB-610"><a href="#DuckDB-610"><span class="linenos">610</span></a> -</span><span id="DuckDB-611"><a href="#DuckDB-611"><span class="linenos">611</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">generateseries_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="DuckDB-612"><a href="#DuckDB-612"><span class="linenos">612</span></a> -</span><span id="DuckDB-613"><a href="#DuckDB-613"><span class="linenos">613</span></a> <span class="k">def</span> <span class="nf">bracket_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Bracket</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="DuckDB-614"><a href="#DuckDB-614"><span class="linenos">614</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> -</span><span id="DuckDB-615"><a href="#DuckDB-615"><span class="linenos">615</span></a> <span class="k">if</span> <span class="nb">isinstance</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">Array</span><span class="p">):</span> -</span><span id="DuckDB-616"><a href="#DuckDB-616"><span class="linenos">616</span></a> <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">paren</span><span class="p">(</span><span class="n">this</span><span class="p">))</span> -</span><span id="DuckDB-617"><a href="#DuckDB-617"><span class="linenos">617</span></a> -</span><span id="DuckDB-618"><a href="#DuckDB-618"><span class="linenos">618</span></a> <span class="n">bracket</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">bracket_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="DuckDB-603"><a href="#DuckDB-603"><span class="linenos">603</span></a> <span class="c1"># There are a few exceptions (e.g. temporary tables) which are supported or</span> +</span><span id="DuckDB-604"><a href="#DuckDB-604"><span class="linenos">604</span></a> <span class="c1"># can be transpiled to DuckDB, so we explicitly override them accordingly</span> +</span><span id="DuckDB-605"><a href="#DuckDB-605"><span class="linenos">605</span></a> <span class="n">PROPERTIES_LOCATION</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">LikeProperty</span><span class="p">]</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span> +</span><span id="DuckDB-606"><a href="#DuckDB-606"><span class="linenos">606</span></a> <span class="n">PROPERTIES_LOCATION</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">TemporaryProperty</span><span class="p">]</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span> +</span><span id="DuckDB-607"><a href="#DuckDB-607"><span class="linenos">607</span></a> +</span><span id="DuckDB-608"><a href="#DuckDB-608"><span class="linenos">608</span></a> <span class="k">def</span> <span class="nf">timefromparts_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TimeFromParts</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="DuckDB-609"><a href="#DuckDB-609"><span class="linenos">609</span></a> <span class="n">nano</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"nano"</span><span class="p">)</span> +</span><span id="DuckDB-610"><a href="#DuckDB-610"><span class="linenos">610</span></a> <span class="k">if</span> <span class="n">nano</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="DuckDB-611"><a href="#DuckDB-611"><span class="linenos">611</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> +</span><span id="DuckDB-612"><a href="#DuckDB-612"><span class="linenos">612</span></a> <span class="s2">"sec"</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"sec"</span><span class="p">]</span> <span class="o">+</span> <span class="n">nano</span><span class="o">.</span><span class="n">pop</span><span class="p">()</span> <span class="o">/</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">number</span><span class="p">(</span><span class="mf">1000000000.0</span><span class="p">)</span> +</span><span id="DuckDB-613"><a href="#DuckDB-613"><span class="linenos">613</span></a> <span class="p">)</span> +</span><span id="DuckDB-614"><a href="#DuckDB-614"><span class="linenos">614</span></a> +</span><span id="DuckDB-615"><a href="#DuckDB-615"><span class="linenos">615</span></a> <span class="k">return</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"MAKE_TIME"</span><span class="p">)(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> +</span><span id="DuckDB-616"><a href="#DuckDB-616"><span class="linenos">616</span></a> +</span><span id="DuckDB-617"><a href="#DuckDB-617"><span class="linenos">617</span></a> <span class="k">def</span> <span class="nf">timestampfromparts_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TimestampFromParts</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="DuckDB-618"><a href="#DuckDB-618"><span class="linenos">618</span></a> <span class="n">sec</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"sec"</span><span class="p">]</span> </span><span id="DuckDB-619"><a href="#DuckDB-619"><span class="linenos">619</span></a> -</span><span id="DuckDB-620"><a href="#DuckDB-620"><span class="linenos">620</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"returns_list_for_maps"</span><span class="p">):</span> -</span><span id="DuckDB-621"><a href="#DuckDB-621"><span class="linenos">621</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">this</span><span class="o">.</span><span class="n">type</span><span class="p">:</span> -</span><span id="DuckDB-622"><a href="#DuckDB-622"><span class="linenos">622</span></a> <span class="kn">from</span> <span class="nn">sqlglot.optimizer.annotate_types</span> <span class="kn">import</span> <span class="n">annotate_types</span> +</span><span id="DuckDB-620"><a href="#DuckDB-620"><span class="linenos">620</span></a> <span class="n">milli</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"milli"</span><span class="p">)</span> +</span><span id="DuckDB-621"><a href="#DuckDB-621"><span class="linenos">621</span></a> <span class="k">if</span> <span class="n">milli</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="DuckDB-622"><a href="#DuckDB-622"><span class="linenos">622</span></a> <span class="n">sec</span> <span class="o">+=</span> <span class="n">milli</span><span class="o">.</span><span class="n">pop</span><span class="p">()</span> <span class="o">/</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">number</span><span class="p">(</span><span class="mf">1000.0</span><span class="p">)</span> </span><span id="DuckDB-623"><a href="#DuckDB-623"><span class="linenos">623</span></a> -</span><span id="DuckDB-624"><a href="#DuckDB-624"><span class="linenos">624</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">annotate_types</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> -</span><span id="DuckDB-625"><a href="#DuckDB-625"><span class="linenos">625</span></a> -</span><span id="DuckDB-626"><a href="#DuckDB-626"><span class="linenos">626</span></a> <span class="k">if</span> <span class="n">this</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">MAP</span><span class="p">):</span> -</span><span id="DuckDB-627"><a href="#DuckDB-627"><span class="linenos">627</span></a> <span class="n">bracket</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">bracket</span><span class="si">}</span><span class="s2">)[1]"</span> -</span><span id="DuckDB-628"><a href="#DuckDB-628"><span class="linenos">628</span></a> -</span><span id="DuckDB-629"><a href="#DuckDB-629"><span class="linenos">629</span></a> <span class="k">return</span> <span class="n">bracket</span> +</span><span id="DuckDB-624"><a href="#DuckDB-624"><span class="linenos">624</span></a> <span class="n">nano</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"nano"</span><span class="p">)</span> +</span><span id="DuckDB-625"><a href="#DuckDB-625"><span class="linenos">625</span></a> <span class="k">if</span> <span class="n">nano</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="DuckDB-626"><a href="#DuckDB-626"><span class="linenos">626</span></a> <span class="n">sec</span> <span class="o">+=</span> <span class="n">nano</span><span class="o">.</span><span class="n">pop</span><span class="p">()</span> <span class="o">/</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">number</span><span class="p">(</span><span class="mf">1000000000.0</span><span class="p">)</span> +</span><span id="DuckDB-627"><a href="#DuckDB-627"><span class="linenos">627</span></a> +</span><span id="DuckDB-628"><a href="#DuckDB-628"><span class="linenos">628</span></a> <span class="k">if</span> <span class="n">milli</span> <span class="ow">or</span> <span class="n">nano</span><span class="p">:</span> +</span><span id="DuckDB-629"><a href="#DuckDB-629"><span class="linenos">629</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"sec"</span><span class="p">,</span> <span class="n">sec</span><span class="p">)</span> </span><span id="DuckDB-630"><a href="#DuckDB-630"><span class="linenos">630</span></a> -</span><span id="DuckDB-631"><a href="#DuckDB-631"><span class="linenos">631</span></a> <span class="k">def</span> <span class="nf">withingroup_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">WithinGroup</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="DuckDB-632"><a href="#DuckDB-632"><span class="linenos">632</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> -</span><span id="DuckDB-633"><a href="#DuckDB-633"><span class="linenos">633</span></a> -</span><span id="DuckDB-634"><a href="#DuckDB-634"><span class="linenos">634</span></a> <span class="n">func</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> -</span><span id="DuckDB-635"><a href="#DuckDB-635"><span class="linenos">635</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">func</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">PERCENTILES</span><span class="p">):</span> -</span><span id="DuckDB-636"><a href="#DuckDB-636"><span class="linenos">636</span></a> <span class="c1"># Make the order key the first arg and slide the fraction to the right</span> -</span><span id="DuckDB-637"><a href="#DuckDB-637"><span class="linenos">637</span></a> <span class="c1"># https://duckdb.org/docs/sql/aggregates#ordered-set-aggregate-functions</span> -</span><span id="DuckDB-638"><a href="#DuckDB-638"><span class="linenos">638</span></a> <span class="n">order_col</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">find</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Ordered</span><span class="p">)</span> -</span><span id="DuckDB-639"><a href="#DuckDB-639"><span class="linenos">639</span></a> <span class="k">if</span> <span class="n">order_col</span><span class="p">:</span> -</span><span id="DuckDB-640"><a href="#DuckDB-640"><span class="linenos">640</span></a> <span class="n">func</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"expression"</span><span class="p">,</span> <span class="n">func</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> -</span><span id="DuckDB-641"><a href="#DuckDB-641"><span class="linenos">641</span></a> <span class="n">func</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"this"</span><span class="p">,</span> <span class="n">order_col</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> +</span><span id="DuckDB-631"><a href="#DuckDB-631"><span class="linenos">631</span></a> <span class="k">return</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"MAKE_TIMESTAMP"</span><span class="p">)(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> +</span><span id="DuckDB-632"><a href="#DuckDB-632"><span class="linenos">632</span></a> +</span><span id="DuckDB-633"><a href="#DuckDB-633"><span class="linenos">633</span></a> <span class="k">def</span> <span class="nf">tablesample_sql</span><span class="p">(</span> +</span><span id="DuckDB-634"><a href="#DuckDB-634"><span class="linenos">634</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="DuckDB-635"><a href="#DuckDB-635"><span class="linenos">635</span></a> <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><span id="DuckDB-636"><a href="#DuckDB-636"><span class="linenos">636</span></a> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">" AS "</span><span class="p">,</span> +</span><span id="DuckDB-637"><a href="#DuckDB-637"><span class="linenos">637</span></a> <span class="n">tablesample_keyword</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="DuckDB-638"><a href="#DuckDB-638"><span class="linenos">638</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="DuckDB-639"><a href="#DuckDB-639"><span class="linenos">639</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">parent</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">):</span> +</span><span id="DuckDB-640"><a href="#DuckDB-640"><span class="linenos">640</span></a> <span class="c1"># This sample clause only applies to a single source, not the entire resulting relation</span> +</span><span id="DuckDB-641"><a href="#DuckDB-641"><span class="linenos">641</span></a> <span class="n">tablesample_keyword</span> <span class="o">=</span> <span class="s2">"TABLESAMPLE"</span> </span><span id="DuckDB-642"><a href="#DuckDB-642"><span class="linenos">642</span></a> -</span><span id="DuckDB-643"><a href="#DuckDB-643"><span class="linenos">643</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span><span class="o">.</span><span class="n">rstrip</span><span class="p">(</span><span class="s2">")"</span><span class="p">)</span> -</span><span id="DuckDB-644"><a href="#DuckDB-644"><span class="linenos">644</span></a> -</span><span id="DuckDB-645"><a href="#DuckDB-645"><span class="linenos">645</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="DuckDB-643"><a href="#DuckDB-643"><span class="linenos">643</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">"size"</span><span class="p">):</span> +</span><span id="DuckDB-644"><a href="#DuckDB-644"><span class="linenos">644</span></a> <span class="n">method</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"method"</span><span class="p">)</span> +</span><span id="DuckDB-645"><a href="#DuckDB-645"><span class="linenos">645</span></a> <span class="k">if</span> <span class="n">method</span> <span class="ow">and</span> <span class="n">method</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> <span class="o">!=</span> <span class="s2">"RESERVOIR"</span><span class="p">:</span> +</span><span id="DuckDB-646"><a href="#DuckDB-646"><span class="linenos">646</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span> +</span><span id="DuckDB-647"><a href="#DuckDB-647"><span class="linenos">647</span></a> <span class="sa">f</span><span class="s2">"Sampling method </span><span class="si">{</span><span class="n">method</span><span class="si">}</span><span class="s2"> is not supported with a discrete sample count, "</span> +</span><span id="DuckDB-648"><a href="#DuckDB-648"><span class="linenos">648</span></a> <span class="s2">"defaulting to reservoir sampling"</span> +</span><span id="DuckDB-649"><a href="#DuckDB-649"><span class="linenos">649</span></a> <span class="p">)</span> +</span><span id="DuckDB-650"><a href="#DuckDB-650"><span class="linenos">650</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"method"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="s2">"RESERVOIR"</span><span class="p">))</span> +</span><span id="DuckDB-651"><a href="#DuckDB-651"><span class="linenos">651</span></a> +</span><span id="DuckDB-652"><a href="#DuckDB-652"><span class="linenos">652</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">tablesample_sql</span><span class="p">(</span> +</span><span id="DuckDB-653"><a href="#DuckDB-653"><span class="linenos">653</span></a> <span class="n">expression</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="n">sep</span><span class="p">,</span> <span class="n">tablesample_keyword</span><span class="o">=</span><span class="n">tablesample_keyword</span> +</span><span id="DuckDB-654"><a href="#DuckDB-654"><span class="linenos">654</span></a> <span class="p">)</span> +</span><span id="DuckDB-655"><a href="#DuckDB-655"><span class="linenos">655</span></a> +</span><span id="DuckDB-656"><a href="#DuckDB-656"><span class="linenos">656</span></a> <span class="k">def</span> <span class="nf">interval_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Interval</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="DuckDB-657"><a href="#DuckDB-657"><span class="linenos">657</span></a> <span class="n">multiplier</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">int</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="DuckDB-658"><a href="#DuckDB-658"><span class="linenos">658</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> +</span><span id="DuckDB-659"><a href="#DuckDB-659"><span class="linenos">659</span></a> +</span><span id="DuckDB-660"><a href="#DuckDB-660"><span class="linenos">660</span></a> <span class="k">if</span> <span class="n">unit</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"week"</span><span class="p">):</span> +</span><span id="DuckDB-661"><a href="#DuckDB-661"><span class="linenos">661</span></a> <span class="n">multiplier</span> <span class="o">=</span> <span class="mi">7</span> +</span><span id="DuckDB-662"><a href="#DuckDB-662"><span class="linenos">662</span></a> <span class="k">if</span> <span class="n">unit</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"quarter"</span><span class="p">):</span> +</span><span id="DuckDB-663"><a href="#DuckDB-663"><span class="linenos">663</span></a> <span class="n">multiplier</span> <span class="o">=</span> <span class="mi">90</span> +</span><span id="DuckDB-664"><a href="#DuckDB-664"><span class="linenos">664</span></a> +</span><span id="DuckDB-665"><a href="#DuckDB-665"><span class="linenos">665</span></a> <span class="k">if</span> <span class="n">multiplier</span><span class="p">:</span> +</span><span id="DuckDB-666"><a href="#DuckDB-666"><span class="linenos">666</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">multiplier</span><span class="si">}</span><span class="s2"> * </span><span class="si">{</span><span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">interval_sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Interval</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span><span class="w"> </span><span class="n">unit</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="s1">'DAY'</span><span class="p">)))</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="DuckDB-667"><a href="#DuckDB-667"><span class="linenos">667</span></a> +</span><span id="DuckDB-668"><a href="#DuckDB-668"><span class="linenos">668</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">interval_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="DuckDB-669"><a href="#DuckDB-669"><span class="linenos">669</span></a> +</span><span id="DuckDB-670"><a href="#DuckDB-670"><span class="linenos">670</span></a> <span class="k">def</span> <span class="nf">columndef_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ColumnDef</span><span class="p">,</span> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">" "</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="DuckDB-671"><a href="#DuckDB-671"><span class="linenos">671</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">parent</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">UserDefinedFunction</span><span class="p">):</span> +</span><span id="DuckDB-672"><a href="#DuckDB-672"><span class="linenos">672</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="DuckDB-673"><a href="#DuckDB-673"><span class="linenos">673</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">columndef_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">sep</span><span class="p">)</span> +</span><span id="DuckDB-674"><a href="#DuckDB-674"><span class="linenos">674</span></a> +</span><span id="DuckDB-675"><a href="#DuckDB-675"><span class="linenos">675</span></a> <span class="k">def</span> <span class="nf">join_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Join</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="DuckDB-676"><a href="#DuckDB-676"><span class="linenos">676</span></a> <span class="k">if</span> <span class="p">(</span> +</span><span id="DuckDB-677"><a href="#DuckDB-677"><span class="linenos">677</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">side</span> <span class="o">==</span> <span class="s2">"LEFT"</span> +</span><span id="DuckDB-678"><a href="#DuckDB-678"><span class="linenos">678</span></a> <span class="ow">and</span> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"on"</span><span class="p">)</span> +</span><span id="DuckDB-679"><a href="#DuckDB-679"><span class="linenos">679</span></a> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Unnest</span><span class="p">)</span> +</span><span id="DuckDB-680"><a href="#DuckDB-680"><span class="linenos">680</span></a> <span class="p">):</span> +</span><span id="DuckDB-681"><a href="#DuckDB-681"><span class="linenos">681</span></a> <span class="c1"># Some dialects support `LEFT JOIN UNNEST(...)` without an explicit ON clause</span> +</span><span id="DuckDB-682"><a href="#DuckDB-682"><span class="linenos">682</span></a> <span class="c1"># DuckDB doesn't, but we can just add a dummy ON clause that is always true</span> +</span><span id="DuckDB-683"><a href="#DuckDB-683"><span class="linenos">683</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">join_sql</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">on</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">true</span><span class="p">()))</span> +</span><span id="DuckDB-684"><a href="#DuckDB-684"><span class="linenos">684</span></a> +</span><span id="DuckDB-685"><a href="#DuckDB-685"><span class="linenos">685</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">join_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="DuckDB-686"><a href="#DuckDB-686"><span class="linenos">686</span></a> +</span><span id="DuckDB-687"><a href="#DuckDB-687"><span class="linenos">687</span></a> <span class="k">def</span> <span class="nf">generateseries_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GenerateSeries</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="DuckDB-688"><a href="#DuckDB-688"><span class="linenos">688</span></a> <span class="c1"># GENERATE_SERIES(a, b) -> [a, b], RANGE(a, b) -> [a, b)</span> +</span><span id="DuckDB-689"><a href="#DuckDB-689"><span class="linenos">689</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"is_end_exclusive"</span><span class="p">):</span> +</span><span id="DuckDB-690"><a href="#DuckDB-690"><span class="linenos">690</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"is_end_exclusive"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> +</span><span id="DuckDB-691"><a href="#DuckDB-691"><span class="linenos">691</span></a> <span class="k">return</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"RANGE"</span><span class="p">)(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> +</span><span id="DuckDB-692"><a href="#DuckDB-692"><span class="linenos">692</span></a> +</span><span id="DuckDB-693"><a href="#DuckDB-693"><span class="linenos">693</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">generateseries_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="DuckDB-694"><a href="#DuckDB-694"><span class="linenos">694</span></a> +</span><span id="DuckDB-695"><a href="#DuckDB-695"><span class="linenos">695</span></a> <span class="k">def</span> <span class="nf">bracket_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Bracket</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="DuckDB-696"><a href="#DuckDB-696"><span class="linenos">696</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> +</span><span id="DuckDB-697"><a href="#DuckDB-697"><span class="linenos">697</span></a> <span class="k">if</span> <span class="nb">isinstance</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">Array</span><span class="p">):</span> +</span><span id="DuckDB-698"><a href="#DuckDB-698"><span class="linenos">698</span></a> <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">paren</span><span class="p">(</span><span class="n">this</span><span class="p">))</span> +</span><span id="DuckDB-699"><a href="#DuckDB-699"><span class="linenos">699</span></a> +</span><span id="DuckDB-700"><a href="#DuckDB-700"><span class="linenos">700</span></a> <span class="n">bracket</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">bracket_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="DuckDB-701"><a href="#DuckDB-701"><span class="linenos">701</span></a> +</span><span id="DuckDB-702"><a href="#DuckDB-702"><span class="linenos">702</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"returns_list_for_maps"</span><span class="p">):</span> +</span><span id="DuckDB-703"><a href="#DuckDB-703"><span class="linenos">703</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">this</span><span class="o">.</span><span class="n">type</span><span class="p">:</span> +</span><span id="DuckDB-704"><a href="#DuckDB-704"><span class="linenos">704</span></a> <span class="kn">from</span> <span class="nn">sqlglot.optimizer.annotate_types</span> <span class="kn">import</span> <span class="n">annotate_types</span> +</span><span id="DuckDB-705"><a href="#DuckDB-705"><span class="linenos">705</span></a> +</span><span id="DuckDB-706"><a href="#DuckDB-706"><span class="linenos">706</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">annotate_types</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> +</span><span id="DuckDB-707"><a href="#DuckDB-707"><span class="linenos">707</span></a> +</span><span id="DuckDB-708"><a href="#DuckDB-708"><span class="linenos">708</span></a> <span class="k">if</span> <span class="n">this</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">MAP</span><span class="p">):</span> +</span><span id="DuckDB-709"><a href="#DuckDB-709"><span class="linenos">709</span></a> <span class="n">bracket</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">bracket</span><span class="si">}</span><span class="s2">)[1]"</span> +</span><span id="DuckDB-710"><a href="#DuckDB-710"><span class="linenos">710</span></a> +</span><span id="DuckDB-711"><a href="#DuckDB-711"><span class="linenos">711</span></a> <span class="k">return</span> <span class="n">bracket</span> +</span><span id="DuckDB-712"><a href="#DuckDB-712"><span class="linenos">712</span></a> +</span><span id="DuckDB-713"><a href="#DuckDB-713"><span class="linenos">713</span></a> <span class="k">def</span> <span class="nf">withingroup_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">WithinGroup</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="DuckDB-714"><a href="#DuckDB-714"><span class="linenos">714</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> +</span><span id="DuckDB-715"><a href="#DuckDB-715"><span class="linenos">715</span></a> +</span><span id="DuckDB-716"><a href="#DuckDB-716"><span class="linenos">716</span></a> <span class="n">func</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> +</span><span id="DuckDB-717"><a href="#DuckDB-717"><span class="linenos">717</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">func</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">PERCENTILES</span><span class="p">):</span> +</span><span id="DuckDB-718"><a href="#DuckDB-718"><span class="linenos">718</span></a> <span class="c1"># Make the order key the first arg and slide the fraction to the right</span> +</span><span id="DuckDB-719"><a href="#DuckDB-719"><span class="linenos">719</span></a> <span class="c1"># https://duckdb.org/docs/sql/aggregates#ordered-set-aggregate-functions</span> +</span><span id="DuckDB-720"><a href="#DuckDB-720"><span class="linenos">720</span></a> <span class="n">order_col</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">find</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Ordered</span><span class="p">)</span> +</span><span id="DuckDB-721"><a href="#DuckDB-721"><span class="linenos">721</span></a> <span class="k">if</span> <span class="n">order_col</span><span class="p">:</span> +</span><span id="DuckDB-722"><a href="#DuckDB-722"><span class="linenos">722</span></a> <span class="n">func</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"expression"</span><span class="p">,</span> <span class="n">func</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> +</span><span id="DuckDB-723"><a href="#DuckDB-723"><span class="linenos">723</span></a> <span class="n">func</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"this"</span><span class="p">,</span> <span class="n">order_col</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> +</span><span id="DuckDB-724"><a href="#DuckDB-724"><span class="linenos">724</span></a> +</span><span id="DuckDB-725"><a href="#DuckDB-725"><span class="linenos">725</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span><span class="o">.</span><span class="n">rstrip</span><span class="p">(</span><span class="s2">")"</span><span class="p">)</span> +</span><span id="DuckDB-726"><a href="#DuckDB-726"><span class="linenos">726</span></a> +</span><span id="DuckDB-727"><a href="#DuckDB-727"><span class="linenos">727</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">)"</span> </span></pre></div> @@ -2135,7 +2302,7 @@ Possible values: <code>"nulls_are_small"</code>, <code>"nulls_are_large"</code>, </span><span id="DuckDB.Parser-342"><a href="#DuckDB.Parser-342"><span class="linenos">342</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">L_BRACE</span><span class="p">,</span> <span class="n">advance</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span> </span><span id="DuckDB.Parser-343"><a href="#DuckDB.Parser-343"><span class="linenos">343</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">ToMap</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_bracket</span><span class="p">())</span> </span><span id="DuckDB.Parser-344"><a href="#DuckDB.Parser-344"><span class="linenos">344</span></a> -</span><span id="DuckDB.Parser-345"><a href="#DuckDB.Parser-345"><span class="linenos">345</span></a> <span class="n">args</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_wrapped_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">)</span> +</span><span id="DuckDB.Parser-345"><a href="#DuckDB.Parser-345"><span class="linenos">345</span></a> <span class="n">args</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_wrapped_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_assignment</span><span class="p">)</span> </span><span id="DuckDB.Parser-346"><a href="#DuckDB.Parser-346"><span class="linenos">346</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Map</span><span class="p">,</span> <span class="n">keys</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">values</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">1</span><span class="p">))</span> </span><span id="DuckDB.Parser-347"><a href="#DuckDB.Parser-347"><span class="linenos">347</span></a> </span><span id="DuckDB.Parser-348"><a href="#DuckDB.Parser-348"><span class="linenos">348</span></a> <span class="k">def</span> <span class="nf">_parse_struct_types</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">type_required</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">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]:</span> @@ -2181,7 +2348,7 @@ Default: 3</li> <div id="DuckDB.Parser.FUNCTIONS_WITH_ALIASED_ARGS" class="classattr"> <div class="attr variable"> <span class="name">FUNCTIONS_WITH_ALIASED_ARGS</span> = -<span class="default_value">{'STRUCT', 'STRUCT_PACK'}</span> +<span class="default_value">{'STRUCT_PACK', 'STRUCT'}</span> </div> @@ -2194,7 +2361,7 @@ Default: 3</li> <div class="attr variable"> <span class="name">FUNCTIONS</span> = <input id="DuckDB.Parser.FUNCTIONS-view-value" class="view-value-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1"> - <label class="view-value-button pdoc-button" for="DuckDB.Parser.FUNCTIONS-view-value"></label><span class="default_value">{'ABS': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Abs">sqlglot.expressions.Abs</a>'>>, 'ADD_MONTHS': <bound method Func.from_arg_list of <class '<a href="../expressions.html#AddMonths">sqlglot.expressions.AddMonths</a>'>>, 'ANONYMOUS_AGG_FUNC': <bound method Func.from_arg_list of <class '<a href="../expressions.html#AnonymousAggFunc">sqlglot.expressions.AnonymousAggFunc</a>'>>, 'ANY_VALUE': <bound method Func.from_arg_list of <class '<a href="../expressions.html#AnyValue">sqlglot.expressions.AnyValue</a>'>>, 'APPROX_DISTINCT': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ApproxDistinct">sqlglot.expressions.ApproxDistinct</a>'>>, 'APPROX_COUNT_DISTINCT': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ApproxDistinct">sqlglot.expressions.ApproxDistinct</a>'>>, 'APPROX_QUANTILE': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ApproxQuantile">sqlglot.expressions.ApproxQuantile</a>'>>, 'APPROX_TOP_K': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ApproxTopK">sqlglot.expressions.ApproxTopK</a>'>>, 'ARG_MAX': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ArgMax">sqlglot.expressions.ArgMax</a>'>>, 'ARGMAX': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ArgMax">sqlglot.expressions.ArgMax</a>'>>, 'MAX_BY': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ArgMax">sqlglot.expressions.ArgMax</a>'>>, 'ARG_MIN': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ArgMin">sqlglot.expressions.ArgMin</a>'>>, 'ARGMIN': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ArgMin">sqlglot.expressions.ArgMin</a>'>>, 'MIN_BY': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ArgMin">sqlglot.expressions.ArgMin</a>'>>, 'ARRAY': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Array">sqlglot.expressions.Array</a>'>>, 'ARRAY_AGG': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ArrayAgg">sqlglot.expressions.ArrayAgg</a>'>>, 'ARRAY_ALL': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ArrayAll">sqlglot.expressions.ArrayAll</a>'>>, 'ARRAY_ANY': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ArrayAny">sqlglot.expressions.ArrayAny</a>'>>, 'ARRAY_CONCAT': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ArrayConcat">sqlglot.expressions.ArrayConcat</a>'>>, 'ARRAY_CAT': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ArrayConcat">sqlglot.expressions.ArrayConcat</a>'>>, 'ARRAY_CONSTRUCT_COMPACT': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ArrayConstructCompact">sqlglot.expressions.ArrayConstructCompact</a>'>>, 'ARRAY_CONTAINS': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ArrayContains">sqlglot.expressions.ArrayContains</a>'>>, 'ARRAY_HAS': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ArrayContains">sqlglot.expressions.ArrayContains</a>'>>, 'ARRAY_CONTAINS_ALL': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ArrayContainsAll">sqlglot.expressions.ArrayContainsAll</a>'>>, 'ARRAY_HAS_ALL': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ArrayContainsAll">sqlglot.expressions.ArrayContainsAll</a>'>>, 'FILTER': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ArrayFilter">sqlglot.expressions.ArrayFilter</a>'>>, 'ARRAY_FILTER': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ArrayFilter">sqlglot.expressions.ArrayFilter</a>'>>, 'ARRAY_OVERLAPS': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ArrayOverlaps">sqlglot.expressions.ArrayOverlaps</a>'>>, 'ARRAY_SIZE': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ArraySize">sqlglot.expressions.ArraySize</a>'>>, 'ARRAY_LENGTH': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ArraySize">sqlglot.expressions.ArraySize</a>'>>, 'ARRAY_SORT': <bound method Func.from_arg_list of <class '<a href="../expressions.html#SortArray">sqlglot.expressions.SortArray</a>'>>, 'ARRAY_SUM': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ArraySum">sqlglot.expressions.ArraySum</a>'>>, 'ARRAY_TO_STRING': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ArrayToString">sqlglot.expressions.ArrayToString</a>'>>, 'ARRAY_JOIN': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ArrayToString">sqlglot.expressions.ArrayToString</a>'>>, 'ARRAY_UNION_AGG': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ArrayUnionAgg">sqlglot.expressions.ArrayUnionAgg</a>'>>, 'ARRAY_UNIQUE_AGG': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ArrayUniqueAgg">sqlglot.expressions.ArrayUniqueAgg</a>'>>, 'AVG': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Avg">sqlglot.expressions.Avg</a>'>>, 'CASE': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Case">sqlglot.expressions.Case</a>'>>, 'CAST': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Cast">sqlglot.expressions.Cast</a>'>>, 'CAST_TO_STR_TYPE': <bound method Func.from_arg_list of <class '<a href="../expressions.html#CastToStrType">sqlglot.expressions.CastToStrType</a>'>>, 'CBRT': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Cbrt">sqlglot.expressions.Cbrt</a>'>>, 'CEIL': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Ceil">sqlglot.expressions.Ceil</a>'>>, 'CEILING': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Ceil">sqlglot.expressions.Ceil</a>'>>, 'CHR': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Chr">sqlglot.expressions.Chr</a>'>>, 'CHAR': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Chr">sqlglot.expressions.Chr</a>'>>, 'COALESCE': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Coalesce">sqlglot.expressions.Coalesce</a>'>>, 'IFNULL': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Coalesce">sqlglot.expressions.Coalesce</a>'>>, 'NVL': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Coalesce">sqlglot.expressions.Coalesce</a>'>>, 'COLLATE': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Collate">sqlglot.expressions.Collate</a>'>>, 'COMBINED_AGG_FUNC': <bound method Func.from_arg_list of <class '<a href="../expressions.html#CombinedAggFunc">sqlglot.expressions.CombinedAggFunc</a>'>>, 'COMBINED_PARAMETERIZED_AGG': <bound method Func.from_arg_list of <class '<a href="../expressions.html#CombinedParameterizedAgg">sqlglot.expressions.CombinedParameterizedAgg</a>'>>, 'CONCAT': <function Parser.<lambda>>, 'CONCAT_WS': <function Parser.<lambda>>, 'CONNECT_BY_ROOT': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ConnectByRoot">sqlglot.expressions.ConnectByRoot</a>'>>, 'CONVERT': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Convert">sqlglot.expressions.Convert</a>'>>, 'CORR': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Corr">sqlglot.expressions.Corr</a>'>>, 'COUNT': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Count">sqlglot.expressions.Count</a>'>>, 'COUNT_IF': <bound method Func.from_arg_list of <class '<a href="../expressions.html#CountIf">sqlglot.expressions.CountIf</a>'>>, 'COUNTIF': <bound method Func.from_arg_list of <class '<a href="../expressions.html#CountIf">sqlglot.expressions.CountIf</a>'>>, 'COVAR_POP': <bound method Func.from_arg_list of <class '<a href="../expressions.html#CovarPop">sqlglot.expressions.CovarPop</a>'>>, 'COVAR_SAMP': <bound method Func.from_arg_list of <class '<a href="../expressions.html#CovarSamp">sqlglot.expressions.CovarSamp</a>'>>, 'CURRENT_DATE': <bound method Func.from_arg_list of <class '<a href="../expressions.html#CurrentDate">sqlglot.expressions.CurrentDate</a>'>>, 'CURRENT_DATETIME': <bound method Func.from_arg_list of <class '<a href="../expressions.html#CurrentDatetime">sqlglot.expressions.CurrentDatetime</a>'>>, 'CURRENT_TIME': <bound method Func.from_arg_list of <class '<a href="../expressions.html#CurrentTime">sqlglot.expressions.CurrentTime</a>'>>, 'CURRENT_TIMESTAMP': <bound method Func.from_arg_list of <class '<a href="../expressions.html#CurrentTimestamp">sqlglot.expressions.CurrentTimestamp</a>'>>, 'CURRENT_USER': <bound method Func.from_arg_list of <class '<a href="../expressions.html#CurrentUser">sqlglot.expressions.CurrentUser</a>'>>, 'DATE': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Date">sqlglot.expressions.Date</a>'>>, 'DATE_ADD': <bound method Func.from_arg_list of <class '<a href="../expressions.html#DateAdd">sqlglot.expressions.DateAdd</a>'>>, 'DATEDIFF': <function _build_date_diff>, 'DATE_DIFF': <function _build_date_diff>, 'DATE_FROM_PARTS': <bound method Func.from_arg_list of <class '<a href="../expressions.html#DateFromParts">sqlglot.expressions.DateFromParts</a>'>>, 'DATEFROMPARTS': <bound method Func.from_arg_list of <class '<a href="../expressions.html#DateFromParts">sqlglot.expressions.DateFromParts</a>'>>, 'DATE_STR_TO_DATE': <bound method Func.from_arg_list of <class '<a href="../expressions.html#DateStrToDate">sqlglot.expressions.DateStrToDate</a>'>>, 'DATE_TO_DATE_STR': <function Parser.<lambda>>, 'DATE_TO_DI': <bound method Func.from_arg_list of <class '<a href="../expressions.html#DateToDi">sqlglot.expressions.DateToDi</a>'>>, 'DATE_TRUNC': <function date_trunc_to_time>, 'DATETIME_ADD': <bound method Func.from_arg_list of <class '<a href="../expressions.html#DatetimeAdd">sqlglot.expressions.DatetimeAdd</a>'>>, 'DATETIME_DIFF': <bound method Func.from_arg_list of <class '<a href="../expressions.html#DatetimeDiff">sqlglot.expressions.DatetimeDiff</a>'>>, 'DATETIME_SUB': <bound method Func.from_arg_list of <class '<a href="../expressions.html#DatetimeSub">sqlglot.expressions.DatetimeSub</a>'>>, 'DATETIME_TRUNC': <bound method Func.from_arg_list of <class '<a href="../expressions.html#DatetimeTrunc">sqlglot.expressions.DatetimeTrunc</a>'>>, 'DAY': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Day">sqlglot.expressions.Day</a>'>>, 'DAY_OF_MONTH': <bound method Func.from_arg_list of <class '<a href="../expressions.html#DayOfMonth">sqlglot.expressions.DayOfMonth</a>'>>, 'DAYOFMONTH': <bound method Func.from_arg_list of <class '<a href="../expressions.html#DayOfMonth">sqlglot.expressions.DayOfMonth</a>'>>, 'DAY_OF_WEEK': <bound method Func.from_arg_list of <class '<a href="../expressions.html#DayOfWeek">sqlglot.expressions.DayOfWeek</a>'>>, 'DAYOFWEEK': <bound method Func.from_arg_list of <class '<a href="../expressions.html#DayOfWeek">sqlglot.expressions.DayOfWeek</a>'>>, 'DAY_OF_YEAR': <bound method Func.from_arg_list of <class '<a href="../expressions.html#DayOfYear">sqlglot.expressions.DayOfYear</a>'>>, 'DAYOFYEAR': <bound method Func.from_arg_list of <class '<a href="../expressions.html#DayOfYear">sqlglot.expressions.DayOfYear</a>'>>, 'DECODE': <function <a href="#DuckDB.Parser">DuckDB.Parser</a>.<lambda>>, 'DI_TO_DATE': <bound method Func.from_arg_list of <class '<a href="../expressions.html#DiToDate">sqlglot.expressions.DiToDate</a>'>>, 'ENCODE': <function <a href="#DuckDB.Parser">DuckDB.Parser</a>.<lambda>>, 'EXP': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Exp">sqlglot.expressions.Exp</a>'>>, 'EXPLODE': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Explode">sqlglot.expressions.Explode</a>'>>, 'EXPLODE_OUTER': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ExplodeOuter">sqlglot.expressions.ExplodeOuter</a>'>>, 'EXTRACT': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Extract">sqlglot.expressions.Extract</a>'>>, 'FIRST': <bound method Func.from_arg_list of <class '<a href="../expressions.html#First">sqlglot.expressions.First</a>'>>, 'FIRST_VALUE': <bound method Func.from_arg_list of <class '<a href="../expressions.html#FirstValue">sqlglot.expressions.FirstValue</a>'>>, 'FLATTEN': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Flatten">sqlglot.expressions.Flatten</a>'>>, 'FLOOR': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Floor">sqlglot.expressions.Floor</a>'>>, 'FROM_BASE': <bound method Func.from_arg_list of <class '<a href="../expressions.html#FromBase">sqlglot.expressions.FromBase</a>'>>, 'FROM_BASE64': <bound method Func.from_arg_list of <class '<a href="../expressions.html#FromBase64">sqlglot.expressions.FromBase64</a>'>>, 'GENERATE_DATE_ARRAY': <bound method Func.from_arg_list of <class '<a href="../expressions.html#GenerateDateArray">sqlglot.expressions.GenerateDateArray</a>'>>, 'GENERATE_SERIES': <function _build_generate_series.<locals>._builder>, 'GREATEST': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Greatest">sqlglot.expressions.Greatest</a>'>>, 'GROUP_CONCAT': <bound method Func.from_arg_list of <class '<a href="../expressions.html#GroupConcat">sqlglot.expressions.GroupConcat</a>'>>, 'HEX': <function build_hex>, 'HLL': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Hll">sqlglot.expressions.Hll</a>'>>, 'IF': <bound method Func.from_arg_list of <class '<a href="../expressions.html#If">sqlglot.expressions.If</a>'>>, 'IIF': <bound method Func.from_arg_list of <class '<a href="../expressions.html#If">sqlglot.expressions.If</a>'>>, 'INITCAP': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Initcap">sqlglot.expressions.Initcap</a>'>>, 'IS_INF': <bound method Func.from_arg_list of <class '<a href="../expressions.html#IsInf">sqlglot.expressions.IsInf</a>'>>, 'ISINF': <bound method Func.from_arg_list of <class '<a href="../expressions.html#IsInf">sqlglot.expressions.IsInf</a>'>>, 'IS_NAN': <bound method Func.from_arg_list of <class '<a href="../expressions.html#IsNan">sqlglot.expressions.IsNan</a>'>>, 'ISNAN': <bound method Func.from_arg_list of <class '<a href="../expressions.html#IsNan">sqlglot.expressions.IsNan</a>'>>, 'J_S_O_N_ARRAY': <bound method Func.from_arg_list of <class '<a href="../expressions.html#JSONArray">sqlglot.expressions.JSONArray</a>'>>, 'J_S_O_N_ARRAY_AGG': <bound method Func.from_arg_list of <class '<a href="../expressions.html#JSONArrayAgg">sqlglot.expressions.JSONArrayAgg</a>'>>, 'JSON_ARRAY_CONTAINS': <bound method Func.from_arg_list of <class '<a href="../expressions.html#JSONArrayContains">sqlglot.expressions.JSONArrayContains</a>'>>, 'JSONB_EXTRACT': <bound method Func.from_arg_list of <class '<a href="../expressions.html#JSONBExtract">sqlglot.expressions.JSONBExtract</a>'>>, 'JSONB_EXTRACT_SCALAR': <bound method Func.from_arg_list of <class '<a href="../expressions.html#JSONBExtractScalar">sqlglot.expressions.JSONBExtractScalar</a>'>>, 'JSON_EXTRACT': <function build_extract_json_with_path.<locals>._builder>, 'JSON_EXTRACT_SCALAR': <function build_extract_json_with_path.<locals>._builder>, 'JSON_FORMAT': <bound method Func.from_arg_list of <class '<a href="../expressions.html#JSONFormat">sqlglot.expressions.JSONFormat</a>'>>, 'J_S_O_N_OBJECT': <bound method Func.from_arg_list of <class '<a href="../expressions.html#JSONObject">sqlglot.expressions.JSONObject</a>'>>, 'J_S_O_N_OBJECT_AGG': <bound method Func.from_arg_list of <class '<a href="../expressions.html#JSONObjectAgg">sqlglot.expressions.JSONObjectAgg</a>'>>, 'J_S_O_N_TABLE': <bound method Func.from_arg_list of <class '<a href="../expressions.html#JSONTable">sqlglot.expressions.JSONTable</a>'>>, 'LAG': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Lag">sqlglot.expressions.Lag</a>'>>, 'LAST': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Last">sqlglot.expressions.Last</a>'>>, 'LAST_DAY': <bound method Func.from_arg_list of <class '<a href="../expressions.html#LastDay">sqlglot.expressions.LastDay</a>'>>, 'LAST_DAY_OF_MONTH': <bound method Func.from_arg_list of <class '<a href="../expressions.html#LastDay">sqlglot.expressions.LastDay</a>'>>, 'LAST_VALUE': <bound method Func.from_arg_list of <class '<a href="../expressions.html#LastValue">sqlglot.expressions.LastValue</a>'>>, 'LEAD': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Lead">sqlglot.expressions.Lead</a>'>>, 'LEAST': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Least">sqlglot.expressions.Least</a>'>>, 'LEFT': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Left">sqlglot.expressions.Left</a>'>>, 'LENGTH': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Length">sqlglot.expressions.Length</a>'>>, 'LEN': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Length">sqlglot.expressions.Length</a>'>>, 'LEVENSHTEIN': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Levenshtein">sqlglot.expressions.Levenshtein</a>'>>, 'LN': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Ln">sqlglot.expressions.Ln</a>'>>, 'LOG': <function build_logarithm>, 'LOGICAL_AND': <bound method Func.from_arg_list of <class '<a href="../expressions.html#LogicalAnd">sqlglot.expressions.LogicalAnd</a>'>>, 'BOOL_AND': <bound method Func.from_arg_list of <class '<a href="../expressions.html#LogicalAnd">sqlglot.expressions.LogicalAnd</a>'>>, 'BOOLAND_AGG': <bound method Func.from_arg_list of <class '<a href="../expressions.html#LogicalAnd">sqlglot.expressions.LogicalAnd</a>'>>, 'LOGICAL_OR': <bound method Func.from_arg_list of <class '<a href="../expressions.html#LogicalOr">sqlglot.expressions.LogicalOr</a>'>>, 'BOOL_OR': <bound method Func.from_arg_list of <class '<a href="../expressions.html#LogicalOr">sqlglot.expressions.LogicalOr</a>'>>, 'BOOLOR_AGG': <bound method Func.from_arg_list of <class '<a href="../expressions.html#LogicalOr">sqlglot.expressions.LogicalOr</a>'>>, 'LOWER': <function build_lower>, 'LCASE': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Lower">sqlglot.expressions.Lower</a>'>>, 'LOWER_HEX': <bound method Func.from_arg_list of <class '<a href="../expressions.html#LowerHex">sqlglot.expressions.LowerHex</a>'>>, 'MD5': <bound method Func.from_arg_list of <class '<a href="../expressions.html#MD5">sqlglot.expressions.MD5</a>'>>, 'MD5_DIGEST': <bound method Func.from_arg_list of <class '<a href="../expressions.html#MD5Digest">sqlglot.expressions.MD5Digest</a>'>>, 'MAP': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Map">sqlglot.expressions.Map</a>'>>, 'MAP_FROM_ENTRIES': <bound method Func.from_arg_list of <class '<a href="../expressions.html#MapFromEntries">sqlglot.expressions.MapFromEntries</a>'>>, 'MATCH_AGAINST': <bound method Func.from_arg_list of <class '<a href="../expressions.html#MatchAgainst">sqlglot.expressions.MatchAgainst</a>'>>, 'MAX': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Max">sqlglot.expressions.Max</a>'>>, 'MIN': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Min">sqlglot.expressions.Min</a>'>>, 'MONTH': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Month">sqlglot.expressions.Month</a>'>>, 'MONTHS_BETWEEN': <bound method Func.from_arg_list of <class '<a href="../expressions.html#MonthsBetween">sqlglot.expressions.MonthsBetween</a>'>>, 'NEXT_VALUE_FOR': <bound method Func.from_arg_list of <class '<a href="../expressions.html#NextValueFor">sqlglot.expressions.NextValueFor</a>'>>, 'NTH_VALUE': <bound method Func.from_arg_list of <class '<a href="../expressions.html#NthValue">sqlglot.expressions.NthValue</a>'>>, 'NULLIF': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Nullif">sqlglot.expressions.Nullif</a>'>>, 'NUMBER_TO_STR': <bound method Func.from_arg_list of <class '<a href="../expressions.html#NumberToStr">sqlglot.expressions.NumberToStr</a>'>>, 'NVL2': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Nvl2">sqlglot.expressions.Nvl2</a>'>>, 'OPEN_J_S_O_N': <bound method Func.from_arg_list of <class '<a href="../expressions.html#OpenJSON">sqlglot.expressions.OpenJSON</a>'>>, 'PARAMETERIZED_AGG': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ParameterizedAgg">sqlglot.expressions.ParameterizedAgg</a>'>>, 'PARSE_JSON': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ParseJSON">sqlglot.expressions.ParseJSON</a>'>>, 'JSON_PARSE': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ParseJSON">sqlglot.expressions.ParseJSON</a>'>>, 'PERCENTILE_CONT': <bound method Func.from_arg_list of <class '<a href="../expressions.html#PercentileCont">sqlglot.expressions.PercentileCont</a>'>>, 'PERCENTILE_DISC': <bound method Func.from_arg_list of <class '<a href="../expressions.html#PercentileDisc">sqlglot.expressions.PercentileDisc</a>'>>, 'POSEXPLODE': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Posexplode">sqlglot.expressions.Posexplode</a>'>>, 'POSEXPLODE_OUTER': <bound method Func.from_arg_list of <class '<a href="../expressions.html#PosexplodeOuter">sqlglot.expressions.PosexplodeOuter</a>'>>, 'POWER': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Pow">sqlglot.expressions.Pow</a>'>>, 'POW': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Pow">sqlglot.expressions.Pow</a>'>>, 'PREDICT': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Predict">sqlglot.expressions.Predict</a>'>>, 'QUANTILE': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Quantile">sqlglot.expressions.Quantile</a>'>>, 'QUARTER': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Quarter">sqlglot.expressions.Quarter</a>'>>, 'RAND': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Rand">sqlglot.expressions.Rand</a>'>>, 'RANDOM': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Rand">sqlglot.expressions.Rand</a>'>>, 'RANDN': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Randn">sqlglot.expressions.Randn</a>'>>, 'RANGE_N': <bound method Func.from_arg_list of <class '<a href="../expressions.html#RangeN">sqlglot.expressions.RangeN</a>'>>, 'READ_CSV': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ReadCSV">sqlglot.expressions.ReadCSV</a>'>>, 'REDUCE': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Reduce">sqlglot.expressions.Reduce</a>'>>, 'REGEXP_EXTRACT': <function <a href="#DuckDB.Parser">DuckDB.Parser</a>.<lambda>>, 'REGEXP_I_LIKE': <bound method Func.from_arg_list of <class '<a href="../expressions.html#RegexpILike">sqlglot.expressions.RegexpILike</a>'>>, 'REGEXP_LIKE': <bound method Func.from_arg_list of <class '<a href="../expressions.html#RegexpLike">sqlglot.expressions.RegexpLike</a>'>>, 'REGEXP_REPLACE': <function <a href="#DuckDB.Parser">DuckDB.Parser</a>.<lambda>>, 'REGEXP_SPLIT': <bound method Func.from_arg_list of <class '<a href="../expressions.html#RegexpSplit">sqlglot.expressions.RegexpSplit</a>'>>, 'REPEAT': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Repeat">sqlglot.expressions.Repeat</a>'>>, 'RIGHT': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Right">sqlglot.expressions.Right</a>'>>, 'ROUND': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Round">sqlglot.expressions.Round</a>'>>, 'ROW_NUMBER': <bound method Func.from_arg_list of <class '<a href="../expressions.html#RowNumber">sqlglot.expressions.RowNumber</a>'>>, 'SHA': <bound method Func.from_arg_list of <class '<a href="../expressions.html#SHA">sqlglot.expressions.SHA</a>'>>, 'SHA1': <bound method Func.from_arg_list of <class '<a href="../expressions.html#SHA">sqlglot.expressions.SHA</a>'>>, 'SHA2': <bound method Func.from_arg_list of <class '<a href="../expressions.html#SHA2">sqlglot.expressions.SHA2</a>'>>, 'SAFE_DIVIDE': <bound method Func.from_arg_list of <class '<a href="../expressions.html#SafeDivide">sqlglot.expressions.SafeDivide</a>'>>, 'SIGN': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Sign">sqlglot.expressions.Sign</a>'>>, 'SIGNUM': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Sign">sqlglot.expressions.Sign</a>'>>, 'SORT_ARRAY': <bound method Func.from_arg_list of <class '<a href="../expressions.html#SortArray">sqlglot.expressions.SortArray</a>'>>, 'SPLIT': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Split">sqlglot.expressions.Split</a>'>>, 'SQRT': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Sqrt">sqlglot.expressions.Sqrt</a>'>>, 'STANDARD_HASH': <bound method Func.from_arg_list of <class '<a href="../expressions.html#StandardHash">sqlglot.expressions.StandardHash</a>'>>, 'STAR_MAP': <bound method Func.from_arg_list of <class '<a href="../expressions.html#StarMap">sqlglot.expressions.StarMap</a>'>>, 'STARTS_WITH': <bound method Func.from_arg_list of <class '<a href="../expressions.html#StartsWith">sqlglot.expressions.StartsWith</a>'>>, 'STARTSWITH': <bound method Func.from_arg_list of <class '<a href="../expressions.html#StartsWith">sqlglot.expressions.StartsWith</a>'>>, 'STDDEV': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Stddev">sqlglot.expressions.Stddev</a>'>>, 'STDDEV_POP': <bound method Func.from_arg_list of <class '<a href="../expressions.html#StddevPop">sqlglot.expressions.StddevPop</a>'>>, 'STDDEV_SAMP': <bound method Func.from_arg_list of <class '<a href="../expressions.html#StddevSamp">sqlglot.expressions.StddevSamp</a>'>>, 'STR_POSITION': <bound method Func.from_arg_list of <class '<a href="../expressions.html#StrPosition">sqlglot.expressions.StrPosition</a>'>>, 'STR_TO_DATE': <bound method Func.from_arg_list of <class '<a href="../expressions.html#StrToDate">sqlglot.expressions.StrToDate</a>'>>, 'STR_TO_MAP': <bound method Func.from_arg_list of <class '<a href="../expressions.html#StrToMap">sqlglot.expressions.StrToMap</a>'>>, 'STR_TO_TIME': <bound method Func.from_arg_list of <class '<a href="../expressions.html#StrToTime">sqlglot.expressions.StrToTime</a>'>>, 'STR_TO_UNIX': <bound method Func.from_arg_list of <class '<a href="../expressions.html#StrToUnix">sqlglot.expressions.StrToUnix</a>'>>, 'STRING_TO_ARRAY': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Split">sqlglot.expressions.Split</a>'>>, 'SPLIT_BY_STRING': <bound method Func.from_arg_list of <class '<a href="../expressions.html#StringToArray">sqlglot.expressions.StringToArray</a>'>>, 'STRUCT': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Struct">sqlglot.expressions.Struct</a>'>>, 'STRUCT_EXTRACT': <bound method Func.from_arg_list of <class '<a href="../expressions.html#StructExtract">sqlglot.expressions.StructExtract</a>'>>, 'STUFF': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Stuff">sqlglot.expressions.Stuff</a>'>>, 'INSERT': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Stuff">sqlglot.expressions.Stuff</a>'>>, 'SUBSTRING': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Substring">sqlglot.expressions.Substring</a>'>>, 'SUM': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Sum">sqlglot.expressions.Sum</a>'>>, 'TIME_ADD': <bound method Func.from_arg_list of <class '<a href="../expressions.html#TimeAdd">sqlglot.expressions.TimeAdd</a>'>>, 'TIME_DIFF': <bound method Func.from_arg_list of <class '<a href="../expressions.html#TimeDiff">sqlglot.expressions.TimeDiff</a>'>>, 'TIME_FROM_PARTS': <bound method Func.from_arg_list of <class '<a href="../expressions.html#TimeFromParts">sqlglot.expressions.TimeFromParts</a>'>>, 'TIMEFROMPARTS': <bound method Func.from_arg_list of <class '<a href="../expressions.html#TimeFromParts">sqlglot.expressions.TimeFromParts</a>'>>, 'TIME_STR_TO_DATE': <bound method Func.from_arg_list of <class '<a href="../expressions.html#TimeStrToDate">sqlglot.expressions.TimeStrToDate</a>'>>, 'TIME_STR_TO_TIME': <bound method Func.from_arg_list of <class '<a href="../expressions.html#TimeStrToTime">sqlglot.expressions.TimeStrToTime</a>'>>, 'TIME_STR_TO_UNIX': <bound method Func.from_arg_list of <class '<a href="../expressions.html#TimeStrToUnix">sqlglot.expressions.TimeStrToUnix</a>'>>, 'TIME_SUB': <bound method Func.from_arg_list of <class '<a href="../expressions.html#TimeSub">sqlglot.expressions.TimeSub</a>'>>, 'TIME_TO_STR': <bound method Func.from_arg_list of <class '<a href="../expressions.html#TimeToStr">sqlglot.expressions.TimeToStr</a>'>>, 'TIME_TO_TIME_STR': <function Parser.<lambda>>, 'TIME_TO_UNIX': <bound method Func.from_arg_list of <class '<a href="../expressions.html#TimeToUnix">sqlglot.expressions.TimeToUnix</a>'>>, 'TIME_TRUNC': <bound method Func.from_arg_list of <class '<a href="../expressions.html#TimeTrunc">sqlglot.expressions.TimeTrunc</a>'>>, 'TIMESTAMP': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Timestamp">sqlglot.expressions.Timestamp</a>'>>, 'TIMESTAMP_ADD': <bound method Func.from_arg_list of <class '<a href="../expressions.html#TimestampAdd">sqlglot.expressions.TimestampAdd</a>'>>, 'TIMESTAMPDIFF': <bound method Func.from_arg_list of <class '<a href="../expressions.html#TimestampDiff">sqlglot.expressions.TimestampDiff</a>'>>, 'TIMESTAMP_DIFF': <bound method Func.from_arg_list of <class '<a href="../expressions.html#TimestampDiff">sqlglot.expressions.TimestampDiff</a>'>>, 'TIMESTAMP_FROM_PARTS': <bound method Func.from_arg_list of <class '<a href="../expressions.html#TimestampFromParts">sqlglot.expressions.TimestampFromParts</a>'>>, 'TIMESTAMPFROMPARTS': <bound method Func.from_arg_list of <class '<a href="../expressions.html#TimestampFromParts">sqlglot.expressions.TimestampFromParts</a>'>>, 'TIMESTAMP_SUB': <bound method Func.from_arg_list of <class '<a href="../expressions.html#TimestampSub">sqlglot.expressions.TimestampSub</a>'>>, 'TIMESTAMP_TRUNC': <bound method Func.from_arg_list of <class '<a href="../expressions.html#TimestampTrunc">sqlglot.expressions.TimestampTrunc</a>'>>, 'TO_ARRAY': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ToArray">sqlglot.expressions.ToArray</a>'>>, 'TO_BASE64': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ToBase64">sqlglot.expressions.ToBase64</a>'>>, 'TO_CHAR': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ToChar">sqlglot.expressions.ToChar</a>'>>, 'TO_DAYS': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ToDays">sqlglot.expressions.ToDays</a>'>>, 'TO_MAP': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ToMap">sqlglot.expressions.ToMap</a>'>>, 'TO_NUMBER': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ToNumber">sqlglot.expressions.ToNumber</a>'>>, 'TRANSFORM': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Transform">sqlglot.expressions.Transform</a>'>>, 'TRIM': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Trim">sqlglot.expressions.Trim</a>'>>, 'TRY': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Try">sqlglot.expressions.Try</a>'>>, 'TRY_CAST': <bound method Func.from_arg_list of <class '<a href="../expressions.html#TryCast">sqlglot.expressions.TryCast</a>'>>, 'TS_OR_DI_TO_DI': <bound method Func.from_arg_list of <class '<a href="../expressions.html#TsOrDiToDi">sqlglot.expressions.TsOrDiToDi</a>'>>, 'TS_OR_DS_ADD': <bound method Func.from_arg_list of <class '<a href="../expressions.html#TsOrDsAdd">sqlglot.expressions.TsOrDsAdd</a>'>>, 'TS_OR_DS_DIFF': <bound method Func.from_arg_list of <class '<a href="../expressions.html#TsOrDsDiff">sqlglot.expressions.TsOrDsDiff</a>'>>, 'TS_OR_DS_TO_DATE': <bound method Func.from_arg_list of <class '<a href="../expressions.html#TsOrDsToDate">sqlglot.expressions.TsOrDsToDate</a>'>>, 'TS_OR_DS_TO_DATE_STR': <function Parser.<lambda>>, 'TS_OR_DS_TO_TIME': <bound method Func.from_arg_list of <class '<a href="../expressions.html#TsOrDsToTime">sqlglot.expressions.TsOrDsToTime</a>'>>, 'TS_OR_DS_TO_TIMESTAMP': <bound method Func.from_arg_list of <class '<a href="../expressions.html#TsOrDsToTimestamp">sqlglot.expressions.TsOrDsToTimestamp</a>'>>, 'UNHEX': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Unhex">sqlglot.expressions.Unhex</a>'>>, 'UNIX_DATE': <bound method Func.from_arg_list of <class '<a href="../expressions.html#UnixDate">sqlglot.expressions.UnixDate</a>'>>, 'UNIX_TO_STR': <bound method Func.from_arg_list of <class '<a href="../expressions.html#UnixToStr">sqlglot.expressions.UnixToStr</a>'>>, 'UNIX_TO_TIME': <bound method Func.from_arg_list of <class '<a href="../expressions.html#UnixToTime">sqlglot.expressions.UnixToTime</a>'>>, 'UNIX_TO_TIME_STR': <bound method Func.from_arg_list of <class '<a href="../expressions.html#UnixToTimeStr">sqlglot.expressions.UnixToTimeStr</a>'>>, 'UPPER': <function build_upper>, 'UCASE': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Upper">sqlglot.expressions.Upper</a>'>>, 'VAR_MAP': <function build_var_map>, 'VARIANCE': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Variance">sqlglot.expressions.Variance</a>'>>, 'VARIANCE_SAMP': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Variance">sqlglot.expressions.Variance</a>'>>, 'VAR_SAMP': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Variance">sqlglot.expressions.Variance</a>'>>, 'VARIANCE_POP': <bound method Func.from_arg_list of <class '<a href="../expressions.html#VariancePop">sqlglot.expressions.VariancePop</a>'>>, 'VAR_POP': <bound method Func.from_arg_list of <class '<a href="../expressions.html#VariancePop">sqlglot.expressions.VariancePop</a>'>>, 'WEEK': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Week">sqlglot.expressions.Week</a>'>>, 'WEEK_OF_YEAR': <bound method Func.from_arg_list of <class '<a href="../expressions.html#WeekOfYear">sqlglot.expressions.WeekOfYear</a>'>>, 'WEEKOFYEAR': <bound method Func.from_arg_list of <class '<a href="../expressions.html#WeekOfYear">sqlglot.expressions.WeekOfYear</a>'>>, 'WHEN': <bound method Func.from_arg_list of <class '<a href="../expressions.html#When">sqlglot.expressions.When</a>'>>, 'X_M_L_TABLE': <bound method Func.from_arg_list of <class '<a href="../expressions.html#XMLTable">sqlglot.expressions.XMLTable</a>'>>, 'XOR': <function binary_from_function.<locals>.<lambda>>, 'YEAR': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Year">sqlglot.expressions.Year</a>'>>, 'GLOB': <function Parser.<lambda>>, 'JSON_EXTRACT_PATH_TEXT': <function build_extract_json_with_path.<locals>._builder>, 'LIKE': <function build_like>, 'LOG2': <function Parser.<lambda>>, 'LOG10': <function Parser.<lambda>>, 'MOD': <function build_mod>, 'TO_HEX': <function build_hex>, 'ARRAY_REVERSE_SORT': <function _build_sort_array_desc>, 'DATETRUNC': <function date_trunc_to_time>, 'EPOCH': <bound method Func.from_arg_list of <class '<a href="../expressions.html#TimeToUnix">sqlglot.expressions.TimeToUnix</a>'>>, 'EPOCH_MS': <function <a href="#DuckDB.Parser">DuckDB.Parser</a>.<lambda>>, 'JSON': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ParseJSON">sqlglot.expressions.ParseJSON</a>'>>, 'JSON_EXTRACT_PATH': <function build_extract_json_with_path.<locals>._builder>, 'JSON_EXTRACT_STRING': <function build_extract_json_with_path.<locals>._builder>, 'LIST_HAS': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ArrayContains">sqlglot.expressions.ArrayContains</a>'>>, 'LIST_REVERSE_SORT': <function _build_sort_array_desc>, 'LIST_SORT': <bound method Func.from_arg_list of <class '<a href="../expressions.html#SortArray">sqlglot.expressions.SortArray</a>'>>, 'LIST_VALUE': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Array">sqlglot.expressions.Array</a>'>>, 'MAKE_TIME': <bound method Func.from_arg_list of <class '<a href="../expressions.html#TimeFromParts">sqlglot.expressions.TimeFromParts</a>'>>, 'MAKE_TIMESTAMP': <function _build_make_timestamp>, 'MEDIAN': <function <a href="#DuckDB.Parser">DuckDB.Parser</a>.<lambda>>, 'QUANTILE_CONT': <bound method Func.from_arg_list of <class '<a href="../expressions.html#PercentileCont">sqlglot.expressions.PercentileCont</a>'>>, 'QUANTILE_DISC': <bound method Func.from_arg_list of <class '<a href="../expressions.html#PercentileDisc">sqlglot.expressions.PercentileDisc</a>'>>, 'REGEXP_MATCHES': <bound method Func.from_arg_list of <class '<a href="../expressions.html#RegexpLike">sqlglot.expressions.RegexpLike</a>'>>, 'STRFTIME': <function build_formatted_time.<locals>._builder>, 'STRING_SPLIT': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Split">sqlglot.expressions.Split</a>'>>, 'STRING_SPLIT_REGEX': <bound method Func.from_arg_list of <class '<a href="../expressions.html#RegexpSplit">sqlglot.expressions.RegexpSplit</a>'>>, 'STRPTIME': <function build_formatted_time.<locals>._builder>, 'STRUCT_PACK': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Struct">sqlglot.expressions.Struct</a>'>>, 'STR_SPLIT': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Split">sqlglot.expressions.Split</a>'>>, 'STR_SPLIT_REGEX': <bound method Func.from_arg_list of <class '<a href="../expressions.html#RegexpSplit">sqlglot.expressions.RegexpSplit</a>'>>, 'TO_TIMESTAMP': <bound method Func.from_arg_list of <class '<a href="../expressions.html#UnixToTime">sqlglot.expressions.UnixToTime</a>'>>, 'UNNEST': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Explode">sqlglot.expressions.Explode</a>'>>, 'RANGE': <function _build_generate_series.<locals>._builder>}</span> + <label class="view-value-button pdoc-button" for="DuckDB.Parser.FUNCTIONS-view-value"></label><span class="default_value">{'ABS': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Abs">sqlglot.expressions.Abs</a>'>>, 'ADD_MONTHS': <bound method Func.from_arg_list of <class '<a href="../expressions.html#AddMonths">sqlglot.expressions.AddMonths</a>'>>, 'ANONYMOUS_AGG_FUNC': <bound method Func.from_arg_list of <class '<a href="../expressions.html#AnonymousAggFunc">sqlglot.expressions.AnonymousAggFunc</a>'>>, 'ANY_VALUE': <bound method Func.from_arg_list of <class '<a href="../expressions.html#AnyValue">sqlglot.expressions.AnyValue</a>'>>, 'APPROX_DISTINCT': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ApproxDistinct">sqlglot.expressions.ApproxDistinct</a>'>>, 'APPROX_COUNT_DISTINCT': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ApproxDistinct">sqlglot.expressions.ApproxDistinct</a>'>>, 'APPROX_QUANTILE': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ApproxQuantile">sqlglot.expressions.ApproxQuantile</a>'>>, 'APPROX_TOP_K': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ApproxTopK">sqlglot.expressions.ApproxTopK</a>'>>, 'ARG_MAX': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ArgMax">sqlglot.expressions.ArgMax</a>'>>, 'ARGMAX': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ArgMax">sqlglot.expressions.ArgMax</a>'>>, 'MAX_BY': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ArgMax">sqlglot.expressions.ArgMax</a>'>>, 'ARG_MIN': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ArgMin">sqlglot.expressions.ArgMin</a>'>>, 'ARGMIN': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ArgMin">sqlglot.expressions.ArgMin</a>'>>, 'MIN_BY': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ArgMin">sqlglot.expressions.ArgMin</a>'>>, 'ARRAY': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Array">sqlglot.expressions.Array</a>'>>, 'ARRAY_AGG': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ArrayAgg">sqlglot.expressions.ArrayAgg</a>'>>, 'ARRAY_ALL': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ArrayAll">sqlglot.expressions.ArrayAll</a>'>>, 'ARRAY_ANY': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ArrayAny">sqlglot.expressions.ArrayAny</a>'>>, 'ARRAY_CONCAT': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ArrayConcat">sqlglot.expressions.ArrayConcat</a>'>>, 'ARRAY_CAT': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ArrayConcat">sqlglot.expressions.ArrayConcat</a>'>>, 'ARRAY_CONSTRUCT_COMPACT': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ArrayConstructCompact">sqlglot.expressions.ArrayConstructCompact</a>'>>, 'ARRAY_CONTAINS': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ArrayContains">sqlglot.expressions.ArrayContains</a>'>>, 'ARRAY_HAS': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ArrayContains">sqlglot.expressions.ArrayContains</a>'>>, 'ARRAY_CONTAINS_ALL': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ArrayContainsAll">sqlglot.expressions.ArrayContainsAll</a>'>>, 'ARRAY_HAS_ALL': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ArrayContainsAll">sqlglot.expressions.ArrayContainsAll</a>'>>, 'FILTER': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ArrayFilter">sqlglot.expressions.ArrayFilter</a>'>>, 'ARRAY_FILTER': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ArrayFilter">sqlglot.expressions.ArrayFilter</a>'>>, 'ARRAY_OVERLAPS': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ArrayOverlaps">sqlglot.expressions.ArrayOverlaps</a>'>>, 'ARRAY_SIZE': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ArraySize">sqlglot.expressions.ArraySize</a>'>>, 'ARRAY_LENGTH': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ArraySize">sqlglot.expressions.ArraySize</a>'>>, 'ARRAY_SORT': <bound method Func.from_arg_list of <class '<a href="../expressions.html#SortArray">sqlglot.expressions.SortArray</a>'>>, 'ARRAY_SUM': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ArraySum">sqlglot.expressions.ArraySum</a>'>>, 'ARRAY_TO_STRING': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ArrayToString">sqlglot.expressions.ArrayToString</a>'>>, 'ARRAY_JOIN': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ArrayToString">sqlglot.expressions.ArrayToString</a>'>>, 'ARRAY_UNION_AGG': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ArrayUnionAgg">sqlglot.expressions.ArrayUnionAgg</a>'>>, 'ARRAY_UNIQUE_AGG': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ArrayUniqueAgg">sqlglot.expressions.ArrayUniqueAgg</a>'>>, 'AVG': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Avg">sqlglot.expressions.Avg</a>'>>, 'CASE': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Case">sqlglot.expressions.Case</a>'>>, 'CAST': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Cast">sqlglot.expressions.Cast</a>'>>, 'CAST_TO_STR_TYPE': <bound method Func.from_arg_list of <class '<a href="../expressions.html#CastToStrType">sqlglot.expressions.CastToStrType</a>'>>, 'CBRT': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Cbrt">sqlglot.expressions.Cbrt</a>'>>, 'CEIL': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Ceil">sqlglot.expressions.Ceil</a>'>>, 'CEILING': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Ceil">sqlglot.expressions.Ceil</a>'>>, 'CHR': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Chr">sqlglot.expressions.Chr</a>'>>, 'CHAR': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Chr">sqlglot.expressions.Chr</a>'>>, 'COALESCE': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Coalesce">sqlglot.expressions.Coalesce</a>'>>, 'IFNULL': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Coalesce">sqlglot.expressions.Coalesce</a>'>>, 'NVL': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Coalesce">sqlglot.expressions.Coalesce</a>'>>, 'COLLATE': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Collate">sqlglot.expressions.Collate</a>'>>, 'COMBINED_AGG_FUNC': <bound method Func.from_arg_list of <class '<a href="../expressions.html#CombinedAggFunc">sqlglot.expressions.CombinedAggFunc</a>'>>, 'COMBINED_PARAMETERIZED_AGG': <bound method Func.from_arg_list of <class '<a href="../expressions.html#CombinedParameterizedAgg">sqlglot.expressions.CombinedParameterizedAgg</a>'>>, 'CONCAT': <function Parser.<lambda>>, 'CONCAT_WS': <function Parser.<lambda>>, 'CONNECT_BY_ROOT': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ConnectByRoot">sqlglot.expressions.ConnectByRoot</a>'>>, 'CONVERT': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Convert">sqlglot.expressions.Convert</a>'>>, 'CORR': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Corr">sqlglot.expressions.Corr</a>'>>, 'COUNT': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Count">sqlglot.expressions.Count</a>'>>, 'COUNT_IF': <bound method Func.from_arg_list of <class '<a href="../expressions.html#CountIf">sqlglot.expressions.CountIf</a>'>>, 'COUNTIF': <bound method Func.from_arg_list of <class '<a href="../expressions.html#CountIf">sqlglot.expressions.CountIf</a>'>>, 'COVAR_POP': <bound method Func.from_arg_list of <class '<a href="../expressions.html#CovarPop">sqlglot.expressions.CovarPop</a>'>>, 'COVAR_SAMP': <bound method Func.from_arg_list of <class '<a href="../expressions.html#CovarSamp">sqlglot.expressions.CovarSamp</a>'>>, 'CURRENT_DATE': <bound method Func.from_arg_list of <class '<a href="../expressions.html#CurrentDate">sqlglot.expressions.CurrentDate</a>'>>, 'CURRENT_DATETIME': <bound method Func.from_arg_list of <class '<a href="../expressions.html#CurrentDatetime">sqlglot.expressions.CurrentDatetime</a>'>>, 'CURRENT_TIME': <bound method Func.from_arg_list of <class '<a href="../expressions.html#CurrentTime">sqlglot.expressions.CurrentTime</a>'>>, 'CURRENT_TIMESTAMP': <bound method Func.from_arg_list of <class '<a href="../expressions.html#CurrentTimestamp">sqlglot.expressions.CurrentTimestamp</a>'>>, 'CURRENT_USER': <bound method Func.from_arg_list of <class '<a href="../expressions.html#CurrentUser">sqlglot.expressions.CurrentUser</a>'>>, 'DATE': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Date">sqlglot.expressions.Date</a>'>>, 'DATE_ADD': <bound method Func.from_arg_list of <class '<a href="../expressions.html#DateAdd">sqlglot.expressions.DateAdd</a>'>>, 'DATEDIFF': <function _build_date_diff>, 'DATE_DIFF': <function _build_date_diff>, 'DATE_FROM_PARTS': <bound method Func.from_arg_list of <class '<a href="../expressions.html#DateFromParts">sqlglot.expressions.DateFromParts</a>'>>, 'DATEFROMPARTS': <bound method Func.from_arg_list of <class '<a href="../expressions.html#DateFromParts">sqlglot.expressions.DateFromParts</a>'>>, 'DATE_STR_TO_DATE': <bound method Func.from_arg_list of <class '<a href="../expressions.html#DateStrToDate">sqlglot.expressions.DateStrToDate</a>'>>, 'DATE_TO_DATE_STR': <function Parser.<lambda>>, 'DATE_TO_DI': <bound method Func.from_arg_list of <class '<a href="../expressions.html#DateToDi">sqlglot.expressions.DateToDi</a>'>>, 'DATE_TRUNC': <function date_trunc_to_time>, 'DATETIME_ADD': <bound method Func.from_arg_list of <class '<a href="../expressions.html#DatetimeAdd">sqlglot.expressions.DatetimeAdd</a>'>>, 'DATETIME_DIFF': <bound method Func.from_arg_list of <class '<a href="../expressions.html#DatetimeDiff">sqlglot.expressions.DatetimeDiff</a>'>>, 'DATETIME_SUB': <bound method Func.from_arg_list of <class '<a href="../expressions.html#DatetimeSub">sqlglot.expressions.DatetimeSub</a>'>>, 'DATETIME_TRUNC': <bound method Func.from_arg_list of <class '<a href="../expressions.html#DatetimeTrunc">sqlglot.expressions.DatetimeTrunc</a>'>>, 'DAY': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Day">sqlglot.expressions.Day</a>'>>, 'DAY_OF_MONTH': <bound method Func.from_arg_list of <class '<a href="../expressions.html#DayOfMonth">sqlglot.expressions.DayOfMonth</a>'>>, 'DAYOFMONTH': <bound method Func.from_arg_list of <class '<a href="../expressions.html#DayOfMonth">sqlglot.expressions.DayOfMonth</a>'>>, 'DAY_OF_WEEK': <bound method Func.from_arg_list of <class '<a href="../expressions.html#DayOfWeek">sqlglot.expressions.DayOfWeek</a>'>>, 'DAYOFWEEK': <bound method Func.from_arg_list of <class '<a href="../expressions.html#DayOfWeek">sqlglot.expressions.DayOfWeek</a>'>>, 'DAY_OF_YEAR': <bound method Func.from_arg_list of <class '<a href="../expressions.html#DayOfYear">sqlglot.expressions.DayOfYear</a>'>>, 'DAYOFYEAR': <bound method Func.from_arg_list of <class '<a href="../expressions.html#DayOfYear">sqlglot.expressions.DayOfYear</a>'>>, 'DECODE': <function <a href="#DuckDB.Parser">DuckDB.Parser</a>.<lambda>>, 'DI_TO_DATE': <bound method Func.from_arg_list of <class '<a href="../expressions.html#DiToDate">sqlglot.expressions.DiToDate</a>'>>, 'ENCODE': <function <a href="#DuckDB.Parser">DuckDB.Parser</a>.<lambda>>, 'EXP': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Exp">sqlglot.expressions.Exp</a>'>>, 'EXPLODE': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Explode">sqlglot.expressions.Explode</a>'>>, 'EXPLODE_OUTER': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ExplodeOuter">sqlglot.expressions.ExplodeOuter</a>'>>, 'EXTRACT': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Extract">sqlglot.expressions.Extract</a>'>>, 'FIRST': <bound method Func.from_arg_list of <class '<a href="../expressions.html#First">sqlglot.expressions.First</a>'>>, 'FIRST_VALUE': <bound method Func.from_arg_list of <class '<a href="../expressions.html#FirstValue">sqlglot.expressions.FirstValue</a>'>>, 'FLATTEN': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Flatten">sqlglot.expressions.Flatten</a>'>>, 'FLOOR': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Floor">sqlglot.expressions.Floor</a>'>>, 'FROM_BASE': <bound method Func.from_arg_list of <class '<a href="../expressions.html#FromBase">sqlglot.expressions.FromBase</a>'>>, 'FROM_BASE64': <bound method Func.from_arg_list of <class '<a href="../expressions.html#FromBase64">sqlglot.expressions.FromBase64</a>'>>, 'GAP_FILL': <bound method Func.from_arg_list of <class '<a href="../expressions.html#GapFill">sqlglot.expressions.GapFill</a>'>>, 'GENERATE_DATE_ARRAY': <bound method Func.from_arg_list of <class '<a href="../expressions.html#GenerateDateArray">sqlglot.expressions.GenerateDateArray</a>'>>, 'GENERATE_SERIES': <function _build_generate_series.<locals>._builder>, 'GREATEST': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Greatest">sqlglot.expressions.Greatest</a>'>>, 'GROUP_CONCAT': <bound method Func.from_arg_list of <class '<a href="../expressions.html#GroupConcat">sqlglot.expressions.GroupConcat</a>'>>, 'HEX': <function build_hex>, 'HLL': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Hll">sqlglot.expressions.Hll</a>'>>, 'IF': <bound method Func.from_arg_list of <class '<a href="../expressions.html#If">sqlglot.expressions.If</a>'>>, 'IIF': <bound method Func.from_arg_list of <class '<a href="../expressions.html#If">sqlglot.expressions.If</a>'>>, 'INITCAP': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Initcap">sqlglot.expressions.Initcap</a>'>>, 'IS_INF': <bound method Func.from_arg_list of <class '<a href="../expressions.html#IsInf">sqlglot.expressions.IsInf</a>'>>, 'ISINF': <bound method Func.from_arg_list of <class '<a href="../expressions.html#IsInf">sqlglot.expressions.IsInf</a>'>>, 'IS_NAN': <bound method Func.from_arg_list of <class '<a href="../expressions.html#IsNan">sqlglot.expressions.IsNan</a>'>>, 'ISNAN': <bound method Func.from_arg_list of <class '<a href="../expressions.html#IsNan">sqlglot.expressions.IsNan</a>'>>, 'J_S_O_N_ARRAY': <bound method Func.from_arg_list of <class '<a href="../expressions.html#JSONArray">sqlglot.expressions.JSONArray</a>'>>, 'J_S_O_N_ARRAY_AGG': <bound method Func.from_arg_list of <class '<a href="../expressions.html#JSONArrayAgg">sqlglot.expressions.JSONArrayAgg</a>'>>, 'JSON_ARRAY_CONTAINS': <bound method Func.from_arg_list of <class '<a href="../expressions.html#JSONArrayContains">sqlglot.expressions.JSONArrayContains</a>'>>, 'JSONB_EXTRACT': <bound method Func.from_arg_list of <class '<a href="../expressions.html#JSONBExtract">sqlglot.expressions.JSONBExtract</a>'>>, 'JSONB_EXTRACT_SCALAR': <bound method Func.from_arg_list of <class '<a href="../expressions.html#JSONBExtractScalar">sqlglot.expressions.JSONBExtractScalar</a>'>>, 'JSON_EXTRACT': <function build_extract_json_with_path.<locals>._builder>, 'JSON_EXTRACT_SCALAR': <function build_extract_json_with_path.<locals>._builder>, 'JSON_FORMAT': <bound method Func.from_arg_list of <class '<a href="../expressions.html#JSONFormat">sqlglot.expressions.JSONFormat</a>'>>, 'J_S_O_N_OBJECT': <bound method Func.from_arg_list of <class '<a href="../expressions.html#JSONObject">sqlglot.expressions.JSONObject</a>'>>, 'J_S_O_N_OBJECT_AGG': <bound method Func.from_arg_list of <class '<a href="../expressions.html#JSONObjectAgg">sqlglot.expressions.JSONObjectAgg</a>'>>, 'J_S_O_N_TABLE': <bound method Func.from_arg_list of <class '<a href="../expressions.html#JSONTable">sqlglot.expressions.JSONTable</a>'>>, 'LAG': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Lag">sqlglot.expressions.Lag</a>'>>, 'LAST': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Last">sqlglot.expressions.Last</a>'>>, 'LAST_DAY': <bound method Func.from_arg_list of <class '<a href="../expressions.html#LastDay">sqlglot.expressions.LastDay</a>'>>, 'LAST_DAY_OF_MONTH': <bound method Func.from_arg_list of <class '<a href="../expressions.html#LastDay">sqlglot.expressions.LastDay</a>'>>, 'LAST_VALUE': <bound method Func.from_arg_list of <class '<a href="../expressions.html#LastValue">sqlglot.expressions.LastValue</a>'>>, 'LEAD': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Lead">sqlglot.expressions.Lead</a>'>>, 'LEAST': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Least">sqlglot.expressions.Least</a>'>>, 'LEFT': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Left">sqlglot.expressions.Left</a>'>>, 'LENGTH': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Length">sqlglot.expressions.Length</a>'>>, 'LEN': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Length">sqlglot.expressions.Length</a>'>>, 'LEVENSHTEIN': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Levenshtein">sqlglot.expressions.Levenshtein</a>'>>, 'LN': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Ln">sqlglot.expressions.Ln</a>'>>, 'LOG': <function build_logarithm>, 'LOGICAL_AND': <bound method Func.from_arg_list of <class '<a href="../expressions.html#LogicalAnd">sqlglot.expressions.LogicalAnd</a>'>>, 'BOOL_AND': <bound method Func.from_arg_list of <class '<a href="../expressions.html#LogicalAnd">sqlglot.expressions.LogicalAnd</a>'>>, 'BOOLAND_AGG': <bound method Func.from_arg_list of <class '<a href="../expressions.html#LogicalAnd">sqlglot.expressions.LogicalAnd</a>'>>, 'LOGICAL_OR': <bound method Func.from_arg_list of <class '<a href="../expressions.html#LogicalOr">sqlglot.expressions.LogicalOr</a>'>>, 'BOOL_OR': <bound method Func.from_arg_list of <class '<a href="../expressions.html#LogicalOr">sqlglot.expressions.LogicalOr</a>'>>, 'BOOLOR_AGG': <bound method Func.from_arg_list of <class '<a href="../expressions.html#LogicalOr">sqlglot.expressions.LogicalOr</a>'>>, 'LOWER': <function build_lower>, 'LCASE': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Lower">sqlglot.expressions.Lower</a>'>>, 'LOWER_HEX': <bound method Func.from_arg_list of <class '<a href="../expressions.html#LowerHex">sqlglot.expressions.LowerHex</a>'>>, 'MD5': <bound method Func.from_arg_list of <class '<a href="../expressions.html#MD5">sqlglot.expressions.MD5</a>'>>, 'MD5_DIGEST': <bound method Func.from_arg_list of <class '<a href="../expressions.html#MD5Digest">sqlglot.expressions.MD5Digest</a>'>>, 'MAP': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Map">sqlglot.expressions.Map</a>'>>, 'MAP_FROM_ENTRIES': <bound method Func.from_arg_list of <class '<a href="../expressions.html#MapFromEntries">sqlglot.expressions.MapFromEntries</a>'>>, 'MATCH_AGAINST': <bound method Func.from_arg_list of <class '<a href="../expressions.html#MatchAgainst">sqlglot.expressions.MatchAgainst</a>'>>, 'MAX': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Max">sqlglot.expressions.Max</a>'>>, 'MIN': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Min">sqlglot.expressions.Min</a>'>>, 'MONTH': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Month">sqlglot.expressions.Month</a>'>>, 'MONTHS_BETWEEN': <bound method Func.from_arg_list of <class '<a href="../expressions.html#MonthsBetween">sqlglot.expressions.MonthsBetween</a>'>>, 'NEXT_VALUE_FOR': <bound method Func.from_arg_list of <class '<a href="../expressions.html#NextValueFor">sqlglot.expressions.NextValueFor</a>'>>, 'NTH_VALUE': <bound method Func.from_arg_list of <class '<a href="../expressions.html#NthValue">sqlglot.expressions.NthValue</a>'>>, 'NULLIF': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Nullif">sqlglot.expressions.Nullif</a>'>>, 'NUMBER_TO_STR': <bound method Func.from_arg_list of <class '<a href="../expressions.html#NumberToStr">sqlglot.expressions.NumberToStr</a>'>>, 'NVL2': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Nvl2">sqlglot.expressions.Nvl2</a>'>>, 'OPEN_J_S_O_N': <bound method Func.from_arg_list of <class '<a href="../expressions.html#OpenJSON">sqlglot.expressions.OpenJSON</a>'>>, 'PARAMETERIZED_AGG': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ParameterizedAgg">sqlglot.expressions.ParameterizedAgg</a>'>>, 'PARSE_JSON': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ParseJSON">sqlglot.expressions.ParseJSON</a>'>>, 'JSON_PARSE': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ParseJSON">sqlglot.expressions.ParseJSON</a>'>>, 'PERCENTILE_CONT': <bound method Func.from_arg_list of <class '<a href="../expressions.html#PercentileCont">sqlglot.expressions.PercentileCont</a>'>>, 'PERCENTILE_DISC': <bound method Func.from_arg_list of <class '<a href="../expressions.html#PercentileDisc">sqlglot.expressions.PercentileDisc</a>'>>, 'POSEXPLODE': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Posexplode">sqlglot.expressions.Posexplode</a>'>>, 'POSEXPLODE_OUTER': <bound method Func.from_arg_list of <class '<a href="../expressions.html#PosexplodeOuter">sqlglot.expressions.PosexplodeOuter</a>'>>, 'POWER': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Pow">sqlglot.expressions.Pow</a>'>>, 'POW': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Pow">sqlglot.expressions.Pow</a>'>>, 'PREDICT': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Predict">sqlglot.expressions.Predict</a>'>>, 'QUANTILE': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Quantile">sqlglot.expressions.Quantile</a>'>>, 'QUARTER': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Quarter">sqlglot.expressions.Quarter</a>'>>, 'RAND': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Rand">sqlglot.expressions.Rand</a>'>>, 'RANDOM': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Rand">sqlglot.expressions.Rand</a>'>>, 'RANDN': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Randn">sqlglot.expressions.Randn</a>'>>, 'RANGE_N': <bound method Func.from_arg_list of <class '<a href="../expressions.html#RangeN">sqlglot.expressions.RangeN</a>'>>, 'READ_CSV': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ReadCSV">sqlglot.expressions.ReadCSV</a>'>>, 'REDUCE': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Reduce">sqlglot.expressions.Reduce</a>'>>, 'REGEXP_EXTRACT': <function <a href="#DuckDB.Parser">DuckDB.Parser</a>.<lambda>>, 'REGEXP_I_LIKE': <bound method Func.from_arg_list of <class '<a href="../expressions.html#RegexpILike">sqlglot.expressions.RegexpILike</a>'>>, 'REGEXP_LIKE': <bound method Func.from_arg_list of <class '<a href="../expressions.html#RegexpLike">sqlglot.expressions.RegexpLike</a>'>>, 'REGEXP_REPLACE': <function <a href="#DuckDB.Parser">DuckDB.Parser</a>.<lambda>>, 'REGEXP_SPLIT': <bound method Func.from_arg_list of <class '<a href="../expressions.html#RegexpSplit">sqlglot.expressions.RegexpSplit</a>'>>, 'REPEAT': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Repeat">sqlglot.expressions.Repeat</a>'>>, 'RIGHT': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Right">sqlglot.expressions.Right</a>'>>, 'ROUND': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Round">sqlglot.expressions.Round</a>'>>, 'ROW_NUMBER': <bound method Func.from_arg_list of <class '<a href="../expressions.html#RowNumber">sqlglot.expressions.RowNumber</a>'>>, 'SHA': <bound method Func.from_arg_list of <class '<a href="../expressions.html#SHA">sqlglot.expressions.SHA</a>'>>, 'SHA1': <bound method Func.from_arg_list of <class '<a href="../expressions.html#SHA">sqlglot.expressions.SHA</a>'>>, 'SHA2': <bound method Func.from_arg_list of <class '<a href="../expressions.html#SHA2">sqlglot.expressions.SHA2</a>'>>, 'SAFE_DIVIDE': <bound method Func.from_arg_list of <class '<a href="../expressions.html#SafeDivide">sqlglot.expressions.SafeDivide</a>'>>, 'SIGN': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Sign">sqlglot.expressions.Sign</a>'>>, 'SIGNUM': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Sign">sqlglot.expressions.Sign</a>'>>, 'SORT_ARRAY': <bound method Func.from_arg_list of <class '<a href="../expressions.html#SortArray">sqlglot.expressions.SortArray</a>'>>, 'SPLIT': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Split">sqlglot.expressions.Split</a>'>>, 'SQRT': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Sqrt">sqlglot.expressions.Sqrt</a>'>>, 'STANDARD_HASH': <bound method Func.from_arg_list of <class '<a href="../expressions.html#StandardHash">sqlglot.expressions.StandardHash</a>'>>, 'STAR_MAP': <bound method Func.from_arg_list of <class '<a href="../expressions.html#StarMap">sqlglot.expressions.StarMap</a>'>>, 'STARTS_WITH': <bound method Func.from_arg_list of <class '<a href="../expressions.html#StartsWith">sqlglot.expressions.StartsWith</a>'>>, 'STARTSWITH': <bound method Func.from_arg_list of <class '<a href="../expressions.html#StartsWith">sqlglot.expressions.StartsWith</a>'>>, 'STDDEV': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Stddev">sqlglot.expressions.Stddev</a>'>>, 'STDDEV_POP': <bound method Func.from_arg_list of <class '<a href="../expressions.html#StddevPop">sqlglot.expressions.StddevPop</a>'>>, 'STDDEV_SAMP': <bound method Func.from_arg_list of <class '<a href="../expressions.html#StddevSamp">sqlglot.expressions.StddevSamp</a>'>>, 'STR_POSITION': <bound method Func.from_arg_list of <class '<a href="../expressions.html#StrPosition">sqlglot.expressions.StrPosition</a>'>>, 'STR_TO_DATE': <bound method Func.from_arg_list of <class '<a href="../expressions.html#StrToDate">sqlglot.expressions.StrToDate</a>'>>, 'STR_TO_MAP': <bound method Func.from_arg_list of <class '<a href="../expressions.html#StrToMap">sqlglot.expressions.StrToMap</a>'>>, 'STR_TO_TIME': <bound method Func.from_arg_list of <class '<a href="../expressions.html#StrToTime">sqlglot.expressions.StrToTime</a>'>>, 'STR_TO_UNIX': <bound method Func.from_arg_list of <class '<a href="../expressions.html#StrToUnix">sqlglot.expressions.StrToUnix</a>'>>, 'STRING_TO_ARRAY': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Split">sqlglot.expressions.Split</a>'>>, 'SPLIT_BY_STRING': <bound method Func.from_arg_list of <class '<a href="../expressions.html#StringToArray">sqlglot.expressions.StringToArray</a>'>>, 'STRUCT': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Struct">sqlglot.expressions.Struct</a>'>>, 'STRUCT_EXTRACT': <bound method Func.from_arg_list of <class '<a href="../expressions.html#StructExtract">sqlglot.expressions.StructExtract</a>'>>, 'STUFF': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Stuff">sqlglot.expressions.Stuff</a>'>>, 'INSERT': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Stuff">sqlglot.expressions.Stuff</a>'>>, 'SUBSTRING': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Substring">sqlglot.expressions.Substring</a>'>>, 'SUM': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Sum">sqlglot.expressions.Sum</a>'>>, 'TIME_ADD': <bound method Func.from_arg_list of <class '<a href="../expressions.html#TimeAdd">sqlglot.expressions.TimeAdd</a>'>>, 'TIME_DIFF': <bound method Func.from_arg_list of <class '<a href="../expressions.html#TimeDiff">sqlglot.expressions.TimeDiff</a>'>>, 'TIME_FROM_PARTS': <bound method Func.from_arg_list of <class '<a href="../expressions.html#TimeFromParts">sqlglot.expressions.TimeFromParts</a>'>>, 'TIMEFROMPARTS': <bound method Func.from_arg_list of <class '<a href="../expressions.html#TimeFromParts">sqlglot.expressions.TimeFromParts</a>'>>, 'TIME_STR_TO_DATE': <bound method Func.from_arg_list of <class '<a href="../expressions.html#TimeStrToDate">sqlglot.expressions.TimeStrToDate</a>'>>, 'TIME_STR_TO_TIME': <bound method Func.from_arg_list of <class '<a href="../expressions.html#TimeStrToTime">sqlglot.expressions.TimeStrToTime</a>'>>, 'TIME_STR_TO_UNIX': <bound method Func.from_arg_list of <class '<a href="../expressions.html#TimeStrToUnix">sqlglot.expressions.TimeStrToUnix</a>'>>, 'TIME_SUB': <bound method Func.from_arg_list of <class '<a href="../expressions.html#TimeSub">sqlglot.expressions.TimeSub</a>'>>, 'TIME_TO_STR': <bound method Func.from_arg_list of <class '<a href="../expressions.html#TimeToStr">sqlglot.expressions.TimeToStr</a>'>>, 'TIME_TO_TIME_STR': <function Parser.<lambda>>, 'TIME_TO_UNIX': <bound method Func.from_arg_list of <class '<a href="../expressions.html#TimeToUnix">sqlglot.expressions.TimeToUnix</a>'>>, 'TIME_TRUNC': <bound method Func.from_arg_list of <class '<a href="../expressions.html#TimeTrunc">sqlglot.expressions.TimeTrunc</a>'>>, 'TIMESTAMP': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Timestamp">sqlglot.expressions.Timestamp</a>'>>, 'TIMESTAMP_ADD': <bound method Func.from_arg_list of <class '<a href="../expressions.html#TimestampAdd">sqlglot.expressions.TimestampAdd</a>'>>, 'TIMESTAMPDIFF': <bound method Func.from_arg_list of <class '<a href="../expressions.html#TimestampDiff">sqlglot.expressions.TimestampDiff</a>'>>, 'TIMESTAMP_DIFF': <bound method Func.from_arg_list of <class '<a href="../expressions.html#TimestampDiff">sqlglot.expressions.TimestampDiff</a>'>>, 'TIMESTAMP_FROM_PARTS': <bound method Func.from_arg_list of <class '<a href="../expressions.html#TimestampFromParts">sqlglot.expressions.TimestampFromParts</a>'>>, 'TIMESTAMPFROMPARTS': <bound method Func.from_arg_list of <class '<a href="../expressions.html#TimestampFromParts">sqlglot.expressions.TimestampFromParts</a>'>>, 'TIMESTAMP_SUB': <bound method Func.from_arg_list of <class '<a href="../expressions.html#TimestampSub">sqlglot.expressions.TimestampSub</a>'>>, 'TIMESTAMP_TRUNC': <bound method Func.from_arg_list of <class '<a href="../expressions.html#TimestampTrunc">sqlglot.expressions.TimestampTrunc</a>'>>, 'TO_ARRAY': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ToArray">sqlglot.expressions.ToArray</a>'>>, 'TO_BASE64': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ToBase64">sqlglot.expressions.ToBase64</a>'>>, 'TO_CHAR': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ToChar">sqlglot.expressions.ToChar</a>'>>, 'TO_DAYS': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ToDays">sqlglot.expressions.ToDays</a>'>>, 'TO_MAP': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ToMap">sqlglot.expressions.ToMap</a>'>>, 'TO_NUMBER': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ToNumber">sqlglot.expressions.ToNumber</a>'>>, 'TRANSFORM': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Transform">sqlglot.expressions.Transform</a>'>>, 'TRIM': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Trim">sqlglot.expressions.Trim</a>'>>, 'TRY': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Try">sqlglot.expressions.Try</a>'>>, 'TRY_CAST': <bound method Func.from_arg_list of <class '<a href="../expressions.html#TryCast">sqlglot.expressions.TryCast</a>'>>, 'TS_OR_DI_TO_DI': <bound method Func.from_arg_list of <class '<a href="../expressions.html#TsOrDiToDi">sqlglot.expressions.TsOrDiToDi</a>'>>, 'TS_OR_DS_ADD': <bound method Func.from_arg_list of <class '<a href="../expressions.html#TsOrDsAdd">sqlglot.expressions.TsOrDsAdd</a>'>>, 'TS_OR_DS_DIFF': <bound method Func.from_arg_list of <class '<a href="../expressions.html#TsOrDsDiff">sqlglot.expressions.TsOrDsDiff</a>'>>, 'TS_OR_DS_TO_DATE': <bound method Func.from_arg_list of <class '<a href="../expressions.html#TsOrDsToDate">sqlglot.expressions.TsOrDsToDate</a>'>>, 'TS_OR_DS_TO_DATE_STR': <function Parser.<lambda>>, 'TS_OR_DS_TO_TIME': <bound method Func.from_arg_list of <class '<a href="../expressions.html#TsOrDsToTime">sqlglot.expressions.TsOrDsToTime</a>'>>, 'TS_OR_DS_TO_TIMESTAMP': <bound method Func.from_arg_list of <class '<a href="../expressions.html#TsOrDsToTimestamp">sqlglot.expressions.TsOrDsToTimestamp</a>'>>, 'UNHEX': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Unhex">sqlglot.expressions.Unhex</a>'>>, 'UNIX_DATE': <bound method Func.from_arg_list of <class '<a href="../expressions.html#UnixDate">sqlglot.expressions.UnixDate</a>'>>, 'UNIX_TO_STR': <bound method Func.from_arg_list of <class '<a href="../expressions.html#UnixToStr">sqlglot.expressions.UnixToStr</a>'>>, 'UNIX_TO_TIME': <bound method Func.from_arg_list of <class '<a href="../expressions.html#UnixToTime">sqlglot.expressions.UnixToTime</a>'>>, 'UNIX_TO_TIME_STR': <bound method Func.from_arg_list of <class '<a href="../expressions.html#UnixToTimeStr">sqlglot.expressions.UnixToTimeStr</a>'>>, 'UPPER': <function build_upper>, 'UCASE': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Upper">sqlglot.expressions.Upper</a>'>>, 'VAR_MAP': <function build_var_map>, 'VARIANCE': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Variance">sqlglot.expressions.Variance</a>'>>, 'VARIANCE_SAMP': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Variance">sqlglot.expressions.Variance</a>'>>, 'VAR_SAMP': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Variance">sqlglot.expressions.Variance</a>'>>, 'VARIANCE_POP': <bound method Func.from_arg_list of <class '<a href="../expressions.html#VariancePop">sqlglot.expressions.VariancePop</a>'>>, 'VAR_POP': <bound method Func.from_arg_list of <class '<a href="../expressions.html#VariancePop">sqlglot.expressions.VariancePop</a>'>>, 'WEEK': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Week">sqlglot.expressions.Week</a>'>>, 'WEEK_OF_YEAR': <bound method Func.from_arg_list of <class '<a href="../expressions.html#WeekOfYear">sqlglot.expressions.WeekOfYear</a>'>>, 'WEEKOFYEAR': <bound method Func.from_arg_list of <class '<a href="../expressions.html#WeekOfYear">sqlglot.expressions.WeekOfYear</a>'>>, 'WHEN': <bound method Func.from_arg_list of <class '<a href="../expressions.html#When">sqlglot.expressions.When</a>'>>, 'X_M_L_TABLE': <bound method Func.from_arg_list of <class '<a href="../expressions.html#XMLTable">sqlglot.expressions.XMLTable</a>'>>, 'XOR': <function binary_from_function.<locals>.<lambda>>, 'YEAR': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Year">sqlglot.expressions.Year</a>'>>, 'GLOB': <function Parser.<lambda>>, 'JSON_EXTRACT_PATH_TEXT': <function build_extract_json_with_path.<locals>._builder>, 'LIKE': <function build_like>, 'LOG2': <function Parser.<lambda>>, 'LOG10': <function Parser.<lambda>>, 'MOD': <function build_mod>, 'TO_HEX': <function build_hex>, 'ARRAY_REVERSE_SORT': <function _build_sort_array_desc>, 'DATETRUNC': <function date_trunc_to_time>, 'EPOCH': <bound method Func.from_arg_list of <class '<a href="../expressions.html#TimeToUnix">sqlglot.expressions.TimeToUnix</a>'>>, 'EPOCH_MS': <function <a href="#DuckDB.Parser">DuckDB.Parser</a>.<lambda>>, 'JSON': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ParseJSON">sqlglot.expressions.ParseJSON</a>'>>, 'JSON_EXTRACT_PATH': <function build_extract_json_with_path.<locals>._builder>, 'JSON_EXTRACT_STRING': <function build_extract_json_with_path.<locals>._builder>, 'LIST_HAS': <bound method Func.from_arg_list of <class '<a href="../expressions.html#ArrayContains">sqlglot.expressions.ArrayContains</a>'>>, 'LIST_REVERSE_SORT': <function _build_sort_array_desc>, 'LIST_SORT': <bound method Func.from_arg_list of <class '<a href="../expressions.html#SortArray">sqlglot.expressions.SortArray</a>'>>, 'LIST_VALUE': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Array">sqlglot.expressions.Array</a>'>>, 'MAKE_TIME': <bound method Func.from_arg_list of <class '<a href="../expressions.html#TimeFromParts">sqlglot.expressions.TimeFromParts</a>'>>, 'MAKE_TIMESTAMP': <function _build_make_timestamp>, 'MEDIAN': <function <a href="#DuckDB.Parser">DuckDB.Parser</a>.<lambda>>, 'QUANTILE_CONT': <bound method Func.from_arg_list of <class '<a href="../expressions.html#PercentileCont">sqlglot.expressions.PercentileCont</a>'>>, 'QUANTILE_DISC': <bound method Func.from_arg_list of <class '<a href="../expressions.html#PercentileDisc">sqlglot.expressions.PercentileDisc</a>'>>, 'REGEXP_MATCHES': <bound method Func.from_arg_list of <class '<a href="../expressions.html#RegexpLike">sqlglot.expressions.RegexpLike</a>'>>, 'STRFTIME': <function build_formatted_time.<locals>._builder>, 'STRING_SPLIT': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Split">sqlglot.expressions.Split</a>'>>, 'STRING_SPLIT_REGEX': <bound method Func.from_arg_list of <class '<a href="../expressions.html#RegexpSplit">sqlglot.expressions.RegexpSplit</a>'>>, 'STRPTIME': <function build_formatted_time.<locals>._builder>, 'STRUCT_PACK': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Struct">sqlglot.expressions.Struct</a>'>>, 'STR_SPLIT': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Split">sqlglot.expressions.Split</a>'>>, 'STR_SPLIT_REGEX': <bound method Func.from_arg_list of <class '<a href="../expressions.html#RegexpSplit">sqlglot.expressions.RegexpSplit</a>'>>, 'TO_TIMESTAMP': <bound method Func.from_arg_list of <class '<a href="../expressions.html#UnixToTime">sqlglot.expressions.UnixToTime</a>'>>, 'UNNEST': <bound method Func.from_arg_list of <class '<a href="../expressions.html#Explode">sqlglot.expressions.Explode</a>'>>, 'RANGE': <function _build_generate_series.<locals>._builder>}</span> </div> @@ -2207,7 +2374,7 @@ Default: 3</li> <div class="attr variable"> <span class="name">FUNCTION_PARSERS</span> = <input id="DuckDB.Parser.FUNCTION_PARSERS-view-value" class="view-value-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1"> - <label class="view-value-button pdoc-button" for="DuckDB.Parser.FUNCTION_PARSERS-view-value"></label><span class="default_value">{'CAST': <function Parser.<lambda>>, 'CONVERT': <function Parser.<lambda>>, 'EXTRACT': <function Parser.<lambda>>, 'JSON_OBJECT': <function Parser.<lambda>>, 'JSON_OBJECTAGG': <function Parser.<lambda>>, 'JSON_TABLE': <function Parser.<lambda>>, 'MATCH': <function Parser.<lambda>>, 'OPENJSON': <function Parser.<lambda>>, 'POSITION': <function Parser.<lambda>>, 'PREDICT': <function Parser.<lambda>>, 'SAFE_CAST': <function Parser.<lambda>>, 'STRING_AGG': <function Parser.<lambda>>, 'SUBSTRING': <function Parser.<lambda>>, 'TRIM': <function Parser.<lambda>>, 'TRY_CAST': <function Parser.<lambda>>, 'TRY_CONVERT': <function Parser.<lambda>>}</span> + <label class="view-value-button pdoc-button" for="DuckDB.Parser.FUNCTION_PARSERS-view-value"></label><span class="default_value">{'CAST': <function Parser.<lambda>>, 'CONVERT': <function Parser.<lambda>>, 'EXTRACT': <function Parser.<lambda>>, 'GAP_FILL': <function Parser.<lambda>>, 'JSON_OBJECT': <function Parser.<lambda>>, 'JSON_OBJECTAGG': <function Parser.<lambda>>, 'JSON_TABLE': <function Parser.<lambda>>, 'MATCH': <function Parser.<lambda>>, 'OPENJSON': <function Parser.<lambda>>, 'POSITION': <function Parser.<lambda>>, 'PREDICT': <function Parser.<lambda>>, 'SAFE_CAST': <function Parser.<lambda>>, 'STRING_AGG': <function Parser.<lambda>>, 'SUBSTRING': <function Parser.<lambda>>, 'TRIM': <function Parser.<lambda>>, 'TRY_CAST': <function Parser.<lambda>>, 'TRY_CONVERT': <function Parser.<lambda>>}</span> </div> @@ -2233,7 +2400,7 @@ Default: 3</li> <div class="attr variable"> <span class="name">TABLE_ALIAS_TOKENS</span> = <input id="DuckDB.Parser.TABLE_ALIAS_TOKENS-view-value" class="view-value-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1"> - <label class="view-value-button pdoc-button" for="DuckDB.Parser.TABLE_ALIAS_TOKENS-view-value"></label><span class="default_value">{<TokenType.DATETIME64: 'DATETIME64'>, <TokenType.CASE: 'CASE'>, <TokenType.FUNCTION: 'FUNCTION'>, <TokenType.FILTER: 'FILTER'>, <TokenType.DATABASE: 'DATABASE'>, <TokenType.ANY: 'ANY'>, <TokenType.CURRENT_DATETIME: 'CURRENT_DATETIME'>, <TokenType.TRUNCATE: 'TRUNCATE'>, <TokenType.FOREIGN_KEY: 'FOREIGN_KEY'>, <TokenType.BOOLEAN: 'BOOLEAN'>, <TokenType.IS: 'IS'>, <TokenType.SUPER: 'SUPER'>, <TokenType.NUMRANGE: 'NUMRANGE'>, <TokenType.FIRST: 'FIRST'>, <TokenType.DATEMULTIRANGE: 'DATEMULTIRANGE'>, <TokenType.NESTED: 'NESTED'>, <TokenType.DESC: 'DESC'>, <TokenType.UINT: 'UINT'>, <TokenType.PSEUDO_TYPE: 'PSEUDO_TYPE'>, <TokenType.TINYBLOB: 'TINYBLOB'>, <TokenType.IPV4: 'IPV4'>, <TokenType.REPLACE: 'REPLACE'>, <TokenType.MONEY: 'MONEY'>, <TokenType.PARTITION: 'PARTITION'>, <TokenType.SHOW: 'SHOW'>, <TokenType.COLUMN: 'COLUMN'>, <TokenType.HLLSKETCH: 'HLLSKETCH'>, <TokenType.BPCHAR: 'BPCHAR'>, <TokenType.USMALLINT: 'USMALLINT'>, <TokenType.NVARCHAR: 'NVARCHAR'>, <TokenType.INTERVAL: 'INTERVAL'>, <TokenType.IDENTIFIER: 'IDENTIFIER'>, <TokenType.TABLE: 'TABLE'>, <TokenType.SEQUENCE: 'SEQUENCE'>, <TokenType.USE: 'USE'>, <TokenType.FORMAT: 'FORMAT'>, <TokenType.ESCAPE: 'ESCAPE'>, <TokenType.XML: 'XML'>, <TokenType.MEDIUMBLOB: 'MEDIUMBLOB'>, <TokenType.NULLABLE: 'NULLABLE'>, <TokenType.DECIMAL: 'DECIMAL'>, <TokenType.MAP: 'MAP'>, <TokenType.CONSTRAINT: 'CONSTRAINT'>, <TokenType.INT256: 'INT256'>, <TokenType.VIEW: 'VIEW'>, <TokenType.COMMENT: 'COMMENT'>, <TokenType.SCHEMA: 'SCHEMA'>, <TokenType.SMALLINT: 'SMALLINT'>, <TokenType.ENUM: 'ENUM'>, <TokenType.INT8RANGE: 'INT8RANGE'>, <TokenType.JSON: 'JSON'>, <TokenType.ROWVERSION: 'ROWVERSION'>, <TokenType.SIMPLEAGGREGATEFUNCTION: 'SIMPLEAGGREGATEFUNCTION'>, <TokenType.COPY: 'COPY'>, <TokenType.IPADDRESS: 'IPADDRESS'>, <TokenType.SERIAL: 'SERIAL'>, <TokenType.DESCRIBE: 'DESCRIBE'>, <TokenType.DATERANGE: 'DATERANGE'>, <TokenType.NEXT: 'NEXT'>, <TokenType.PROCEDURE: 'PROCEDURE'>, <TokenType.TOP: 'TOP'>, <TokenType.LOAD: 'LOAD'>, <TokenType.USERDEFINED: 'USERDEFINED'>, <TokenType.EXECUTE: 'EXECUTE'>, <TokenType.TDIGEST: 'TDIGEST'>, <TokenType.UNKNOWN: 'UNKNOWN'>, <TokenType.STRUCT: 'STRUCT'>, <TokenType.BIT: 'BIT'>, <TokenType.MEDIUMTEXT: 'MEDIUMTEXT'>, <TokenType.BINARY: 'BINARY'>, <TokenType.DATE32: 'DATE32'>, <TokenType.TSMULTIRANGE: 'TSMULTIRANGE'>, <TokenType.TSTZMULTIRANGE: 'TSTZMULTIRANGE'>, <TokenType.COMMIT: 'COMMIT'>, <TokenType.PIVOT: 'PIVOT'>, <TokenType.OPERATOR: 'OPERATOR'>, <TokenType.NUMMULTIRANGE: 'NUMMULTIRANGE'>, <TokenType.OBJECT: 'OBJECT'>, <TokenType.EXISTS: 'EXISTS'>, <TokenType.ENUM16: 'ENUM16'>, <TokenType.IMAGE: 'IMAGE'>, <TokenType.IPPREFIX: 'IPPREFIX'>, <TokenType.STORAGE_INTEGRATION: 'STORAGE_INTEGRATION'>, <TokenType.LONGBLOB: 'LONGBLOB'>, <TokenType.ALL: 'ALL'>, <TokenType.RANGE: 'RANGE'>, <TokenType.INT128: 'INT128'>, <TokenType.REFRESH: 'REFRESH'>, <TokenType.YEAR: 'YEAR'>, <TokenType.OVERLAPS: 'OVERLAPS'>, <TokenType.OBJECT_IDENTIFIER: 'OBJECT_IDENTIFIER'>, <TokenType.TIMESTAMP: 'TIMESTAMP'>, <TokenType.TIMESTAMP_MS: 'TIMESTAMP_MS'>, <TokenType.INT8MULTIRANGE: 'INT8MULTIRANGE'>, <TokenType.MEDIUMINT: 'MEDIUMINT'>, <TokenType.TINYINT: 'TINYINT'>, <TokenType.ROW: 'ROW'>, <TokenType.UINT256: 'UINT256'>, <TokenType.HSTORE: 'HSTORE'>, <TokenType.UTINYINT: 'UTINYINT'>, <TokenType.JSONB: 'JSONB'>, <TokenType.TSTZRANGE: 'TSTZRANGE'>, <TokenType.TIMESTAMP_S: 'TIMESTAMP_S'>, <TokenType.MODEL: 'MODEL'>, <TokenType.DEFAULT: 'DEFAULT'>, <TokenType.INDEX: 'INDEX'>, <TokenType.ARRAY: 'ARRAY'>, <TokenType.TIMESTAMPNTZ: 'TIMESTAMPNTZ'>, <TokenType.UMEDIUMINT: 'UMEDIUMINT'>, <TokenType.TRUE: 'TRUE'>, <TokenType.OVERWRITE: 'OVERWRITE'>, <TokenType.CHAR: 'CHAR'>, <TokenType.COLLATE: 'COLLATE'>, <TokenType.UPDATE: 'UPDATE'>, <TokenType.TAG: 'TAG'>, <TokenType.WAREHOUSE: 'WAREHOUSE'>, <TokenType.UNIQUE: 'UNIQUE'>, <TokenType.REFERENCES: 'REFERENCES'>, <TokenType.LOWCARDINALITY: 'LOWCARDINALITY'>, <TokenType.PERCENT: 'PERCENT'>, <TokenType.SET: 'SET'>, <TokenType.ROWS: 'ROWS'>, <TokenType.TEXT: 'TEXT'>, <TokenType.COMMAND: 'COMMAND'>, <TokenType.SMALLSERIAL: 'SMALLSERIAL'>, <TokenType.FINAL: 'FINAL'>, <TokenType.STREAMLIT: 'STREAMLIT'>, <TokenType.END: 'END'>, <TokenType.CURRENT_TIMESTAMP: 'CURRENT_TIMESTAMP'>, <TokenType.BIGINT: 'BIGINT'>, <TokenType.LONGTEXT: 'LONGTEXT'>, <TokenType.ORDINALITY: 'ORDINALITY'>, <TokenType.AGGREGATEFUNCTION: 'AGGREGATEFUNCTION'>, <TokenType.CURRENT_TIME: 'CURRENT_TIME'>, <TokenType.MERGE: 'MERGE'>, <TokenType.ISNULL: 'ISNULL'>, <TokenType.FALSE: 'FALSE'>, <TokenType.TINYTEXT: 'TINYTEXT'>, <TokenType.TIMETZ: 'TIMETZ'>, <TokenType.SETTINGS: 'SETTINGS'>, <TokenType.VOLATILE: 'VOLATILE'>, <TokenType.DOUBLE: 'DOUBLE'>, <TokenType.VARCHAR: 'VARCHAR'>, <TokenType.NULL: 'NULL'>, <TokenType.UBIGINT: 'UBIGINT'>, <TokenType.BEGIN: 'BEGIN'>, <TokenType.DATETIME: 'DATETIME'>, <TokenType.ROLLUP: 'ROLLUP'>, <TokenType.TSRANGE: 'TSRANGE'>, <TokenType.UUID: 'UUID'>, <TokenType.GEOGRAPHY: 'GEOGRAPHY'>, <TokenType.BIGSERIAL: 'BIGSERIAL'>, <TokenType.UINT128: 'UINT128'>, <TokenType.NAME: 'NAME'>, <TokenType.ASC: 'ASC'>, <TokenType.INT: 'INT'>, <TokenType.KEEP: 'KEEP'>, <TokenType.UNIQUEIDENTIFIER: 'UNIQUEIDENTIFIER'>, <TokenType.KILL: 'KILL'>, <TokenType.FLOAT: 'FLOAT'>, <TokenType.VARBINARY: 'VARBINARY'>, <TokenType.TIMESTAMPLTZ: 'TIMESTAMPLTZ'>, <TokenType.FIXEDSTRING: 'FIXEDSTRING'>, <TokenType.BIGDECIMAL: 'BIGDECIMAL'>, <TokenType.DATE: 'DATE'>, <TokenType.SOME: 'SOME'>, <TokenType.DELETE: 'DELETE'>, <TokenType.INT4MULTIRANGE: 'INT4MULTIRANGE'>, <TokenType.DIV: 'DIV'>, <TokenType.UDECIMAL: 'UDECIMAL'>, <TokenType.TIME: 'TIME'>, <TokenType.TIMESTAMPTZ: 'TIMESTAMPTZ'>, <TokenType.SMALLMONEY: 'SMALLMONEY'>, <TokenType.DICTIONARY: 'DICTIONARY'>, <TokenType.IPV6: 'IPV6'>, <TokenType.VAR: 'VAR'>, <TokenType.ENUM8: 'ENUM8'>, <TokenType.VARIANT: 'VARIANT'>, <TokenType.AUTO_INCREMENT: 'AUTO_INCREMENT'>, <TokenType.CURRENT_USER: 'CURRENT_USER'>, <TokenType.TIMESTAMP_NS: 'TIMESTAMP_NS'>, <TokenType.INET: 'INET'>, <TokenType.UNNEST: 'UNNEST'>, <TokenType.CURRENT_DATE: 'CURRENT_DATE'>, <TokenType.RECURSIVE: 'RECURSIVE'>, <TokenType.CACHE: 'CACHE'>, <TokenType.NCHAR: 'NCHAR'>, <TokenType.GEOMETRY: 'GEOMETRY'>, <TokenType.TEMPORARY: 'TEMPORARY'>, <TokenType.PRAGMA: 'PRAGMA'>, <TokenType.UNPIVOT: 'UNPIVOT'>, <TokenType.INT4RANGE: 'INT4RANGE'>}</span> + <label class="view-value-button pdoc-button" for="DuckDB.Parser.TABLE_ALIAS_TOKENS-view-value"></label><span class="default_value">{<TokenType.DEFAULT: 'DEFAULT'>, <TokenType.AUTO_INCREMENT: 'AUTO_INCREMENT'>, <TokenType.SHOW: 'SHOW'>, <TokenType.IMAGE: 'IMAGE'>, <TokenType.NESTED: 'NESTED'>, <TokenType.CHAR: 'CHAR'>, <TokenType.IPPREFIX: 'IPPREFIX'>, <TokenType.DIV: 'DIV'>, <TokenType.BEGIN: 'BEGIN'>, <TokenType.IPADDRESS: 'IPADDRESS'>, <TokenType.PERCENT: 'PERCENT'>, <TokenType.NCHAR: 'NCHAR'>, <TokenType.EXECUTE: 'EXECUTE'>, <TokenType.VOLATILE: 'VOLATILE'>, <TokenType.UNNEST: 'UNNEST'>, <TokenType.PSEUDO_TYPE: 'PSEUDO_TYPE'>, <TokenType.SUPER: 'SUPER'>, <TokenType.MONEY: 'MONEY'>, <TokenType.TRUE: 'TRUE'>, <TokenType.IPV6: 'IPV6'>, <TokenType.UPDATE: 'UPDATE'>, <TokenType.SEQUENCE: 'SEQUENCE'>, <TokenType.ENUM8: 'ENUM8'>, <TokenType.MODEL: 'MODEL'>, <TokenType.ASC: 'ASC'>, <TokenType.FALSE: 'FALSE'>, <TokenType.INET: 'INET'>, <TokenType.MEDIUMTEXT: 'MEDIUMTEXT'>, <TokenType.BIGSERIAL: 'BIGSERIAL'>, <TokenType.HLLSKETCH: 'HLLSKETCH'>, <TokenType.TIME: 'TIME'>, <TokenType.MAP: 'MAP'>, <TokenType.TIMESTAMP_MS: 'TIMESTAMP_MS'>, <TokenType.DECIMAL: 'DECIMAL'>, <TokenType.FOREIGN_KEY: 'FOREIGN_KEY'>, <TokenType.OBJECT_IDENTIFIER: 'OBJECT_IDENTIFIER'>, <TokenType.SOME: 'SOME'>, <TokenType.INT8RANGE: 'INT8RANGE'>, <TokenType.GEOGRAPHY: 'GEOGRAPHY'>, <TokenType.VARBINARY: 'VARBINARY'>, <TokenType.TIMESTAMPLTZ: 'TIMESTAMPLTZ'>, <TokenType.CURRENT_DATETIME: 'CURRENT_DATETIME'>, <TokenType.COLLATE: 'COLLATE'>, <TokenType.PROCEDURE: 'PROCEDURE'>, <TokenType.TSRANGE: 'TSRANGE'>, <TokenType.ENUM16: 'ENUM16'>, <TokenType.TIMESTAMPTZ: 'TIMESTAMPTZ'>, <TokenType.CASE: 'CASE'>, <TokenType.INT4MULTIRANGE: 'INT4MULTIRANGE'>, <TokenType.TSMULTIRANGE: 'TSMULTIRANGE'>, <TokenType.CURRENT_TIMESTAMP: 'CURRENT_TIMESTAMP'>, <TokenType.BINARY: 'BINARY'>, <TokenType.COMMIT: 'COMMIT'>, <TokenType.TIMESTAMP_S: 'TIMESTAMP_S'>, <TokenType.DICTIONARY: 'DICTIONARY'>, <TokenType.SMALLMONEY: 'SMALLMONEY'>, <TokenType.TIMESTAMP_NS: 'TIMESTAMP_NS'>, <TokenType.UINT: 'UINT'>, <TokenType.NUMMULTIRANGE: 'NUMMULTIRANGE'>, <TokenType.ALL: 'ALL'>, <TokenType.NVARCHAR: 'NVARCHAR'>, <TokenType.TINYTEXT: 'TINYTEXT'>, <TokenType.ENUM: 'ENUM'>, <TokenType.FILTER: 'FILTER'>, <TokenType.SCHEMA: 'SCHEMA'>, <TokenType.DOUBLE: 'DOUBLE'>, <TokenType.PIVOT: 'PIVOT'>, <TokenType.EXISTS: 'EXISTS'>, <TokenType.UDECIMAL: 'UDECIMAL'>, <TokenType.SMALLSERIAL: 'SMALLSERIAL'>, <TokenType.DATE: 'DATE'>, <TokenType.BOOLEAN: 'BOOLEAN'>, <TokenType.BPCHAR: 'BPCHAR'>, <TokenType.OVERWRITE: 'OVERWRITE'>, <TokenType.FORMAT: 'FORMAT'>, <TokenType.NULLABLE: 'NULLABLE'>, <TokenType.WAREHOUSE: 'WAREHOUSE'>, <TokenType.MEDIUMINT: 'MEDIUMINT'>, <TokenType.PARTITION: 'PARTITION'>, <TokenType.INT256: 'INT256'>, <TokenType.LOWCARDINALITY: 'LOWCARDINALITY'>, <TokenType.ESCAPE: 'ESCAPE'>, <TokenType.TINYBLOB: 'TINYBLOB'>, <TokenType.OPERATOR: 'OPERATOR'>, <TokenType.UINT256: 'UINT256'>, <TokenType.OVERLAPS: 'OVERLAPS'>, <TokenType.ISNULL: 'ISNULL'>, <TokenType.TOP: 'TOP'>, <TokenType.INT4RANGE: 'INT4RANGE'>, <TokenType.VARIANT: 'VARIANT'>, <TokenType.VAR: 'VAR'>, <TokenType.VIEW: 'VIEW'>, <TokenType.OBJECT: 'OBJECT'>, <TokenType.STORAGE_INTEGRATION: 'STORAGE_INTEGRATION'>, <TokenType.FIRST: 'FIRST'>, <TokenType.LONGTEXT: 'LONGTEXT'>, <TokenType.TSTZRANGE: 'TSTZRANGE'>, <TokenType.AGGREGATEFUNCTION: 'AGGREGATEFUNCTION'>, <TokenType.BIGINT: 'BIGINT'>, <TokenType.ARRAY: 'ARRAY'>, <TokenType.LOAD: 'LOAD'>, <TokenType.INDEX: 'INDEX'>, <TokenType.STRUCT: 'STRUCT'>, <TokenType.YEAR: 'YEAR'>, <TokenType.INTERVAL: 'INTERVAL'>, <TokenType.HSTORE: 'HSTORE'>, <TokenType.NAME: 'NAME'>, <TokenType.DATETIME: 'DATETIME'>, <TokenType.ANY: 'ANY'>, <TokenType.SERIAL: 'SERIAL'>, <TokenType.LONGBLOB: 'LONGBLOB'>, <TokenType.COLUMN: 'COLUMN'>, <TokenType.JSONB: 'JSONB'>, <TokenType.KEEP: 'KEEP'>, <TokenType.DESC: 'DESC'>, <TokenType.TEXT: 'TEXT'>, <TokenType.USERDEFINED: 'USERDEFINED'>, <TokenType.SETTINGS: 'SETTINGS'>, <TokenType.ROLLUP: 'ROLLUP'>, <TokenType.INT8MULTIRANGE: 'INT8MULTIRANGE'>, <TokenType.TDIGEST: 'TDIGEST'>, <TokenType.RECURSIVE: 'RECURSIVE'>, <TokenType.CURRENT_TIME: 'CURRENT_TIME'>, <TokenType.ORDINALITY: 'ORDINALITY'>, <TokenType.DESCRIBE: 'DESCRIBE'>, <TokenType.TINYINT: 'TINYINT'>, <TokenType.MEDIUMBLOB: 'MEDIUMBLOB'>, <TokenType.SIMPLEAGGREGATEFUNCTION: 'SIMPLEAGGREGATEFUNCTION'>, <TokenType.CACHE: 'CACHE'>, <TokenType.USE: 'USE'>, <TokenType.DATERANGE: 'DATERANGE'>, <TokenType.UBIGINT: 'UBIGINT'>, <TokenType.COPY: 'COPY'>, <TokenType.TIMESTAMP: 'TIMESTAMP'>, <TokenType.BIGDECIMAL: 'BIGDECIMAL'>, <TokenType.CONSTRAINT: 'CONSTRAINT'>, <TokenType.TSTZMULTIRANGE: 'TSTZMULTIRANGE'>, <TokenType.NEXT: 'NEXT'>, <TokenType.KILL: 'KILL'>, <TokenType.DATEMULTIRANGE: 'DATEMULTIRANGE'>, <TokenType.CURRENT_DATE: 'CURRENT_DATE'>, <TokenType.COMMENT: 'COMMENT'>, <TokenType.ROWS: 'ROWS'>, <TokenType.VARCHAR: 'VARCHAR'>, <TokenType.DATE32: 'DATE32'>, <TokenType.FIXEDSTRING: 'FIXEDSTRING'>, <TokenType.UNPIVOT: 'UNPIVOT'>, <TokenType.IDENTIFIER: 'IDENTIFIER'>, <TokenType.DATETIME64: 'DATETIME64'>, <TokenType.JSON: 'JSON'>, <TokenType.USMALLINT: 'USMALLINT'>, <TokenType.BIT: 'BIT'>, <TokenType.SET: 'SET'>, <TokenType.SMALLINT: 'SMALLINT'>, <TokenType.UINT128: 'UINT128'>, <TokenType.END: 'END'>, <TokenType.REPLACE: 'REPLACE'>, <TokenType.STREAMLIT: 'STREAMLIT'>, <TokenType.UNIQUE: 'UNIQUE'>, <TokenType.FUNCTION: 'FUNCTION'>, <TokenType.PRAGMA: 'PRAGMA'>, <TokenType.TIMETZ: 'TIMETZ'>, <TokenType.UNKNOWN: 'UNKNOWN'>, <TokenType.XML: 'XML'>, <TokenType.CURRENT_USER: 'CURRENT_USER'>, <TokenType.UUID: 'UUID'>, <TokenType.TRUNCATE: 'TRUNCATE'>, <TokenType.IPV4: 'IPV4'>, <TokenType.MERGE: 'MERGE'>, <TokenType.DELETE: 'DELETE'>, <TokenType.TABLE: 'TABLE'>, <TokenType.NUMRANGE: 'NUMRANGE'>, <TokenType.FINAL: 'FINAL'>, <TokenType.ROWVERSION: 'ROWVERSION'>, <TokenType.REFERENCES: 'REFERENCES'>, <TokenType.NULL: 'NULL'>, <TokenType.INT: 'INT'>, <TokenType.TEMPORARY: 'TEMPORARY'>, <TokenType.RANGE: 'RANGE'>, <TokenType.ROW: 'ROW'>, <TokenType.DATABASE: 'DATABASE'>, <TokenType.UTINYINT: 'UTINYINT'>, <TokenType.REFRESH: 'REFRESH'>, <TokenType.GEOMETRY: 'GEOMETRY'>, <TokenType.INT128: 'INT128'>, <TokenType.UMEDIUMINT: 'UMEDIUMINT'>, <TokenType.TAG: 'TAG'>, <TokenType.COMMAND: 'COMMAND'>, <TokenType.UNIQUEIDENTIFIER: 'UNIQUEIDENTIFIER'>, <TokenType.TIMESTAMPNTZ: 'TIMESTAMPNTZ'>, <TokenType.IS: 'IS'>, <TokenType.FLOAT: 'FLOAT'>}</span> </div> @@ -2315,6 +2482,8 @@ Default: 3</li> <dd id="DuckDB.Parser.TRIM_TYPES" class="variable"><a href="../parser.html#Parser.TRIM_TYPES">TRIM_TYPES</a></dd> <dd id="DuckDB.Parser.FUNC_TOKENS" class="variable"><a href="../parser.html#Parser.FUNC_TOKENS">FUNC_TOKENS</a></dd> <dd id="DuckDB.Parser.CONJUNCTION" class="variable"><a href="../parser.html#Parser.CONJUNCTION">CONJUNCTION</a></dd> + <dd id="DuckDB.Parser.ASSIGNMENT" class="variable"><a href="../parser.html#Parser.ASSIGNMENT">ASSIGNMENT</a></dd> + <dd id="DuckDB.Parser.DISJUNCTION" class="variable"><a href="../parser.html#Parser.DISJUNCTION">DISJUNCTION</a></dd> <dd id="DuckDB.Parser.EQUALITY" class="variable"><a href="../parser.html#Parser.EQUALITY">EQUALITY</a></dd> <dd id="DuckDB.Parser.COMPARISON" class="variable"><a href="../parser.html#Parser.COMPARISON">COMPARISON</a></dd> <dd id="DuckDB.Parser.TERM" class="variable"><a href="../parser.html#Parser.TERM">TERM</a></dd> @@ -2373,6 +2542,7 @@ Default: 3</li> <dd id="DuckDB.Parser.NULL_TOKENS" class="variable"><a href="../parser.html#Parser.NULL_TOKENS">NULL_TOKENS</a></dd> <dd id="DuckDB.Parser.UNNEST_OFFSET_ALIAS_TOKENS" class="variable"><a href="../parser.html#Parser.UNNEST_OFFSET_ALIAS_TOKENS">UNNEST_OFFSET_ALIAS_TOKENS</a></dd> <dd id="DuckDB.Parser.SELECT_START_TOKENS" class="variable"><a href="../parser.html#Parser.SELECT_START_TOKENS">SELECT_START_TOKENS</a></dd> + <dd id="DuckDB.Parser.COPY_INTO_VARLEN_OPTIONS" class="variable"><a href="../parser.html#Parser.COPY_INTO_VARLEN_OPTIONS">COPY_INTO_VARLEN_OPTIONS</a></dd> <dd id="DuckDB.Parser.STRICT_CAST" class="variable"><a href="../parser.html#Parser.STRICT_CAST">STRICT_CAST</a></dd> <dd id="DuckDB.Parser.PREFIXED_PIVOT_COLUMNS" class="variable"><a href="../parser.html#Parser.PREFIXED_PIVOT_COLUMNS">PREFIXED_PIVOT_COLUMNS</a></dd> <dd id="DuckDB.Parser.IDENTIFY_PIVOT_STRINGS" class="variable"><a href="../parser.html#Parser.IDENTIFY_PIVOT_STRINGS">IDENTIFY_PIVOT_STRINGS</a></dd> @@ -2572,145 +2742,227 @@ Default: 3</li> </span><span id="DuckDB.Generator-504"><a href="#DuckDB.Generator-504"><span class="linenos">504</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">VARBINARY</span><span class="p">:</span> <span class="s2">"BLOB"</span><span class="p">,</span> </span><span id="DuckDB.Generator-505"><a href="#DuckDB.Generator-505"><span class="linenos">505</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">ROWVERSION</span><span class="p">:</span> <span class="s2">"BLOB"</span><span class="p">,</span> </span><span id="DuckDB.Generator-506"><a href="#DuckDB.Generator-506"><span class="linenos">506</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">VARCHAR</span><span class="p">:</span> <span class="s2">"TEXT"</span><span class="p">,</span> -</span><span id="DuckDB.Generator-507"><a href="#DuckDB.Generator-507"><span class="linenos">507</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMP_S</span><span class="p">:</span> <span class="s2">"TIMESTAMP_S"</span><span class="p">,</span> -</span><span id="DuckDB.Generator-508"><a href="#DuckDB.Generator-508"><span class="linenos">508</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMP_MS</span><span class="p">:</span> <span class="s2">"TIMESTAMP_MS"</span><span class="p">,</span> -</span><span id="DuckDB.Generator-509"><a href="#DuckDB.Generator-509"><span class="linenos">509</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMP_NS</span><span class="p">:</span> <span class="s2">"TIMESTAMP_NS"</span><span class="p">,</span> -</span><span id="DuckDB.Generator-510"><a href="#DuckDB.Generator-510"><span class="linenos">510</span></a> <span class="p">}</span> -</span><span id="DuckDB.Generator-511"><a href="#DuckDB.Generator-511"><span class="linenos">511</span></a> -</span><span id="DuckDB.Generator-512"><a href="#DuckDB.Generator-512"><span class="linenos">512</span></a> <span class="n">UNWRAPPED_INTERVAL_VALUES</span> <span class="o">=</span> <span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Paren</span><span class="p">)</span> -</span><span id="DuckDB.Generator-513"><a href="#DuckDB.Generator-513"><span class="linenos">513</span></a> -</span><span id="DuckDB.Generator-514"><a href="#DuckDB.Generator-514"><span class="linenos">514</span></a> <span class="c1"># DuckDB doesn't generally support CREATE TABLE .. properties</span> -</span><span id="DuckDB.Generator-515"><a href="#DuckDB.Generator-515"><span class="linenos">515</span></a> <span class="c1"># https://duckdb.org/docs/sql/statements/create_table.html</span> -</span><span id="DuckDB.Generator-516"><a href="#DuckDB.Generator-516"><span class="linenos">516</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="DuckDB.Generator-517"><a href="#DuckDB.Generator-517"><span class="linenos">517</span></a> <span class="n">prop</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span> -</span><span id="DuckDB.Generator-518"><a href="#DuckDB.Generator-518"><span class="linenos">518</span></a> <span class="k">for</span> <span class="n">prop</span> <span class="ow">in</span> <span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">PROPERTIES_LOCATION</span> -</span><span id="DuckDB.Generator-519"><a href="#DuckDB.Generator-519"><span class="linenos">519</span></a> <span class="p">}</span> -</span><span id="DuckDB.Generator-520"><a href="#DuckDB.Generator-520"><span class="linenos">520</span></a> -</span><span id="DuckDB.Generator-521"><a href="#DuckDB.Generator-521"><span class="linenos">521</span></a> <span class="c1"># There are a few exceptions (e.g. temporary tables) which are supported or</span> -</span><span id="DuckDB.Generator-522"><a href="#DuckDB.Generator-522"><span class="linenos">522</span></a> <span class="c1"># can be transpiled to DuckDB, so we explicitly override them accordingly</span> -</span><span id="DuckDB.Generator-523"><a href="#DuckDB.Generator-523"><span class="linenos">523</span></a> <span class="n">PROPERTIES_LOCATION</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">LikeProperty</span><span class="p">]</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span> -</span><span id="DuckDB.Generator-524"><a href="#DuckDB.Generator-524"><span class="linenos">524</span></a> <span class="n">PROPERTIES_LOCATION</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">TemporaryProperty</span><span class="p">]</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span> -</span><span id="DuckDB.Generator-525"><a href="#DuckDB.Generator-525"><span class="linenos">525</span></a> -</span><span id="DuckDB.Generator-526"><a href="#DuckDB.Generator-526"><span class="linenos">526</span></a> <span class="k">def</span> <span class="nf">timefromparts_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TimeFromParts</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="DuckDB.Generator-527"><a href="#DuckDB.Generator-527"><span class="linenos">527</span></a> <span class="n">nano</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"nano"</span><span class="p">)</span> -</span><span id="DuckDB.Generator-528"><a href="#DuckDB.Generator-528"><span class="linenos">528</span></a> <span class="k">if</span> <span class="n">nano</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="DuckDB.Generator-529"><a href="#DuckDB.Generator-529"><span class="linenos">529</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> -</span><span id="DuckDB.Generator-530"><a href="#DuckDB.Generator-530"><span class="linenos">530</span></a> <span class="s2">"sec"</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"sec"</span><span class="p">]</span> <span class="o">+</span> <span class="n">nano</span><span class="o">.</span><span class="n">pop</span><span class="p">()</span> <span class="o">/</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">number</span><span class="p">(</span><span class="mf">1000000000.0</span><span class="p">)</span> -</span><span id="DuckDB.Generator-531"><a href="#DuckDB.Generator-531"><span class="linenos">531</span></a> <span class="p">)</span> -</span><span id="DuckDB.Generator-532"><a href="#DuckDB.Generator-532"><span class="linenos">532</span></a> -</span><span id="DuckDB.Generator-533"><a href="#DuckDB.Generator-533"><span class="linenos">533</span></a> <span class="k">return</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"MAKE_TIME"</span><span class="p">)(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> -</span><span id="DuckDB.Generator-534"><a href="#DuckDB.Generator-534"><span class="linenos">534</span></a> -</span><span id="DuckDB.Generator-535"><a href="#DuckDB.Generator-535"><span class="linenos">535</span></a> <span class="k">def</span> <span class="nf">timestampfromparts_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TimestampFromParts</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="DuckDB.Generator-536"><a href="#DuckDB.Generator-536"><span class="linenos">536</span></a> <span class="n">sec</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"sec"</span><span class="p">]</span> -</span><span id="DuckDB.Generator-537"><a href="#DuckDB.Generator-537"><span class="linenos">537</span></a> -</span><span id="DuckDB.Generator-538"><a href="#DuckDB.Generator-538"><span class="linenos">538</span></a> <span class="n">milli</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"milli"</span><span class="p">)</span> -</span><span id="DuckDB.Generator-539"><a href="#DuckDB.Generator-539"><span class="linenos">539</span></a> <span class="k">if</span> <span class="n">milli</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="DuckDB.Generator-540"><a href="#DuckDB.Generator-540"><span class="linenos">540</span></a> <span class="n">sec</span> <span class="o">+=</span> <span class="n">milli</span><span class="o">.</span><span class="n">pop</span><span class="p">()</span> <span class="o">/</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">number</span><span class="p">(</span><span class="mf">1000.0</span><span class="p">)</span> -</span><span id="DuckDB.Generator-541"><a href="#DuckDB.Generator-541"><span class="linenos">541</span></a> -</span><span id="DuckDB.Generator-542"><a href="#DuckDB.Generator-542"><span class="linenos">542</span></a> <span class="n">nano</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"nano"</span><span class="p">)</span> -</span><span id="DuckDB.Generator-543"><a href="#DuckDB.Generator-543"><span class="linenos">543</span></a> <span class="k">if</span> <span class="n">nano</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="DuckDB.Generator-544"><a href="#DuckDB.Generator-544"><span class="linenos">544</span></a> <span class="n">sec</span> <span class="o">+=</span> <span class="n">nano</span><span class="o">.</span><span class="n">pop</span><span class="p">()</span> <span class="o">/</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">number</span><span class="p">(</span><span class="mf">1000000000.0</span><span class="p">)</span> -</span><span id="DuckDB.Generator-545"><a href="#DuckDB.Generator-545"><span class="linenos">545</span></a> -</span><span id="DuckDB.Generator-546"><a href="#DuckDB.Generator-546"><span class="linenos">546</span></a> <span class="k">if</span> <span class="n">milli</span> <span class="ow">or</span> <span class="n">nano</span><span class="p">:</span> -</span><span id="DuckDB.Generator-547"><a href="#DuckDB.Generator-547"><span class="linenos">547</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"sec"</span><span class="p">,</span> <span class="n">sec</span><span class="p">)</span> -</span><span id="DuckDB.Generator-548"><a href="#DuckDB.Generator-548"><span class="linenos">548</span></a> -</span><span id="DuckDB.Generator-549"><a href="#DuckDB.Generator-549"><span class="linenos">549</span></a> <span class="k">return</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"MAKE_TIMESTAMP"</span><span class="p">)(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> -</span><span id="DuckDB.Generator-550"><a href="#DuckDB.Generator-550"><span class="linenos">550</span></a> -</span><span id="DuckDB.Generator-551"><a href="#DuckDB.Generator-551"><span class="linenos">551</span></a> <span class="k">def</span> <span class="nf">tablesample_sql</span><span class="p">(</span> -</span><span id="DuckDB.Generator-552"><a href="#DuckDB.Generator-552"><span class="linenos">552</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="DuckDB.Generator-553"><a href="#DuckDB.Generator-553"><span class="linenos">553</span></a> <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><span id="DuckDB.Generator-554"><a href="#DuckDB.Generator-554"><span class="linenos">554</span></a> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">" AS "</span><span class="p">,</span> -</span><span id="DuckDB.Generator-555"><a href="#DuckDB.Generator-555"><span class="linenos">555</span></a> <span class="n">tablesample_keyword</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="DuckDB.Generator-556"><a href="#DuckDB.Generator-556"><span class="linenos">556</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="DuckDB.Generator-557"><a href="#DuckDB.Generator-557"><span class="linenos">557</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">parent</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">):</span> -</span><span id="DuckDB.Generator-558"><a href="#DuckDB.Generator-558"><span class="linenos">558</span></a> <span class="c1"># This sample clause only applies to a single source, not the entire resulting relation</span> -</span><span id="DuckDB.Generator-559"><a href="#DuckDB.Generator-559"><span class="linenos">559</span></a> <span class="n">tablesample_keyword</span> <span class="o">=</span> <span class="s2">"TABLESAMPLE"</span> -</span><span id="DuckDB.Generator-560"><a href="#DuckDB.Generator-560"><span class="linenos">560</span></a> -</span><span id="DuckDB.Generator-561"><a href="#DuckDB.Generator-561"><span class="linenos">561</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">"size"</span><span class="p">):</span> -</span><span id="DuckDB.Generator-562"><a href="#DuckDB.Generator-562"><span class="linenos">562</span></a> <span class="n">method</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"method"</span><span class="p">)</span> -</span><span id="DuckDB.Generator-563"><a href="#DuckDB.Generator-563"><span class="linenos">563</span></a> <span class="k">if</span> <span class="n">method</span> <span class="ow">and</span> <span class="n">method</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> <span class="o">!=</span> <span class="s2">"RESERVOIR"</span><span class="p">:</span> -</span><span id="DuckDB.Generator-564"><a href="#DuckDB.Generator-564"><span class="linenos">564</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span> -</span><span id="DuckDB.Generator-565"><a href="#DuckDB.Generator-565"><span class="linenos">565</span></a> <span class="sa">f</span><span class="s2">"Sampling method </span><span class="si">{</span><span class="n">method</span><span class="si">}</span><span class="s2"> is not supported with a discrete sample count, "</span> -</span><span id="DuckDB.Generator-566"><a href="#DuckDB.Generator-566"><span class="linenos">566</span></a> <span class="s2">"defaulting to reservoir sampling"</span> -</span><span id="DuckDB.Generator-567"><a href="#DuckDB.Generator-567"><span class="linenos">567</span></a> <span class="p">)</span> -</span><span id="DuckDB.Generator-568"><a href="#DuckDB.Generator-568"><span class="linenos">568</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"method"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="s2">"RESERVOIR"</span><span class="p">))</span> -</span><span id="DuckDB.Generator-569"><a href="#DuckDB.Generator-569"><span class="linenos">569</span></a> -</span><span id="DuckDB.Generator-570"><a href="#DuckDB.Generator-570"><span class="linenos">570</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">tablesample_sql</span><span class="p">(</span> -</span><span id="DuckDB.Generator-571"><a href="#DuckDB.Generator-571"><span class="linenos">571</span></a> <span class="n">expression</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="n">sep</span><span class="p">,</span> <span class="n">tablesample_keyword</span><span class="o">=</span><span class="n">tablesample_keyword</span> -</span><span id="DuckDB.Generator-572"><a href="#DuckDB.Generator-572"><span class="linenos">572</span></a> <span class="p">)</span> -</span><span id="DuckDB.Generator-573"><a href="#DuckDB.Generator-573"><span class="linenos">573</span></a> -</span><span id="DuckDB.Generator-574"><a href="#DuckDB.Generator-574"><span class="linenos">574</span></a> <span class="k">def</span> <span class="nf">interval_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Interval</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="DuckDB.Generator-575"><a href="#DuckDB.Generator-575"><span class="linenos">575</span></a> <span class="n">multiplier</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">int</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="DuckDB.Generator-576"><a href="#DuckDB.Generator-576"><span class="linenos">576</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> -</span><span id="DuckDB.Generator-577"><a href="#DuckDB.Generator-577"><span class="linenos">577</span></a> -</span><span id="DuckDB.Generator-578"><a href="#DuckDB.Generator-578"><span class="linenos">578</span></a> <span class="k">if</span> <span class="n">unit</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"week"</span><span class="p">):</span> -</span><span id="DuckDB.Generator-579"><a href="#DuckDB.Generator-579"><span class="linenos">579</span></a> <span class="n">multiplier</span> <span class="o">=</span> <span class="mi">7</span> -</span><span id="DuckDB.Generator-580"><a href="#DuckDB.Generator-580"><span class="linenos">580</span></a> <span class="k">if</span> <span class="n">unit</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"quarter"</span><span class="p">):</span> -</span><span id="DuckDB.Generator-581"><a href="#DuckDB.Generator-581"><span class="linenos">581</span></a> <span class="n">multiplier</span> <span class="o">=</span> <span class="mi">90</span> -</span><span id="DuckDB.Generator-582"><a href="#DuckDB.Generator-582"><span class="linenos">582</span></a> -</span><span id="DuckDB.Generator-583"><a href="#DuckDB.Generator-583"><span class="linenos">583</span></a> <span class="k">if</span> <span class="n">multiplier</span><span class="p">:</span> -</span><span id="DuckDB.Generator-584"><a href="#DuckDB.Generator-584"><span class="linenos">584</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">multiplier</span><span class="si">}</span><span class="s2"> * </span><span class="si">{</span><span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">interval_sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Interval</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span><span class="w"> </span><span class="n">unit</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="s1">'DAY'</span><span class="p">)))</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="DuckDB.Generator-585"><a href="#DuckDB.Generator-585"><span class="linenos">585</span></a> -</span><span id="DuckDB.Generator-586"><a href="#DuckDB.Generator-586"><span class="linenos">586</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">interval_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="DuckDB.Generator-587"><a href="#DuckDB.Generator-587"><span class="linenos">587</span></a> -</span><span id="DuckDB.Generator-588"><a href="#DuckDB.Generator-588"><span class="linenos">588</span></a> <span class="k">def</span> <span class="nf">columndef_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ColumnDef</span><span class="p">,</span> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">" "</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="DuckDB.Generator-589"><a href="#DuckDB.Generator-589"><span class="linenos">589</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">parent</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">UserDefinedFunction</span><span class="p">):</span> -</span><span id="DuckDB.Generator-590"><a href="#DuckDB.Generator-590"><span class="linenos">590</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="DuckDB.Generator-591"><a href="#DuckDB.Generator-591"><span class="linenos">591</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">columndef_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">sep</span><span class="p">)</span> -</span><span id="DuckDB.Generator-592"><a href="#DuckDB.Generator-592"><span class="linenos">592</span></a> -</span><span id="DuckDB.Generator-593"><a href="#DuckDB.Generator-593"><span class="linenos">593</span></a> <span class="k">def</span> <span class="nf">join_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Join</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="DuckDB.Generator-594"><a href="#DuckDB.Generator-594"><span class="linenos">594</span></a> <span class="k">if</span> <span class="p">(</span> -</span><span id="DuckDB.Generator-595"><a href="#DuckDB.Generator-595"><span class="linenos">595</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">side</span> <span class="o">==</span> <span class="s2">"LEFT"</span> -</span><span id="DuckDB.Generator-596"><a href="#DuckDB.Generator-596"><span class="linenos">596</span></a> <span class="ow">and</span> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"on"</span><span class="p">)</span> -</span><span id="DuckDB.Generator-597"><a href="#DuckDB.Generator-597"><span class="linenos">597</span></a> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Unnest</span><span class="p">)</span> -</span><span id="DuckDB.Generator-598"><a href="#DuckDB.Generator-598"><span class="linenos">598</span></a> <span class="p">):</span> -</span><span id="DuckDB.Generator-599"><a href="#DuckDB.Generator-599"><span class="linenos">599</span></a> <span class="c1"># Some dialects support `LEFT JOIN UNNEST(...)` without an explicit ON clause</span> -</span><span id="DuckDB.Generator-600"><a href="#DuckDB.Generator-600"><span class="linenos">600</span></a> <span class="c1"># DuckDB doesn't, but we can just add a dummy ON clause that is always true</span> -</span><span id="DuckDB.Generator-601"><a href="#DuckDB.Generator-601"><span class="linenos">601</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">join_sql</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">on</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">true</span><span class="p">()))</span> +</span><span id="DuckDB.Generator-507"><a href="#DuckDB.Generator-507"><span class="linenos">507</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMPNTZ</span><span class="p">:</span> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-508"><a href="#DuckDB.Generator-508"><span class="linenos">508</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMP_S</span><span class="p">:</span> <span class="s2">"TIMESTAMP_S"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-509"><a href="#DuckDB.Generator-509"><span class="linenos">509</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMP_MS</span><span class="p">:</span> <span class="s2">"TIMESTAMP_MS"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-510"><a href="#DuckDB.Generator-510"><span class="linenos">510</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMP_NS</span><span class="p">:</span> <span class="s2">"TIMESTAMP_NS"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-511"><a href="#DuckDB.Generator-511"><span class="linenos">511</span></a> <span class="p">}</span> +</span><span id="DuckDB.Generator-512"><a href="#DuckDB.Generator-512"><span class="linenos">512</span></a> +</span><span id="DuckDB.Generator-513"><a href="#DuckDB.Generator-513"><span class="linenos">513</span></a> <span class="c1"># https://github.com/duckdb/duckdb/blob/ff7f24fd8e3128d94371827523dae85ebaf58713/third_party/libpg_query/grammar/keywords/reserved_keywords.list#L1-L77</span> +</span><span id="DuckDB.Generator-514"><a href="#DuckDB.Generator-514"><span class="linenos">514</span></a> <span class="n">RESERVED_KEYWORDS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="DuckDB.Generator-515"><a href="#DuckDB.Generator-515"><span class="linenos">515</span></a> <span class="s2">"array"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-516"><a href="#DuckDB.Generator-516"><span class="linenos">516</span></a> <span class="s2">"analyse"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-517"><a href="#DuckDB.Generator-517"><span class="linenos">517</span></a> <span class="s2">"union"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-518"><a href="#DuckDB.Generator-518"><span class="linenos">518</span></a> <span class="s2">"all"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-519"><a href="#DuckDB.Generator-519"><span class="linenos">519</span></a> <span class="s2">"when"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-520"><a href="#DuckDB.Generator-520"><span class="linenos">520</span></a> <span class="s2">"in_p"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-521"><a href="#DuckDB.Generator-521"><span class="linenos">521</span></a> <span class="s2">"default"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-522"><a href="#DuckDB.Generator-522"><span class="linenos">522</span></a> <span class="s2">"create_p"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-523"><a href="#DuckDB.Generator-523"><span class="linenos">523</span></a> <span class="s2">"window"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-524"><a href="#DuckDB.Generator-524"><span class="linenos">524</span></a> <span class="s2">"asymmetric"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-525"><a href="#DuckDB.Generator-525"><span class="linenos">525</span></a> <span class="s2">"to"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-526"><a href="#DuckDB.Generator-526"><span class="linenos">526</span></a> <span class="s2">"else"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-527"><a href="#DuckDB.Generator-527"><span class="linenos">527</span></a> <span class="s2">"localtime"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-528"><a href="#DuckDB.Generator-528"><span class="linenos">528</span></a> <span class="s2">"from"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-529"><a href="#DuckDB.Generator-529"><span class="linenos">529</span></a> <span class="s2">"end_p"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-530"><a href="#DuckDB.Generator-530"><span class="linenos">530</span></a> <span class="s2">"select"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-531"><a href="#DuckDB.Generator-531"><span class="linenos">531</span></a> <span class="s2">"current_date"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-532"><a href="#DuckDB.Generator-532"><span class="linenos">532</span></a> <span class="s2">"foreign"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-533"><a href="#DuckDB.Generator-533"><span class="linenos">533</span></a> <span class="s2">"with"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-534"><a href="#DuckDB.Generator-534"><span class="linenos">534</span></a> <span class="s2">"grant"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-535"><a href="#DuckDB.Generator-535"><span class="linenos">535</span></a> <span class="s2">"session_user"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-536"><a href="#DuckDB.Generator-536"><span class="linenos">536</span></a> <span class="s2">"or"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-537"><a href="#DuckDB.Generator-537"><span class="linenos">537</span></a> <span class="s2">"except"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-538"><a href="#DuckDB.Generator-538"><span class="linenos">538</span></a> <span class="s2">"references"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-539"><a href="#DuckDB.Generator-539"><span class="linenos">539</span></a> <span class="s2">"fetch"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-540"><a href="#DuckDB.Generator-540"><span class="linenos">540</span></a> <span class="s2">"limit"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-541"><a href="#DuckDB.Generator-541"><span class="linenos">541</span></a> <span class="s2">"group_p"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-542"><a href="#DuckDB.Generator-542"><span class="linenos">542</span></a> <span class="s2">"leading"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-543"><a href="#DuckDB.Generator-543"><span class="linenos">543</span></a> <span class="s2">"into"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-544"><a href="#DuckDB.Generator-544"><span class="linenos">544</span></a> <span class="s2">"collate"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-545"><a href="#DuckDB.Generator-545"><span class="linenos">545</span></a> <span class="s2">"offset"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-546"><a href="#DuckDB.Generator-546"><span class="linenos">546</span></a> <span class="s2">"do"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-547"><a href="#DuckDB.Generator-547"><span class="linenos">547</span></a> <span class="s2">"then"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-548"><a href="#DuckDB.Generator-548"><span class="linenos">548</span></a> <span class="s2">"localtimestamp"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-549"><a href="#DuckDB.Generator-549"><span class="linenos">549</span></a> <span class="s2">"check_p"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-550"><a href="#DuckDB.Generator-550"><span class="linenos">550</span></a> <span class="s2">"lateral_p"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-551"><a href="#DuckDB.Generator-551"><span class="linenos">551</span></a> <span class="s2">"current_role"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-552"><a href="#DuckDB.Generator-552"><span class="linenos">552</span></a> <span class="s2">"where"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-553"><a href="#DuckDB.Generator-553"><span class="linenos">553</span></a> <span class="s2">"asc_p"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-554"><a href="#DuckDB.Generator-554"><span class="linenos">554</span></a> <span class="s2">"placing"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-555"><a href="#DuckDB.Generator-555"><span class="linenos">555</span></a> <span class="s2">"desc_p"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-556"><a href="#DuckDB.Generator-556"><span class="linenos">556</span></a> <span class="s2">"user"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-557"><a href="#DuckDB.Generator-557"><span class="linenos">557</span></a> <span class="s2">"unique"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-558"><a href="#DuckDB.Generator-558"><span class="linenos">558</span></a> <span class="s2">"initially"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-559"><a href="#DuckDB.Generator-559"><span class="linenos">559</span></a> <span class="s2">"column"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-560"><a href="#DuckDB.Generator-560"><span class="linenos">560</span></a> <span class="s2">"both"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-561"><a href="#DuckDB.Generator-561"><span class="linenos">561</span></a> <span class="s2">"some"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-562"><a href="#DuckDB.Generator-562"><span class="linenos">562</span></a> <span class="s2">"as"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-563"><a href="#DuckDB.Generator-563"><span class="linenos">563</span></a> <span class="s2">"any"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-564"><a href="#DuckDB.Generator-564"><span class="linenos">564</span></a> <span class="s2">"only"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-565"><a href="#DuckDB.Generator-565"><span class="linenos">565</span></a> <span class="s2">"deferrable"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-566"><a href="#DuckDB.Generator-566"><span class="linenos">566</span></a> <span class="s2">"null_p"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-567"><a href="#DuckDB.Generator-567"><span class="linenos">567</span></a> <span class="s2">"current_time"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-568"><a href="#DuckDB.Generator-568"><span class="linenos">568</span></a> <span class="s2">"true_p"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-569"><a href="#DuckDB.Generator-569"><span class="linenos">569</span></a> <span class="s2">"table"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-570"><a href="#DuckDB.Generator-570"><span class="linenos">570</span></a> <span class="s2">"case"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-571"><a href="#DuckDB.Generator-571"><span class="linenos">571</span></a> <span class="s2">"trailing"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-572"><a href="#DuckDB.Generator-572"><span class="linenos">572</span></a> <span class="s2">"variadic"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-573"><a href="#DuckDB.Generator-573"><span class="linenos">573</span></a> <span class="s2">"for"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-574"><a href="#DuckDB.Generator-574"><span class="linenos">574</span></a> <span class="s2">"on"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-575"><a href="#DuckDB.Generator-575"><span class="linenos">575</span></a> <span class="s2">"distinct"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-576"><a href="#DuckDB.Generator-576"><span class="linenos">576</span></a> <span class="s2">"false_p"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-577"><a href="#DuckDB.Generator-577"><span class="linenos">577</span></a> <span class="s2">"not"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-578"><a href="#DuckDB.Generator-578"><span class="linenos">578</span></a> <span class="s2">"constraint"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-579"><a href="#DuckDB.Generator-579"><span class="linenos">579</span></a> <span class="s2">"current_timestamp"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-580"><a href="#DuckDB.Generator-580"><span class="linenos">580</span></a> <span class="s2">"returning"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-581"><a href="#DuckDB.Generator-581"><span class="linenos">581</span></a> <span class="s2">"primary"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-582"><a href="#DuckDB.Generator-582"><span class="linenos">582</span></a> <span class="s2">"intersect"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-583"><a href="#DuckDB.Generator-583"><span class="linenos">583</span></a> <span class="s2">"having"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-584"><a href="#DuckDB.Generator-584"><span class="linenos">584</span></a> <span class="s2">"analyze"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-585"><a href="#DuckDB.Generator-585"><span class="linenos">585</span></a> <span class="s2">"current_user"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-586"><a href="#DuckDB.Generator-586"><span class="linenos">586</span></a> <span class="s2">"and"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-587"><a href="#DuckDB.Generator-587"><span class="linenos">587</span></a> <span class="s2">"cast"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-588"><a href="#DuckDB.Generator-588"><span class="linenos">588</span></a> <span class="s2">"symmetric"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-589"><a href="#DuckDB.Generator-589"><span class="linenos">589</span></a> <span class="s2">"using"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-590"><a href="#DuckDB.Generator-590"><span class="linenos">590</span></a> <span class="s2">"order"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-591"><a href="#DuckDB.Generator-591"><span class="linenos">591</span></a> <span class="s2">"current_catalog"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-592"><a href="#DuckDB.Generator-592"><span class="linenos">592</span></a> <span class="p">}</span> +</span><span id="DuckDB.Generator-593"><a href="#DuckDB.Generator-593"><span class="linenos">593</span></a> +</span><span id="DuckDB.Generator-594"><a href="#DuckDB.Generator-594"><span class="linenos">594</span></a> <span class="n">UNWRAPPED_INTERVAL_VALUES</span> <span class="o">=</span> <span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Paren</span><span class="p">)</span> +</span><span id="DuckDB.Generator-595"><a href="#DuckDB.Generator-595"><span class="linenos">595</span></a> +</span><span id="DuckDB.Generator-596"><a href="#DuckDB.Generator-596"><span class="linenos">596</span></a> <span class="c1"># DuckDB doesn't generally support CREATE TABLE .. properties</span> +</span><span id="DuckDB.Generator-597"><a href="#DuckDB.Generator-597"><span class="linenos">597</span></a> <span class="c1"># https://duckdb.org/docs/sql/statements/create_table.html</span> +</span><span id="DuckDB.Generator-598"><a href="#DuckDB.Generator-598"><span class="linenos">598</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="DuckDB.Generator-599"><a href="#DuckDB.Generator-599"><span class="linenos">599</span></a> <span class="n">prop</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span> +</span><span id="DuckDB.Generator-600"><a href="#DuckDB.Generator-600"><span class="linenos">600</span></a> <span class="k">for</span> <span class="n">prop</span> <span class="ow">in</span> <span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">PROPERTIES_LOCATION</span> +</span><span id="DuckDB.Generator-601"><a href="#DuckDB.Generator-601"><span class="linenos">601</span></a> <span class="p">}</span> </span><span id="DuckDB.Generator-602"><a href="#DuckDB.Generator-602"><span class="linenos">602</span></a> -</span><span id="DuckDB.Generator-603"><a href="#DuckDB.Generator-603"><span class="linenos">603</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">join_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="DuckDB.Generator-604"><a href="#DuckDB.Generator-604"><span class="linenos">604</span></a> -</span><span id="DuckDB.Generator-605"><a href="#DuckDB.Generator-605"><span class="linenos">605</span></a> <span class="k">def</span> <span class="nf">generateseries_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GenerateSeries</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="DuckDB.Generator-606"><a href="#DuckDB.Generator-606"><span class="linenos">606</span></a> <span class="c1"># GENERATE_SERIES(a, b) -> [a, b], RANGE(a, b) -> [a, b)</span> -</span><span id="DuckDB.Generator-607"><a href="#DuckDB.Generator-607"><span class="linenos">607</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">"is_end_exclusive"</span><span class="p">):</span> -</span><span id="DuckDB.Generator-608"><a href="#DuckDB.Generator-608"><span class="linenos">608</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"is_end_exclusive"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> -</span><span id="DuckDB.Generator-609"><a href="#DuckDB.Generator-609"><span class="linenos">609</span></a> <span class="k">return</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"RANGE"</span><span class="p">)(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> -</span><span id="DuckDB.Generator-610"><a href="#DuckDB.Generator-610"><span class="linenos">610</span></a> -</span><span id="DuckDB.Generator-611"><a href="#DuckDB.Generator-611"><span class="linenos">611</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">generateseries_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="DuckDB.Generator-612"><a href="#DuckDB.Generator-612"><span class="linenos">612</span></a> -</span><span id="DuckDB.Generator-613"><a href="#DuckDB.Generator-613"><span class="linenos">613</span></a> <span class="k">def</span> <span class="nf">bracket_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Bracket</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="DuckDB.Generator-614"><a href="#DuckDB.Generator-614"><span class="linenos">614</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> -</span><span id="DuckDB.Generator-615"><a href="#DuckDB.Generator-615"><span class="linenos">615</span></a> <span class="k">if</span> <span class="nb">isinstance</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">Array</span><span class="p">):</span> -</span><span id="DuckDB.Generator-616"><a href="#DuckDB.Generator-616"><span class="linenos">616</span></a> <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">paren</span><span class="p">(</span><span class="n">this</span><span class="p">))</span> -</span><span id="DuckDB.Generator-617"><a href="#DuckDB.Generator-617"><span class="linenos">617</span></a> -</span><span id="DuckDB.Generator-618"><a href="#DuckDB.Generator-618"><span class="linenos">618</span></a> <span class="n">bracket</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">bracket_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="DuckDB.Generator-603"><a href="#DuckDB.Generator-603"><span class="linenos">603</span></a> <span class="c1"># There are a few exceptions (e.g. temporary tables) which are supported or</span> +</span><span id="DuckDB.Generator-604"><a href="#DuckDB.Generator-604"><span class="linenos">604</span></a> <span class="c1"># can be transpiled to DuckDB, so we explicitly override them accordingly</span> +</span><span id="DuckDB.Generator-605"><a href="#DuckDB.Generator-605"><span class="linenos">605</span></a> <span class="n">PROPERTIES_LOCATION</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">LikeProperty</span><span class="p">]</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span> +</span><span id="DuckDB.Generator-606"><a href="#DuckDB.Generator-606"><span class="linenos">606</span></a> <span class="n">PROPERTIES_LOCATION</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">TemporaryProperty</span><span class="p">]</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span> +</span><span id="DuckDB.Generator-607"><a href="#DuckDB.Generator-607"><span class="linenos">607</span></a> +</span><span id="DuckDB.Generator-608"><a href="#DuckDB.Generator-608"><span class="linenos">608</span></a> <span class="k">def</span> <span class="nf">timefromparts_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TimeFromParts</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="DuckDB.Generator-609"><a href="#DuckDB.Generator-609"><span class="linenos">609</span></a> <span class="n">nano</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"nano"</span><span class="p">)</span> +</span><span id="DuckDB.Generator-610"><a href="#DuckDB.Generator-610"><span class="linenos">610</span></a> <span class="k">if</span> <span class="n">nano</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="DuckDB.Generator-611"><a href="#DuckDB.Generator-611"><span class="linenos">611</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> +</span><span id="DuckDB.Generator-612"><a href="#DuckDB.Generator-612"><span class="linenos">612</span></a> <span class="s2">"sec"</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"sec"</span><span class="p">]</span> <span class="o">+</span> <span class="n">nano</span><span class="o">.</span><span class="n">pop</span><span class="p">()</span> <span class="o">/</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">number</span><span class="p">(</span><span class="mf">1000000000.0</span><span class="p">)</span> +</span><span id="DuckDB.Generator-613"><a href="#DuckDB.Generator-613"><span class="linenos">613</span></a> <span class="p">)</span> +</span><span id="DuckDB.Generator-614"><a href="#DuckDB.Generator-614"><span class="linenos">614</span></a> +</span><span id="DuckDB.Generator-615"><a href="#DuckDB.Generator-615"><span class="linenos">615</span></a> <span class="k">return</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"MAKE_TIME"</span><span class="p">)(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> +</span><span id="DuckDB.Generator-616"><a href="#DuckDB.Generator-616"><span class="linenos">616</span></a> +</span><span id="DuckDB.Generator-617"><a href="#DuckDB.Generator-617"><span class="linenos">617</span></a> <span class="k">def</span> <span class="nf">timestampfromparts_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TimestampFromParts</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="DuckDB.Generator-618"><a href="#DuckDB.Generator-618"><span class="linenos">618</span></a> <span class="n">sec</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"sec"</span><span class="p">]</span> </span><span id="DuckDB.Generator-619"><a href="#DuckDB.Generator-619"><span class="linenos">619</span></a> -</span><span id="DuckDB.Generator-620"><a href="#DuckDB.Generator-620"><span class="linenos">620</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"returns_list_for_maps"</span><span class="p">):</span> -</span><span id="DuckDB.Generator-621"><a href="#DuckDB.Generator-621"><span class="linenos">621</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">this</span><span class="o">.</span><span class="n">type</span><span class="p">:</span> -</span><span id="DuckDB.Generator-622"><a href="#DuckDB.Generator-622"><span class="linenos">622</span></a> <span class="kn">from</span> <span class="nn">sqlglot.optimizer.annotate_types</span> <span class="kn">import</span> <span class="n">annotate_types</span> +</span><span id="DuckDB.Generator-620"><a href="#DuckDB.Generator-620"><span class="linenos">620</span></a> <span class="n">milli</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"milli"</span><span class="p">)</span> +</span><span id="DuckDB.Generator-621"><a href="#DuckDB.Generator-621"><span class="linenos">621</span></a> <span class="k">if</span> <span class="n">milli</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="DuckDB.Generator-622"><a href="#DuckDB.Generator-622"><span class="linenos">622</span></a> <span class="n">sec</span> <span class="o">+=</span> <span class="n">milli</span><span class="o">.</span><span class="n">pop</span><span class="p">()</span> <span class="o">/</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">number</span><span class="p">(</span><span class="mf">1000.0</span><span class="p">)</span> </span><span id="DuckDB.Generator-623"><a href="#DuckDB.Generator-623"><span class="linenos">623</span></a> -</span><span id="DuckDB.Generator-624"><a href="#DuckDB.Generator-624"><span class="linenos">624</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">annotate_types</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> -</span><span id="DuckDB.Generator-625"><a href="#DuckDB.Generator-625"><span class="linenos">625</span></a> -</span><span id="DuckDB.Generator-626"><a href="#DuckDB.Generator-626"><span class="linenos">626</span></a> <span class="k">if</span> <span class="n">this</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">MAP</span><span class="p">):</span> -</span><span id="DuckDB.Generator-627"><a href="#DuckDB.Generator-627"><span class="linenos">627</span></a> <span class="n">bracket</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">bracket</span><span class="si">}</span><span class="s2">)[1]"</span> -</span><span id="DuckDB.Generator-628"><a href="#DuckDB.Generator-628"><span class="linenos">628</span></a> -</span><span id="DuckDB.Generator-629"><a href="#DuckDB.Generator-629"><span class="linenos">629</span></a> <span class="k">return</span> <span class="n">bracket</span> +</span><span id="DuckDB.Generator-624"><a href="#DuckDB.Generator-624"><span class="linenos">624</span></a> <span class="n">nano</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"nano"</span><span class="p">)</span> +</span><span id="DuckDB.Generator-625"><a href="#DuckDB.Generator-625"><span class="linenos">625</span></a> <span class="k">if</span> <span class="n">nano</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="DuckDB.Generator-626"><a href="#DuckDB.Generator-626"><span class="linenos">626</span></a> <span class="n">sec</span> <span class="o">+=</span> <span class="n">nano</span><span class="o">.</span><span class="n">pop</span><span class="p">()</span> <span class="o">/</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">number</span><span class="p">(</span><span class="mf">1000000000.0</span><span class="p">)</span> +</span><span id="DuckDB.Generator-627"><a href="#DuckDB.Generator-627"><span class="linenos">627</span></a> +</span><span id="DuckDB.Generator-628"><a href="#DuckDB.Generator-628"><span class="linenos">628</span></a> <span class="k">if</span> <span class="n">milli</span> <span class="ow">or</span> <span class="n">nano</span><span class="p">:</span> +</span><span id="DuckDB.Generator-629"><a href="#DuckDB.Generator-629"><span class="linenos">629</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"sec"</span><span class="p">,</span> <span class="n">sec</span><span class="p">)</span> </span><span id="DuckDB.Generator-630"><a href="#DuckDB.Generator-630"><span class="linenos">630</span></a> -</span><span id="DuckDB.Generator-631"><a href="#DuckDB.Generator-631"><span class="linenos">631</span></a> <span class="k">def</span> <span class="nf">withingroup_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">WithinGroup</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="DuckDB.Generator-632"><a href="#DuckDB.Generator-632"><span class="linenos">632</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> -</span><span id="DuckDB.Generator-633"><a href="#DuckDB.Generator-633"><span class="linenos">633</span></a> -</span><span id="DuckDB.Generator-634"><a href="#DuckDB.Generator-634"><span class="linenos">634</span></a> <span class="n">func</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> -</span><span id="DuckDB.Generator-635"><a href="#DuckDB.Generator-635"><span class="linenos">635</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">func</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">PERCENTILES</span><span class="p">):</span> -</span><span id="DuckDB.Generator-636"><a href="#DuckDB.Generator-636"><span class="linenos">636</span></a> <span class="c1"># Make the order key the first arg and slide the fraction to the right</span> -</span><span id="DuckDB.Generator-637"><a href="#DuckDB.Generator-637"><span class="linenos">637</span></a> <span class="c1"># https://duckdb.org/docs/sql/aggregates#ordered-set-aggregate-functions</span> -</span><span id="DuckDB.Generator-638"><a href="#DuckDB.Generator-638"><span class="linenos">638</span></a> <span class="n">order_col</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">find</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Ordered</span><span class="p">)</span> -</span><span id="DuckDB.Generator-639"><a href="#DuckDB.Generator-639"><span class="linenos">639</span></a> <span class="k">if</span> <span class="n">order_col</span><span class="p">:</span> -</span><span id="DuckDB.Generator-640"><a href="#DuckDB.Generator-640"><span class="linenos">640</span></a> <span class="n">func</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"expression"</span><span class="p">,</span> <span class="n">func</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> -</span><span id="DuckDB.Generator-641"><a href="#DuckDB.Generator-641"><span class="linenos">641</span></a> <span class="n">func</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"this"</span><span class="p">,</span> <span class="n">order_col</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> +</span><span id="DuckDB.Generator-631"><a href="#DuckDB.Generator-631"><span class="linenos">631</span></a> <span class="k">return</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"MAKE_TIMESTAMP"</span><span class="p">)(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> +</span><span id="DuckDB.Generator-632"><a href="#DuckDB.Generator-632"><span class="linenos">632</span></a> +</span><span id="DuckDB.Generator-633"><a href="#DuckDB.Generator-633"><span class="linenos">633</span></a> <span class="k">def</span> <span class="nf">tablesample_sql</span><span class="p">(</span> +</span><span id="DuckDB.Generator-634"><a href="#DuckDB.Generator-634"><span class="linenos">634</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="DuckDB.Generator-635"><a href="#DuckDB.Generator-635"><span class="linenos">635</span></a> <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><span id="DuckDB.Generator-636"><a href="#DuckDB.Generator-636"><span class="linenos">636</span></a> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">" AS "</span><span class="p">,</span> +</span><span id="DuckDB.Generator-637"><a href="#DuckDB.Generator-637"><span class="linenos">637</span></a> <span class="n">tablesample_keyword</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="DuckDB.Generator-638"><a href="#DuckDB.Generator-638"><span class="linenos">638</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="DuckDB.Generator-639"><a href="#DuckDB.Generator-639"><span class="linenos">639</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">parent</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">):</span> +</span><span id="DuckDB.Generator-640"><a href="#DuckDB.Generator-640"><span class="linenos">640</span></a> <span class="c1"># This sample clause only applies to a single source, not the entire resulting relation</span> +</span><span id="DuckDB.Generator-641"><a href="#DuckDB.Generator-641"><span class="linenos">641</span></a> <span class="n">tablesample_keyword</span> <span class="o">=</span> <span class="s2">"TABLESAMPLE"</span> </span><span id="DuckDB.Generator-642"><a href="#DuckDB.Generator-642"><span class="linenos">642</span></a> -</span><span id="DuckDB.Generator-643"><a href="#DuckDB.Generator-643"><span class="linenos">643</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span><span class="o">.</span><span class="n">rstrip</span><span class="p">(</span><span class="s2">")"</span><span class="p">)</span> -</span><span id="DuckDB.Generator-644"><a href="#DuckDB.Generator-644"><span class="linenos">644</span></a> -</span><span id="DuckDB.Generator-645"><a href="#DuckDB.Generator-645"><span class="linenos">645</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="DuckDB.Generator-643"><a href="#DuckDB.Generator-643"><span class="linenos">643</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">"size"</span><span class="p">):</span> +</span><span id="DuckDB.Generator-644"><a href="#DuckDB.Generator-644"><span class="linenos">644</span></a> <span class="n">method</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"method"</span><span class="p">)</span> +</span><span id="DuckDB.Generator-645"><a href="#DuckDB.Generator-645"><span class="linenos">645</span></a> <span class="k">if</span> <span class="n">method</span> <span class="ow">and</span> <span class="n">method</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> <span class="o">!=</span> <span class="s2">"RESERVOIR"</span><span class="p">:</span> +</span><span id="DuckDB.Generator-646"><a href="#DuckDB.Generator-646"><span class="linenos">646</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span> +</span><span id="DuckDB.Generator-647"><a href="#DuckDB.Generator-647"><span class="linenos">647</span></a> <span class="sa">f</span><span class="s2">"Sampling method </span><span class="si">{</span><span class="n">method</span><span class="si">}</span><span class="s2"> is not supported with a discrete sample count, "</span> +</span><span id="DuckDB.Generator-648"><a href="#DuckDB.Generator-648"><span class="linenos">648</span></a> <span class="s2">"defaulting to reservoir sampling"</span> +</span><span id="DuckDB.Generator-649"><a href="#DuckDB.Generator-649"><span class="linenos">649</span></a> <span class="p">)</span> +</span><span id="DuckDB.Generator-650"><a href="#DuckDB.Generator-650"><span class="linenos">650</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"method"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="s2">"RESERVOIR"</span><span class="p">))</span> +</span><span id="DuckDB.Generator-651"><a href="#DuckDB.Generator-651"><span class="linenos">651</span></a> +</span><span id="DuckDB.Generator-652"><a href="#DuckDB.Generator-652"><span class="linenos">652</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">tablesample_sql</span><span class="p">(</span> +</span><span id="DuckDB.Generator-653"><a href="#DuckDB.Generator-653"><span class="linenos">653</span></a> <span class="n">expression</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="n">sep</span><span class="p">,</span> <span class="n">tablesample_keyword</span><span class="o">=</span><span class="n">tablesample_keyword</span> +</span><span id="DuckDB.Generator-654"><a href="#DuckDB.Generator-654"><span class="linenos">654</span></a> <span class="p">)</span> +</span><span id="DuckDB.Generator-655"><a href="#DuckDB.Generator-655"><span class="linenos">655</span></a> +</span><span id="DuckDB.Generator-656"><a href="#DuckDB.Generator-656"><span class="linenos">656</span></a> <span class="k">def</span> <span class="nf">interval_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Interval</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="DuckDB.Generator-657"><a href="#DuckDB.Generator-657"><span class="linenos">657</span></a> <span class="n">multiplier</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">int</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="DuckDB.Generator-658"><a href="#DuckDB.Generator-658"><span class="linenos">658</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> +</span><span id="DuckDB.Generator-659"><a href="#DuckDB.Generator-659"><span class="linenos">659</span></a> +</span><span id="DuckDB.Generator-660"><a href="#DuckDB.Generator-660"><span class="linenos">660</span></a> <span class="k">if</span> <span class="n">unit</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"week"</span><span class="p">):</span> +</span><span id="DuckDB.Generator-661"><a href="#DuckDB.Generator-661"><span class="linenos">661</span></a> <span class="n">multiplier</span> <span class="o">=</span> <span class="mi">7</span> +</span><span id="DuckDB.Generator-662"><a href="#DuckDB.Generator-662"><span class="linenos">662</span></a> <span class="k">if</span> <span class="n">unit</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"quarter"</span><span class="p">):</span> +</span><span id="DuckDB.Generator-663"><a href="#DuckDB.Generator-663"><span class="linenos">663</span></a> <span class="n">multiplier</span> <span class="o">=</span> <span class="mi">90</span> +</span><span id="DuckDB.Generator-664"><a href="#DuckDB.Generator-664"><span class="linenos">664</span></a> +</span><span id="DuckDB.Generator-665"><a href="#DuckDB.Generator-665"><span class="linenos">665</span></a> <span class="k">if</span> <span class="n">multiplier</span><span class="p">:</span> +</span><span id="DuckDB.Generator-666"><a href="#DuckDB.Generator-666"><span class="linenos">666</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">multiplier</span><span class="si">}</span><span class="s2"> * </span><span class="si">{</span><span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">interval_sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Interval</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span><span class="w"> </span><span class="n">unit</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="s1">'DAY'</span><span class="p">)))</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="DuckDB.Generator-667"><a href="#DuckDB.Generator-667"><span class="linenos">667</span></a> +</span><span id="DuckDB.Generator-668"><a href="#DuckDB.Generator-668"><span class="linenos">668</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">interval_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="DuckDB.Generator-669"><a href="#DuckDB.Generator-669"><span class="linenos">669</span></a> +</span><span id="DuckDB.Generator-670"><a href="#DuckDB.Generator-670"><span class="linenos">670</span></a> <span class="k">def</span> <span class="nf">columndef_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ColumnDef</span><span class="p">,</span> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">" "</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="DuckDB.Generator-671"><a href="#DuckDB.Generator-671"><span class="linenos">671</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">parent</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">UserDefinedFunction</span><span class="p">):</span> +</span><span id="DuckDB.Generator-672"><a href="#DuckDB.Generator-672"><span class="linenos">672</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="DuckDB.Generator-673"><a href="#DuckDB.Generator-673"><span class="linenos">673</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">columndef_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">sep</span><span class="p">)</span> +</span><span id="DuckDB.Generator-674"><a href="#DuckDB.Generator-674"><span class="linenos">674</span></a> +</span><span id="DuckDB.Generator-675"><a href="#DuckDB.Generator-675"><span class="linenos">675</span></a> <span class="k">def</span> <span class="nf">join_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Join</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="DuckDB.Generator-676"><a href="#DuckDB.Generator-676"><span class="linenos">676</span></a> <span class="k">if</span> <span class="p">(</span> +</span><span id="DuckDB.Generator-677"><a href="#DuckDB.Generator-677"><span class="linenos">677</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">side</span> <span class="o">==</span> <span class="s2">"LEFT"</span> +</span><span id="DuckDB.Generator-678"><a href="#DuckDB.Generator-678"><span class="linenos">678</span></a> <span class="ow">and</span> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"on"</span><span class="p">)</span> +</span><span id="DuckDB.Generator-679"><a href="#DuckDB.Generator-679"><span class="linenos">679</span></a> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Unnest</span><span class="p">)</span> +</span><span id="DuckDB.Generator-680"><a href="#DuckDB.Generator-680"><span class="linenos">680</span></a> <span class="p">):</span> +</span><span id="DuckDB.Generator-681"><a href="#DuckDB.Generator-681"><span class="linenos">681</span></a> <span class="c1"># Some dialects support `LEFT JOIN UNNEST(...)` without an explicit ON clause</span> +</span><span id="DuckDB.Generator-682"><a href="#DuckDB.Generator-682"><span class="linenos">682</span></a> <span class="c1"># DuckDB doesn't, but we can just add a dummy ON clause that is always true</span> +</span><span id="DuckDB.Generator-683"><a href="#DuckDB.Generator-683"><span class="linenos">683</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">join_sql</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">on</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">true</span><span class="p">()))</span> +</span><span id="DuckDB.Generator-684"><a href="#DuckDB.Generator-684"><span class="linenos">684</span></a> +</span><span id="DuckDB.Generator-685"><a href="#DuckDB.Generator-685"><span class="linenos">685</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">join_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="DuckDB.Generator-686"><a href="#DuckDB.Generator-686"><span class="linenos">686</span></a> +</span><span id="DuckDB.Generator-687"><a href="#DuckDB.Generator-687"><span class="linenos">687</span></a> <span class="k">def</span> <span class="nf">generateseries_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GenerateSeries</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="DuckDB.Generator-688"><a href="#DuckDB.Generator-688"><span class="linenos">688</span></a> <span class="c1"># GENERATE_SERIES(a, b) -> [a, b], RANGE(a, b) -> [a, b)</span> +</span><span id="DuckDB.Generator-689"><a href="#DuckDB.Generator-689"><span class="linenos">689</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"is_end_exclusive"</span><span class="p">):</span> +</span><span id="DuckDB.Generator-690"><a href="#DuckDB.Generator-690"><span class="linenos">690</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"is_end_exclusive"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> +</span><span id="DuckDB.Generator-691"><a href="#DuckDB.Generator-691"><span class="linenos">691</span></a> <span class="k">return</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"RANGE"</span><span class="p">)(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> +</span><span id="DuckDB.Generator-692"><a href="#DuckDB.Generator-692"><span class="linenos">692</span></a> +</span><span id="DuckDB.Generator-693"><a href="#DuckDB.Generator-693"><span class="linenos">693</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">generateseries_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="DuckDB.Generator-694"><a href="#DuckDB.Generator-694"><span class="linenos">694</span></a> +</span><span id="DuckDB.Generator-695"><a href="#DuckDB.Generator-695"><span class="linenos">695</span></a> <span class="k">def</span> <span class="nf">bracket_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Bracket</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="DuckDB.Generator-696"><a href="#DuckDB.Generator-696"><span class="linenos">696</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> +</span><span id="DuckDB.Generator-697"><a href="#DuckDB.Generator-697"><span class="linenos">697</span></a> <span class="k">if</span> <span class="nb">isinstance</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">Array</span><span class="p">):</span> +</span><span id="DuckDB.Generator-698"><a href="#DuckDB.Generator-698"><span class="linenos">698</span></a> <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">paren</span><span class="p">(</span><span class="n">this</span><span class="p">))</span> +</span><span id="DuckDB.Generator-699"><a href="#DuckDB.Generator-699"><span class="linenos">699</span></a> +</span><span id="DuckDB.Generator-700"><a href="#DuckDB.Generator-700"><span class="linenos">700</span></a> <span class="n">bracket</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">bracket_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="DuckDB.Generator-701"><a href="#DuckDB.Generator-701"><span class="linenos">701</span></a> +</span><span id="DuckDB.Generator-702"><a href="#DuckDB.Generator-702"><span class="linenos">702</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"returns_list_for_maps"</span><span class="p">):</span> +</span><span id="DuckDB.Generator-703"><a href="#DuckDB.Generator-703"><span class="linenos">703</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">this</span><span class="o">.</span><span class="n">type</span><span class="p">:</span> +</span><span id="DuckDB.Generator-704"><a href="#DuckDB.Generator-704"><span class="linenos">704</span></a> <span class="kn">from</span> <span class="nn">sqlglot.optimizer.annotate_types</span> <span class="kn">import</span> <span class="n">annotate_types</span> +</span><span id="DuckDB.Generator-705"><a href="#DuckDB.Generator-705"><span class="linenos">705</span></a> +</span><span id="DuckDB.Generator-706"><a href="#DuckDB.Generator-706"><span class="linenos">706</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">annotate_types</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> +</span><span id="DuckDB.Generator-707"><a href="#DuckDB.Generator-707"><span class="linenos">707</span></a> +</span><span id="DuckDB.Generator-708"><a href="#DuckDB.Generator-708"><span class="linenos">708</span></a> <span class="k">if</span> <span class="n">this</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">MAP</span><span class="p">):</span> +</span><span id="DuckDB.Generator-709"><a href="#DuckDB.Generator-709"><span class="linenos">709</span></a> <span class="n">bracket</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">bracket</span><span class="si">}</span><span class="s2">)[1]"</span> +</span><span id="DuckDB.Generator-710"><a href="#DuckDB.Generator-710"><span class="linenos">710</span></a> +</span><span id="DuckDB.Generator-711"><a href="#DuckDB.Generator-711"><span class="linenos">711</span></a> <span class="k">return</span> <span class="n">bracket</span> +</span><span id="DuckDB.Generator-712"><a href="#DuckDB.Generator-712"><span class="linenos">712</span></a> +</span><span id="DuckDB.Generator-713"><a href="#DuckDB.Generator-713"><span class="linenos">713</span></a> <span class="k">def</span> <span class="nf">withingroup_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">WithinGroup</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="DuckDB.Generator-714"><a href="#DuckDB.Generator-714"><span class="linenos">714</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> +</span><span id="DuckDB.Generator-715"><a href="#DuckDB.Generator-715"><span class="linenos">715</span></a> +</span><span id="DuckDB.Generator-716"><a href="#DuckDB.Generator-716"><span class="linenos">716</span></a> <span class="n">func</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> +</span><span id="DuckDB.Generator-717"><a href="#DuckDB.Generator-717"><span class="linenos">717</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">func</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">PERCENTILES</span><span class="p">):</span> +</span><span id="DuckDB.Generator-718"><a href="#DuckDB.Generator-718"><span class="linenos">718</span></a> <span class="c1"># Make the order key the first arg and slide the fraction to the right</span> +</span><span id="DuckDB.Generator-719"><a href="#DuckDB.Generator-719"><span class="linenos">719</span></a> <span class="c1"># https://duckdb.org/docs/sql/aggregates#ordered-set-aggregate-functions</span> +</span><span id="DuckDB.Generator-720"><a href="#DuckDB.Generator-720"><span class="linenos">720</span></a> <span class="n">order_col</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">find</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Ordered</span><span class="p">)</span> +</span><span id="DuckDB.Generator-721"><a href="#DuckDB.Generator-721"><span class="linenos">721</span></a> <span class="k">if</span> <span class="n">order_col</span><span class="p">:</span> +</span><span id="DuckDB.Generator-722"><a href="#DuckDB.Generator-722"><span class="linenos">722</span></a> <span class="n">func</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"expression"</span><span class="p">,</span> <span class="n">func</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> +</span><span id="DuckDB.Generator-723"><a href="#DuckDB.Generator-723"><span class="linenos">723</span></a> <span class="n">func</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"this"</span><span class="p">,</span> <span class="n">order_col</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> +</span><span id="DuckDB.Generator-724"><a href="#DuckDB.Generator-724"><span class="linenos">724</span></a> +</span><span id="DuckDB.Generator-725"><a href="#DuckDB.Generator-725"><span class="linenos">725</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span><span class="o">.</span><span class="n">rstrip</span><span class="p">(</span><span class="s2">")"</span><span class="p">)</span> +</span><span id="DuckDB.Generator-726"><a href="#DuckDB.Generator-726"><span class="linenos">726</span></a> +</span><span id="DuckDB.Generator-727"><a href="#DuckDB.Generator-727"><span class="linenos">727</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">)"</span> </span></pre></div> @@ -3036,7 +3288,7 @@ Default: True</li> <div class="attr variable"> <span class="name">SUPPORTED_JSON_PATH_PARTS</span> = <input id="DuckDB.Generator.SUPPORTED_JSON_PATH_PARTS-view-value" class="view-value-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1"> - <label class="view-value-button pdoc-button" for="DuckDB.Generator.SUPPORTED_JSON_PATH_PARTS-view-value"></label><span class="default_value">{<class '<a href="../expressions.html#JSONPathRoot">sqlglot.expressions.JSONPathRoot</a>'>, <class '<a href="../expressions.html#JSONPathWildcard">sqlglot.expressions.JSONPathWildcard</a>'>, <class '<a href="../expressions.html#JSONPathSubscript">sqlglot.expressions.JSONPathSubscript</a>'>, <class '<a href="../expressions.html#JSONPathKey">sqlglot.expressions.JSONPathKey</a>'>}</span> + <label class="view-value-button pdoc-button" for="DuckDB.Generator.SUPPORTED_JSON_PATH_PARTS-view-value"></label><span class="default_value">{<class '<a href="../expressions.html#JSONPathKey">sqlglot.expressions.JSONPathKey</a>'>, <class '<a href="../expressions.html#JSONPathRoot">sqlglot.expressions.JSONPathRoot</a>'>, <class '<a href="../expressions.html#JSONPathWildcard">sqlglot.expressions.JSONPathWildcard</a>'>, <class '<a href="../expressions.html#JSONPathSubscript">sqlglot.expressions.JSONPathSubscript</a>'>}</span> </div> @@ -3049,7 +3301,7 @@ Default: True</li> <div class="attr variable"> <span class="name">TYPE_MAPPING</span> = <input id="DuckDB.Generator.TYPE_MAPPING-view-value" class="view-value-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1"> - <label class="view-value-button pdoc-button" for="DuckDB.Generator.TYPE_MAPPING-view-value"></label><span class="default_value">{<Type.NCHAR: 'NCHAR'>: 'TEXT', <Type.NVARCHAR: 'NVARCHAR'>: 'TEXT', <Type.MEDIUMTEXT: 'MEDIUMTEXT'>: 'TEXT', <Type.LONGTEXT: 'LONGTEXT'>: 'TEXT', <Type.TINYTEXT: 'TINYTEXT'>: 'TEXT', <Type.MEDIUMBLOB: 'MEDIUMBLOB'>: 'BLOB', <Type.LONGBLOB: 'LONGBLOB'>: 'BLOB', <Type.TINYBLOB: 'TINYBLOB'>: 'BLOB', <Type.INET: 'INET'>: 'INET', <Type.ROWVERSION: 'ROWVERSION'>: 'BLOB', <Type.BINARY: 'BINARY'>: 'BLOB', <Type.CHAR: 'CHAR'>: 'TEXT', <Type.FLOAT: 'FLOAT'>: 'REAL', <Type.UINT: 'UINT'>: 'UINTEGER', <Type.VARBINARY: 'VARBINARY'>: 'BLOB', <Type.VARCHAR: 'VARCHAR'>: 'TEXT', <Type.TIMESTAMP_S: 'TIMESTAMP_S'>: 'TIMESTAMP_S', <Type.TIMESTAMP_MS: 'TIMESTAMP_MS'>: 'TIMESTAMP_MS', <Type.TIMESTAMP_NS: 'TIMESTAMP_NS'>: 'TIMESTAMP_NS'}</span> + <label class="view-value-button pdoc-button" for="DuckDB.Generator.TYPE_MAPPING-view-value"></label><span class="default_value">{<Type.NCHAR: 'NCHAR'>: 'TEXT', <Type.NVARCHAR: 'NVARCHAR'>: 'TEXT', <Type.MEDIUMTEXT: 'MEDIUMTEXT'>: 'TEXT', <Type.LONGTEXT: 'LONGTEXT'>: 'TEXT', <Type.TINYTEXT: 'TINYTEXT'>: 'TEXT', <Type.MEDIUMBLOB: 'MEDIUMBLOB'>: 'BLOB', <Type.LONGBLOB: 'LONGBLOB'>: 'BLOB', <Type.TINYBLOB: 'TINYBLOB'>: 'BLOB', <Type.INET: 'INET'>: 'INET', <Type.ROWVERSION: 'ROWVERSION'>: 'BLOB', <Type.BINARY: 'BINARY'>: 'BLOB', <Type.CHAR: 'CHAR'>: 'TEXT', <Type.FLOAT: 'FLOAT'>: 'REAL', <Type.UINT: 'UINT'>: 'UINTEGER', <Type.VARBINARY: 'VARBINARY'>: 'BLOB', <Type.VARCHAR: 'VARCHAR'>: 'TEXT', <Type.TIMESTAMPNTZ: 'TIMESTAMPNTZ'>: 'TIMESTAMP', <Type.TIMESTAMP_S: 'TIMESTAMP_S'>: 'TIMESTAMP_S', <Type.TIMESTAMP_MS: 'TIMESTAMP_MS'>: 'TIMESTAMP_MS', <Type.TIMESTAMP_NS: 'TIMESTAMP_NS'>: 'TIMESTAMP_NS'}</span> </div> @@ -3058,6 +3310,19 @@ Default: True</li> </div> + <div id="DuckDB.Generator.RESERVED_KEYWORDS" class="classattr"> + <div class="attr variable"> + <span class="name">RESERVED_KEYWORDS</span> = +<input id="DuckDB.Generator.RESERVED_KEYWORDS-view-value" class="view-value-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1"> + <label class="view-value-button pdoc-button" for="DuckDB.Generator.RESERVED_KEYWORDS-view-value"></label><span class="default_value">{'returning', 'lateral_p', 'current_user', 'check_p', 'offset', 'asc_p', 'case', 'distinct', 'fetch', 'then', 'false_p', 'when', 'select', 'to', 'analyse', 'into', 'create_p', 'from', 'using', 'primary', 'table', 'true_p', 'all', 'with', 'window', 'foreign', 'placing', 'collate', 'trailing', 'constraint', 'leading', 'on', 'default', 'grant', 'localtimestamp', 'deferrable', 'analyze', 'column', 'symmetric', 'current_timestamp', 'initially', 'current_role', 'end_p', 'else', 'unique', 'order', 'only', 'as', 'not', 'union', 'cast', 'do', 'group_p', 'any', 'references', 'user', 'session_user', 'intersect', 'and', 'array', 'both', 'in_p', 'current_date', 'null_p', 'or', 'for', 'variadic', 'current_time', 'where', 'limit', 'having', 'except', 'desc_p', 'asymmetric', 'some', 'localtime', 'current_catalog'}</span> + + + </div> + <a class="headerlink" href="#DuckDB.Generator.RESERVED_KEYWORDS"></a> + + + + </div> <div id="DuckDB.Generator.UNWRAPPED_INTERVAL_VALUES" class="classattr"> <div class="attr variable"> <span class="name">UNWRAPPED_INTERVAL_VALUES</span> = @@ -3094,14 +3359,14 @@ Default: True</li> </div> <a class="headerlink" href="#DuckDB.Generator.timefromparts_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DuckDB.Generator.timefromparts_sql-526"><a href="#DuckDB.Generator.timefromparts_sql-526"><span class="linenos">526</span></a> <span class="k">def</span> <span class="nf">timefromparts_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TimeFromParts</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="DuckDB.Generator.timefromparts_sql-527"><a href="#DuckDB.Generator.timefromparts_sql-527"><span class="linenos">527</span></a> <span class="n">nano</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"nano"</span><span class="p">)</span> -</span><span id="DuckDB.Generator.timefromparts_sql-528"><a href="#DuckDB.Generator.timefromparts_sql-528"><span class="linenos">528</span></a> <span class="k">if</span> <span class="n">nano</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="DuckDB.Generator.timefromparts_sql-529"><a href="#DuckDB.Generator.timefromparts_sql-529"><span class="linenos">529</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> -</span><span id="DuckDB.Generator.timefromparts_sql-530"><a href="#DuckDB.Generator.timefromparts_sql-530"><span class="linenos">530</span></a> <span class="s2">"sec"</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"sec"</span><span class="p">]</span> <span class="o">+</span> <span class="n">nano</span><span class="o">.</span><span class="n">pop</span><span class="p">()</span> <span class="o">/</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">number</span><span class="p">(</span><span class="mf">1000000000.0</span><span class="p">)</span> -</span><span id="DuckDB.Generator.timefromparts_sql-531"><a href="#DuckDB.Generator.timefromparts_sql-531"><span class="linenos">531</span></a> <span class="p">)</span> -</span><span id="DuckDB.Generator.timefromparts_sql-532"><a href="#DuckDB.Generator.timefromparts_sql-532"><span class="linenos">532</span></a> -</span><span id="DuckDB.Generator.timefromparts_sql-533"><a href="#DuckDB.Generator.timefromparts_sql-533"><span class="linenos">533</span></a> <span class="k">return</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"MAKE_TIME"</span><span class="p">)(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DuckDB.Generator.timefromparts_sql-608"><a href="#DuckDB.Generator.timefromparts_sql-608"><span class="linenos">608</span></a> <span class="k">def</span> <span class="nf">timefromparts_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TimeFromParts</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="DuckDB.Generator.timefromparts_sql-609"><a href="#DuckDB.Generator.timefromparts_sql-609"><span class="linenos">609</span></a> <span class="n">nano</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"nano"</span><span class="p">)</span> +</span><span id="DuckDB.Generator.timefromparts_sql-610"><a href="#DuckDB.Generator.timefromparts_sql-610"><span class="linenos">610</span></a> <span class="k">if</span> <span class="n">nano</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="DuckDB.Generator.timefromparts_sql-611"><a href="#DuckDB.Generator.timefromparts_sql-611"><span class="linenos">611</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> +</span><span id="DuckDB.Generator.timefromparts_sql-612"><a href="#DuckDB.Generator.timefromparts_sql-612"><span class="linenos">612</span></a> <span class="s2">"sec"</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"sec"</span><span class="p">]</span> <span class="o">+</span> <span class="n">nano</span><span class="o">.</span><span class="n">pop</span><span class="p">()</span> <span class="o">/</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">number</span><span class="p">(</span><span class="mf">1000000000.0</span><span class="p">)</span> +</span><span id="DuckDB.Generator.timefromparts_sql-613"><a href="#DuckDB.Generator.timefromparts_sql-613"><span class="linenos">613</span></a> <span class="p">)</span> +</span><span id="DuckDB.Generator.timefromparts_sql-614"><a href="#DuckDB.Generator.timefromparts_sql-614"><span class="linenos">614</span></a> +</span><span id="DuckDB.Generator.timefromparts_sql-615"><a href="#DuckDB.Generator.timefromparts_sql-615"><span class="linenos">615</span></a> <span class="k">return</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"MAKE_TIME"</span><span class="p">)(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> </span></pre></div> @@ -3119,21 +3384,21 @@ Default: True</li> </div> <a class="headerlink" href="#DuckDB.Generator.timestampfromparts_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DuckDB.Generator.timestampfromparts_sql-535"><a href="#DuckDB.Generator.timestampfromparts_sql-535"><span class="linenos">535</span></a> <span class="k">def</span> <span class="nf">timestampfromparts_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TimestampFromParts</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="DuckDB.Generator.timestampfromparts_sql-536"><a href="#DuckDB.Generator.timestampfromparts_sql-536"><span class="linenos">536</span></a> <span class="n">sec</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"sec"</span><span class="p">]</span> -</span><span id="DuckDB.Generator.timestampfromparts_sql-537"><a href="#DuckDB.Generator.timestampfromparts_sql-537"><span class="linenos">537</span></a> -</span><span id="DuckDB.Generator.timestampfromparts_sql-538"><a href="#DuckDB.Generator.timestampfromparts_sql-538"><span class="linenos">538</span></a> <span class="n">milli</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"milli"</span><span class="p">)</span> -</span><span id="DuckDB.Generator.timestampfromparts_sql-539"><a href="#DuckDB.Generator.timestampfromparts_sql-539"><span class="linenos">539</span></a> <span class="k">if</span> <span class="n">milli</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="DuckDB.Generator.timestampfromparts_sql-540"><a href="#DuckDB.Generator.timestampfromparts_sql-540"><span class="linenos">540</span></a> <span class="n">sec</span> <span class="o">+=</span> <span class="n">milli</span><span class="o">.</span><span class="n">pop</span><span class="p">()</span> <span class="o">/</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">number</span><span class="p">(</span><span class="mf">1000.0</span><span class="p">)</span> -</span><span id="DuckDB.Generator.timestampfromparts_sql-541"><a href="#DuckDB.Generator.timestampfromparts_sql-541"><span class="linenos">541</span></a> -</span><span id="DuckDB.Generator.timestampfromparts_sql-542"><a href="#DuckDB.Generator.timestampfromparts_sql-542"><span class="linenos">542</span></a> <span class="n">nano</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"nano"</span><span class="p">)</span> -</span><span id="DuckDB.Generator.timestampfromparts_sql-543"><a href="#DuckDB.Generator.timestampfromparts_sql-543"><span class="linenos">543</span></a> <span class="k">if</span> <span class="n">nano</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="DuckDB.Generator.timestampfromparts_sql-544"><a href="#DuckDB.Generator.timestampfromparts_sql-544"><span class="linenos">544</span></a> <span class="n">sec</span> <span class="o">+=</span> <span class="n">nano</span><span class="o">.</span><span class="n">pop</span><span class="p">()</span> <span class="o">/</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">number</span><span class="p">(</span><span class="mf">1000000000.0</span><span class="p">)</span> -</span><span id="DuckDB.Generator.timestampfromparts_sql-545"><a href="#DuckDB.Generator.timestampfromparts_sql-545"><span class="linenos">545</span></a> -</span><span id="DuckDB.Generator.timestampfromparts_sql-546"><a href="#DuckDB.Generator.timestampfromparts_sql-546"><span class="linenos">546</span></a> <span class="k">if</span> <span class="n">milli</span> <span class="ow">or</span> <span class="n">nano</span><span class="p">:</span> -</span><span id="DuckDB.Generator.timestampfromparts_sql-547"><a href="#DuckDB.Generator.timestampfromparts_sql-547"><span class="linenos">547</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"sec"</span><span class="p">,</span> <span class="n">sec</span><span class="p">)</span> -</span><span id="DuckDB.Generator.timestampfromparts_sql-548"><a href="#DuckDB.Generator.timestampfromparts_sql-548"><span class="linenos">548</span></a> -</span><span id="DuckDB.Generator.timestampfromparts_sql-549"><a href="#DuckDB.Generator.timestampfromparts_sql-549"><span class="linenos">549</span></a> <span class="k">return</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"MAKE_TIMESTAMP"</span><span class="p">)(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DuckDB.Generator.timestampfromparts_sql-617"><a href="#DuckDB.Generator.timestampfromparts_sql-617"><span class="linenos">617</span></a> <span class="k">def</span> <span class="nf">timestampfromparts_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TimestampFromParts</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="DuckDB.Generator.timestampfromparts_sql-618"><a href="#DuckDB.Generator.timestampfromparts_sql-618"><span class="linenos">618</span></a> <span class="n">sec</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"sec"</span><span class="p">]</span> +</span><span id="DuckDB.Generator.timestampfromparts_sql-619"><a href="#DuckDB.Generator.timestampfromparts_sql-619"><span class="linenos">619</span></a> +</span><span id="DuckDB.Generator.timestampfromparts_sql-620"><a href="#DuckDB.Generator.timestampfromparts_sql-620"><span class="linenos">620</span></a> <span class="n">milli</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"milli"</span><span class="p">)</span> +</span><span id="DuckDB.Generator.timestampfromparts_sql-621"><a href="#DuckDB.Generator.timestampfromparts_sql-621"><span class="linenos">621</span></a> <span class="k">if</span> <span class="n">milli</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="DuckDB.Generator.timestampfromparts_sql-622"><a href="#DuckDB.Generator.timestampfromparts_sql-622"><span class="linenos">622</span></a> <span class="n">sec</span> <span class="o">+=</span> <span class="n">milli</span><span class="o">.</span><span class="n">pop</span><span class="p">()</span> <span class="o">/</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">number</span><span class="p">(</span><span class="mf">1000.0</span><span class="p">)</span> +</span><span id="DuckDB.Generator.timestampfromparts_sql-623"><a href="#DuckDB.Generator.timestampfromparts_sql-623"><span class="linenos">623</span></a> +</span><span id="DuckDB.Generator.timestampfromparts_sql-624"><a href="#DuckDB.Generator.timestampfromparts_sql-624"><span class="linenos">624</span></a> <span class="n">nano</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"nano"</span><span class="p">)</span> +</span><span id="DuckDB.Generator.timestampfromparts_sql-625"><a href="#DuckDB.Generator.timestampfromparts_sql-625"><span class="linenos">625</span></a> <span class="k">if</span> <span class="n">nano</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="DuckDB.Generator.timestampfromparts_sql-626"><a href="#DuckDB.Generator.timestampfromparts_sql-626"><span class="linenos">626</span></a> <span class="n">sec</span> <span class="o">+=</span> <span class="n">nano</span><span class="o">.</span><span class="n">pop</span><span class="p">()</span> <span class="o">/</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">number</span><span class="p">(</span><span class="mf">1000000000.0</span><span class="p">)</span> +</span><span id="DuckDB.Generator.timestampfromparts_sql-627"><a href="#DuckDB.Generator.timestampfromparts_sql-627"><span class="linenos">627</span></a> +</span><span id="DuckDB.Generator.timestampfromparts_sql-628"><a href="#DuckDB.Generator.timestampfromparts_sql-628"><span class="linenos">628</span></a> <span class="k">if</span> <span class="n">milli</span> <span class="ow">or</span> <span class="n">nano</span><span class="p">:</span> +</span><span id="DuckDB.Generator.timestampfromparts_sql-629"><a href="#DuckDB.Generator.timestampfromparts_sql-629"><span class="linenos">629</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"sec"</span><span class="p">,</span> <span class="n">sec</span><span class="p">)</span> +</span><span id="DuckDB.Generator.timestampfromparts_sql-630"><a href="#DuckDB.Generator.timestampfromparts_sql-630"><span class="linenos">630</span></a> +</span><span id="DuckDB.Generator.timestampfromparts_sql-631"><a href="#DuckDB.Generator.timestampfromparts_sql-631"><span class="linenos">631</span></a> <span class="k">return</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"MAKE_TIMESTAMP"</span><span class="p">)(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> </span></pre></div> @@ -3151,28 +3416,28 @@ Default: True</li> </div> <a class="headerlink" href="#DuckDB.Generator.tablesample_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DuckDB.Generator.tablesample_sql-551"><a href="#DuckDB.Generator.tablesample_sql-551"><span class="linenos">551</span></a> <span class="k">def</span> <span class="nf">tablesample_sql</span><span class="p">(</span> -</span><span id="DuckDB.Generator.tablesample_sql-552"><a href="#DuckDB.Generator.tablesample_sql-552"><span class="linenos">552</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="DuckDB.Generator.tablesample_sql-553"><a href="#DuckDB.Generator.tablesample_sql-553"><span class="linenos">553</span></a> <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><span id="DuckDB.Generator.tablesample_sql-554"><a href="#DuckDB.Generator.tablesample_sql-554"><span class="linenos">554</span></a> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">" AS "</span><span class="p">,</span> -</span><span id="DuckDB.Generator.tablesample_sql-555"><a href="#DuckDB.Generator.tablesample_sql-555"><span class="linenos">555</span></a> <span class="n">tablesample_keyword</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="DuckDB.Generator.tablesample_sql-556"><a href="#DuckDB.Generator.tablesample_sql-556"><span class="linenos">556</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="DuckDB.Generator.tablesample_sql-557"><a href="#DuckDB.Generator.tablesample_sql-557"><span class="linenos">557</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">parent</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">):</span> -</span><span id="DuckDB.Generator.tablesample_sql-558"><a href="#DuckDB.Generator.tablesample_sql-558"><span class="linenos">558</span></a> <span class="c1"># This sample clause only applies to a single source, not the entire resulting relation</span> -</span><span id="DuckDB.Generator.tablesample_sql-559"><a href="#DuckDB.Generator.tablesample_sql-559"><span class="linenos">559</span></a> <span class="n">tablesample_keyword</span> <span class="o">=</span> <span class="s2">"TABLESAMPLE"</span> -</span><span id="DuckDB.Generator.tablesample_sql-560"><a href="#DuckDB.Generator.tablesample_sql-560"><span class="linenos">560</span></a> -</span><span id="DuckDB.Generator.tablesample_sql-561"><a href="#DuckDB.Generator.tablesample_sql-561"><span class="linenos">561</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">"size"</span><span class="p">):</span> -</span><span id="DuckDB.Generator.tablesample_sql-562"><a href="#DuckDB.Generator.tablesample_sql-562"><span class="linenos">562</span></a> <span class="n">method</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"method"</span><span class="p">)</span> -</span><span id="DuckDB.Generator.tablesample_sql-563"><a href="#DuckDB.Generator.tablesample_sql-563"><span class="linenos">563</span></a> <span class="k">if</span> <span class="n">method</span> <span class="ow">and</span> <span class="n">method</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> <span class="o">!=</span> <span class="s2">"RESERVOIR"</span><span class="p">:</span> -</span><span id="DuckDB.Generator.tablesample_sql-564"><a href="#DuckDB.Generator.tablesample_sql-564"><span class="linenos">564</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span> -</span><span id="DuckDB.Generator.tablesample_sql-565"><a href="#DuckDB.Generator.tablesample_sql-565"><span class="linenos">565</span></a> <span class="sa">f</span><span class="s2">"Sampling method </span><span class="si">{</span><span class="n">method</span><span class="si">}</span><span class="s2"> is not supported with a discrete sample count, "</span> -</span><span id="DuckDB.Generator.tablesample_sql-566"><a href="#DuckDB.Generator.tablesample_sql-566"><span class="linenos">566</span></a> <span class="s2">"defaulting to reservoir sampling"</span> -</span><span id="DuckDB.Generator.tablesample_sql-567"><a href="#DuckDB.Generator.tablesample_sql-567"><span class="linenos">567</span></a> <span class="p">)</span> -</span><span id="DuckDB.Generator.tablesample_sql-568"><a href="#DuckDB.Generator.tablesample_sql-568"><span class="linenos">568</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"method"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="s2">"RESERVOIR"</span><span class="p">))</span> -</span><span id="DuckDB.Generator.tablesample_sql-569"><a href="#DuckDB.Generator.tablesample_sql-569"><span class="linenos">569</span></a> -</span><span id="DuckDB.Generator.tablesample_sql-570"><a href="#DuckDB.Generator.tablesample_sql-570"><span class="linenos">570</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">tablesample_sql</span><span class="p">(</span> -</span><span id="DuckDB.Generator.tablesample_sql-571"><a href="#DuckDB.Generator.tablesample_sql-571"><span class="linenos">571</span></a> <span class="n">expression</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="n">sep</span><span class="p">,</span> <span class="n">tablesample_keyword</span><span class="o">=</span><span class="n">tablesample_keyword</span> -</span><span id="DuckDB.Generator.tablesample_sql-572"><a href="#DuckDB.Generator.tablesample_sql-572"><span class="linenos">572</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DuckDB.Generator.tablesample_sql-633"><a href="#DuckDB.Generator.tablesample_sql-633"><span class="linenos">633</span></a> <span class="k">def</span> <span class="nf">tablesample_sql</span><span class="p">(</span> +</span><span id="DuckDB.Generator.tablesample_sql-634"><a href="#DuckDB.Generator.tablesample_sql-634"><span class="linenos">634</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="DuckDB.Generator.tablesample_sql-635"><a href="#DuckDB.Generator.tablesample_sql-635"><span class="linenos">635</span></a> <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><span id="DuckDB.Generator.tablesample_sql-636"><a href="#DuckDB.Generator.tablesample_sql-636"><span class="linenos">636</span></a> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">" AS "</span><span class="p">,</span> +</span><span id="DuckDB.Generator.tablesample_sql-637"><a href="#DuckDB.Generator.tablesample_sql-637"><span class="linenos">637</span></a> <span class="n">tablesample_keyword</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="DuckDB.Generator.tablesample_sql-638"><a href="#DuckDB.Generator.tablesample_sql-638"><span class="linenos">638</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="DuckDB.Generator.tablesample_sql-639"><a href="#DuckDB.Generator.tablesample_sql-639"><span class="linenos">639</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">parent</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">):</span> +</span><span id="DuckDB.Generator.tablesample_sql-640"><a href="#DuckDB.Generator.tablesample_sql-640"><span class="linenos">640</span></a> <span class="c1"># This sample clause only applies to a single source, not the entire resulting relation</span> +</span><span id="DuckDB.Generator.tablesample_sql-641"><a href="#DuckDB.Generator.tablesample_sql-641"><span class="linenos">641</span></a> <span class="n">tablesample_keyword</span> <span class="o">=</span> <span class="s2">"TABLESAMPLE"</span> +</span><span id="DuckDB.Generator.tablesample_sql-642"><a href="#DuckDB.Generator.tablesample_sql-642"><span class="linenos">642</span></a> +</span><span id="DuckDB.Generator.tablesample_sql-643"><a href="#DuckDB.Generator.tablesample_sql-643"><span class="linenos">643</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">"size"</span><span class="p">):</span> +</span><span id="DuckDB.Generator.tablesample_sql-644"><a href="#DuckDB.Generator.tablesample_sql-644"><span class="linenos">644</span></a> <span class="n">method</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"method"</span><span class="p">)</span> +</span><span id="DuckDB.Generator.tablesample_sql-645"><a href="#DuckDB.Generator.tablesample_sql-645"><span class="linenos">645</span></a> <span class="k">if</span> <span class="n">method</span> <span class="ow">and</span> <span class="n">method</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> <span class="o">!=</span> <span class="s2">"RESERVOIR"</span><span class="p">:</span> +</span><span id="DuckDB.Generator.tablesample_sql-646"><a href="#DuckDB.Generator.tablesample_sql-646"><span class="linenos">646</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span> +</span><span id="DuckDB.Generator.tablesample_sql-647"><a href="#DuckDB.Generator.tablesample_sql-647"><span class="linenos">647</span></a> <span class="sa">f</span><span class="s2">"Sampling method </span><span class="si">{</span><span class="n">method</span><span class="si">}</span><span class="s2"> is not supported with a discrete sample count, "</span> +</span><span id="DuckDB.Generator.tablesample_sql-648"><a href="#DuckDB.Generator.tablesample_sql-648"><span class="linenos">648</span></a> <span class="s2">"defaulting to reservoir sampling"</span> +</span><span id="DuckDB.Generator.tablesample_sql-649"><a href="#DuckDB.Generator.tablesample_sql-649"><span class="linenos">649</span></a> <span class="p">)</span> +</span><span id="DuckDB.Generator.tablesample_sql-650"><a href="#DuckDB.Generator.tablesample_sql-650"><span class="linenos">650</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"method"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="s2">"RESERVOIR"</span><span class="p">))</span> +</span><span id="DuckDB.Generator.tablesample_sql-651"><a href="#DuckDB.Generator.tablesample_sql-651"><span class="linenos">651</span></a> +</span><span id="DuckDB.Generator.tablesample_sql-652"><a href="#DuckDB.Generator.tablesample_sql-652"><span class="linenos">652</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">tablesample_sql</span><span class="p">(</span> +</span><span id="DuckDB.Generator.tablesample_sql-653"><a href="#DuckDB.Generator.tablesample_sql-653"><span class="linenos">653</span></a> <span class="n">expression</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="n">sep</span><span class="p">,</span> <span class="n">tablesample_keyword</span><span class="o">=</span><span class="n">tablesample_keyword</span> +</span><span id="DuckDB.Generator.tablesample_sql-654"><a href="#DuckDB.Generator.tablesample_sql-654"><span class="linenos">654</span></a> <span class="p">)</span> </span></pre></div> @@ -3190,19 +3455,19 @@ Default: True</li> </div> <a class="headerlink" href="#DuckDB.Generator.interval_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DuckDB.Generator.interval_sql-574"><a href="#DuckDB.Generator.interval_sql-574"><span class="linenos">574</span></a> <span class="k">def</span> <span class="nf">interval_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Interval</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="DuckDB.Generator.interval_sql-575"><a href="#DuckDB.Generator.interval_sql-575"><span class="linenos">575</span></a> <span class="n">multiplier</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">int</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="DuckDB.Generator.interval_sql-576"><a href="#DuckDB.Generator.interval_sql-576"><span class="linenos">576</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> -</span><span id="DuckDB.Generator.interval_sql-577"><a href="#DuckDB.Generator.interval_sql-577"><span class="linenos">577</span></a> -</span><span id="DuckDB.Generator.interval_sql-578"><a href="#DuckDB.Generator.interval_sql-578"><span class="linenos">578</span></a> <span class="k">if</span> <span class="n">unit</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"week"</span><span class="p">):</span> -</span><span id="DuckDB.Generator.interval_sql-579"><a href="#DuckDB.Generator.interval_sql-579"><span class="linenos">579</span></a> <span class="n">multiplier</span> <span class="o">=</span> <span class="mi">7</span> -</span><span id="DuckDB.Generator.interval_sql-580"><a href="#DuckDB.Generator.interval_sql-580"><span class="linenos">580</span></a> <span class="k">if</span> <span class="n">unit</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"quarter"</span><span class="p">):</span> -</span><span id="DuckDB.Generator.interval_sql-581"><a href="#DuckDB.Generator.interval_sql-581"><span class="linenos">581</span></a> <span class="n">multiplier</span> <span class="o">=</span> <span class="mi">90</span> -</span><span id="DuckDB.Generator.interval_sql-582"><a href="#DuckDB.Generator.interval_sql-582"><span class="linenos">582</span></a> -</span><span id="DuckDB.Generator.interval_sql-583"><a href="#DuckDB.Generator.interval_sql-583"><span class="linenos">583</span></a> <span class="k">if</span> <span class="n">multiplier</span><span class="p">:</span> -</span><span id="DuckDB.Generator.interval_sql-584"><a href="#DuckDB.Generator.interval_sql-584"><span class="linenos">584</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">multiplier</span><span class="si">}</span><span class="s2"> * </span><span class="si">{</span><span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">interval_sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Interval</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span><span class="w"> </span><span class="n">unit</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="s1">'DAY'</span><span class="p">)))</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="DuckDB.Generator.interval_sql-585"><a href="#DuckDB.Generator.interval_sql-585"><span class="linenos">585</span></a> -</span><span id="DuckDB.Generator.interval_sql-586"><a href="#DuckDB.Generator.interval_sql-586"><span class="linenos">586</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">interval_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DuckDB.Generator.interval_sql-656"><a href="#DuckDB.Generator.interval_sql-656"><span class="linenos">656</span></a> <span class="k">def</span> <span class="nf">interval_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Interval</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="DuckDB.Generator.interval_sql-657"><a href="#DuckDB.Generator.interval_sql-657"><span class="linenos">657</span></a> <span class="n">multiplier</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">int</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="DuckDB.Generator.interval_sql-658"><a href="#DuckDB.Generator.interval_sql-658"><span class="linenos">658</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> +</span><span id="DuckDB.Generator.interval_sql-659"><a href="#DuckDB.Generator.interval_sql-659"><span class="linenos">659</span></a> +</span><span id="DuckDB.Generator.interval_sql-660"><a href="#DuckDB.Generator.interval_sql-660"><span class="linenos">660</span></a> <span class="k">if</span> <span class="n">unit</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"week"</span><span class="p">):</span> +</span><span id="DuckDB.Generator.interval_sql-661"><a href="#DuckDB.Generator.interval_sql-661"><span class="linenos">661</span></a> <span class="n">multiplier</span> <span class="o">=</span> <span class="mi">7</span> +</span><span id="DuckDB.Generator.interval_sql-662"><a href="#DuckDB.Generator.interval_sql-662"><span class="linenos">662</span></a> <span class="k">if</span> <span class="n">unit</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"quarter"</span><span class="p">):</span> +</span><span id="DuckDB.Generator.interval_sql-663"><a href="#DuckDB.Generator.interval_sql-663"><span class="linenos">663</span></a> <span class="n">multiplier</span> <span class="o">=</span> <span class="mi">90</span> +</span><span id="DuckDB.Generator.interval_sql-664"><a href="#DuckDB.Generator.interval_sql-664"><span class="linenos">664</span></a> +</span><span id="DuckDB.Generator.interval_sql-665"><a href="#DuckDB.Generator.interval_sql-665"><span class="linenos">665</span></a> <span class="k">if</span> <span class="n">multiplier</span><span class="p">:</span> +</span><span id="DuckDB.Generator.interval_sql-666"><a href="#DuckDB.Generator.interval_sql-666"><span class="linenos">666</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">multiplier</span><span class="si">}</span><span class="s2"> * </span><span class="si">{</span><span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">interval_sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Interval</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span><span class="w"> </span><span class="n">unit</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="s1">'DAY'</span><span class="p">)))</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="DuckDB.Generator.interval_sql-667"><a href="#DuckDB.Generator.interval_sql-667"><span class="linenos">667</span></a> +</span><span id="DuckDB.Generator.interval_sql-668"><a href="#DuckDB.Generator.interval_sql-668"><span class="linenos">668</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">interval_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> </span></pre></div> @@ -3220,10 +3485,10 @@ Default: True</li> </div> <a class="headerlink" href="#DuckDB.Generator.columndef_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DuckDB.Generator.columndef_sql-588"><a href="#DuckDB.Generator.columndef_sql-588"><span class="linenos">588</span></a> <span class="k">def</span> <span class="nf">columndef_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ColumnDef</span><span class="p">,</span> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">" "</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="DuckDB.Generator.columndef_sql-589"><a href="#DuckDB.Generator.columndef_sql-589"><span class="linenos">589</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">parent</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">UserDefinedFunction</span><span class="p">):</span> -</span><span id="DuckDB.Generator.columndef_sql-590"><a href="#DuckDB.Generator.columndef_sql-590"><span class="linenos">590</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="DuckDB.Generator.columndef_sql-591"><a href="#DuckDB.Generator.columndef_sql-591"><span class="linenos">591</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">columndef_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">sep</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DuckDB.Generator.columndef_sql-670"><a href="#DuckDB.Generator.columndef_sql-670"><span class="linenos">670</span></a> <span class="k">def</span> <span class="nf">columndef_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ColumnDef</span><span class="p">,</span> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">" "</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="DuckDB.Generator.columndef_sql-671"><a href="#DuckDB.Generator.columndef_sql-671"><span class="linenos">671</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">parent</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">UserDefinedFunction</span><span class="p">):</span> +</span><span id="DuckDB.Generator.columndef_sql-672"><a href="#DuckDB.Generator.columndef_sql-672"><span class="linenos">672</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="DuckDB.Generator.columndef_sql-673"><a href="#DuckDB.Generator.columndef_sql-673"><span class="linenos">673</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">columndef_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">sep</span><span class="p">)</span> </span></pre></div> @@ -3241,17 +3506,17 @@ Default: True</li> </div> <a class="headerlink" href="#DuckDB.Generator.join_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DuckDB.Generator.join_sql-593"><a href="#DuckDB.Generator.join_sql-593"><span class="linenos">593</span></a> <span class="k">def</span> <span class="nf">join_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Join</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="DuckDB.Generator.join_sql-594"><a href="#DuckDB.Generator.join_sql-594"><span class="linenos">594</span></a> <span class="k">if</span> <span class="p">(</span> -</span><span id="DuckDB.Generator.join_sql-595"><a href="#DuckDB.Generator.join_sql-595"><span class="linenos">595</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">side</span> <span class="o">==</span> <span class="s2">"LEFT"</span> -</span><span id="DuckDB.Generator.join_sql-596"><a href="#DuckDB.Generator.join_sql-596"><span class="linenos">596</span></a> <span class="ow">and</span> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"on"</span><span class="p">)</span> -</span><span id="DuckDB.Generator.join_sql-597"><a href="#DuckDB.Generator.join_sql-597"><span class="linenos">597</span></a> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Unnest</span><span class="p">)</span> -</span><span id="DuckDB.Generator.join_sql-598"><a href="#DuckDB.Generator.join_sql-598"><span class="linenos">598</span></a> <span class="p">):</span> -</span><span id="DuckDB.Generator.join_sql-599"><a href="#DuckDB.Generator.join_sql-599"><span class="linenos">599</span></a> <span class="c1"># Some dialects support `LEFT JOIN UNNEST(...)` without an explicit ON clause</span> -</span><span id="DuckDB.Generator.join_sql-600"><a href="#DuckDB.Generator.join_sql-600"><span class="linenos">600</span></a> <span class="c1"># DuckDB doesn't, but we can just add a dummy ON clause that is always true</span> -</span><span id="DuckDB.Generator.join_sql-601"><a href="#DuckDB.Generator.join_sql-601"><span class="linenos">601</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">join_sql</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">on</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">true</span><span class="p">()))</span> -</span><span id="DuckDB.Generator.join_sql-602"><a href="#DuckDB.Generator.join_sql-602"><span class="linenos">602</span></a> -</span><span id="DuckDB.Generator.join_sql-603"><a href="#DuckDB.Generator.join_sql-603"><span class="linenos">603</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">join_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DuckDB.Generator.join_sql-675"><a href="#DuckDB.Generator.join_sql-675"><span class="linenos">675</span></a> <span class="k">def</span> <span class="nf">join_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Join</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="DuckDB.Generator.join_sql-676"><a href="#DuckDB.Generator.join_sql-676"><span class="linenos">676</span></a> <span class="k">if</span> <span class="p">(</span> +</span><span id="DuckDB.Generator.join_sql-677"><a href="#DuckDB.Generator.join_sql-677"><span class="linenos">677</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">side</span> <span class="o">==</span> <span class="s2">"LEFT"</span> +</span><span id="DuckDB.Generator.join_sql-678"><a href="#DuckDB.Generator.join_sql-678"><span class="linenos">678</span></a> <span class="ow">and</span> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"on"</span><span class="p">)</span> +</span><span id="DuckDB.Generator.join_sql-679"><a href="#DuckDB.Generator.join_sql-679"><span class="linenos">679</span></a> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Unnest</span><span class="p">)</span> +</span><span id="DuckDB.Generator.join_sql-680"><a href="#DuckDB.Generator.join_sql-680"><span class="linenos">680</span></a> <span class="p">):</span> +</span><span id="DuckDB.Generator.join_sql-681"><a href="#DuckDB.Generator.join_sql-681"><span class="linenos">681</span></a> <span class="c1"># Some dialects support `LEFT JOIN UNNEST(...)` without an explicit ON clause</span> +</span><span id="DuckDB.Generator.join_sql-682"><a href="#DuckDB.Generator.join_sql-682"><span class="linenos">682</span></a> <span class="c1"># DuckDB doesn't, but we can just add a dummy ON clause that is always true</span> +</span><span id="DuckDB.Generator.join_sql-683"><a href="#DuckDB.Generator.join_sql-683"><span class="linenos">683</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">join_sql</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">on</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">true</span><span class="p">()))</span> +</span><span id="DuckDB.Generator.join_sql-684"><a href="#DuckDB.Generator.join_sql-684"><span class="linenos">684</span></a> +</span><span id="DuckDB.Generator.join_sql-685"><a href="#DuckDB.Generator.join_sql-685"><span class="linenos">685</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">join_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> </span></pre></div> @@ -3269,13 +3534,13 @@ Default: True</li> </div> <a class="headerlink" href="#DuckDB.Generator.generateseries_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DuckDB.Generator.generateseries_sql-605"><a href="#DuckDB.Generator.generateseries_sql-605"><span class="linenos">605</span></a> <span class="k">def</span> <span class="nf">generateseries_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GenerateSeries</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="DuckDB.Generator.generateseries_sql-606"><a href="#DuckDB.Generator.generateseries_sql-606"><span class="linenos">606</span></a> <span class="c1"># GENERATE_SERIES(a, b) -> [a, b], RANGE(a, b) -> [a, b)</span> -</span><span id="DuckDB.Generator.generateseries_sql-607"><a href="#DuckDB.Generator.generateseries_sql-607"><span class="linenos">607</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">"is_end_exclusive"</span><span class="p">):</span> -</span><span id="DuckDB.Generator.generateseries_sql-608"><a href="#DuckDB.Generator.generateseries_sql-608"><span class="linenos">608</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"is_end_exclusive"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> -</span><span id="DuckDB.Generator.generateseries_sql-609"><a href="#DuckDB.Generator.generateseries_sql-609"><span class="linenos">609</span></a> <span class="k">return</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"RANGE"</span><span class="p">)(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> -</span><span id="DuckDB.Generator.generateseries_sql-610"><a href="#DuckDB.Generator.generateseries_sql-610"><span class="linenos">610</span></a> -</span><span id="DuckDB.Generator.generateseries_sql-611"><a href="#DuckDB.Generator.generateseries_sql-611"><span class="linenos">611</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">generateseries_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DuckDB.Generator.generateseries_sql-687"><a href="#DuckDB.Generator.generateseries_sql-687"><span class="linenos">687</span></a> <span class="k">def</span> <span class="nf">generateseries_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GenerateSeries</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="DuckDB.Generator.generateseries_sql-688"><a href="#DuckDB.Generator.generateseries_sql-688"><span class="linenos">688</span></a> <span class="c1"># GENERATE_SERIES(a, b) -> [a, b], RANGE(a, b) -> [a, b)</span> +</span><span id="DuckDB.Generator.generateseries_sql-689"><a href="#DuckDB.Generator.generateseries_sql-689"><span class="linenos">689</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"is_end_exclusive"</span><span class="p">):</span> +</span><span id="DuckDB.Generator.generateseries_sql-690"><a href="#DuckDB.Generator.generateseries_sql-690"><span class="linenos">690</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"is_end_exclusive"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> +</span><span id="DuckDB.Generator.generateseries_sql-691"><a href="#DuckDB.Generator.generateseries_sql-691"><span class="linenos">691</span></a> <span class="k">return</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"RANGE"</span><span class="p">)(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> +</span><span id="DuckDB.Generator.generateseries_sql-692"><a href="#DuckDB.Generator.generateseries_sql-692"><span class="linenos">692</span></a> +</span><span id="DuckDB.Generator.generateseries_sql-693"><a href="#DuckDB.Generator.generateseries_sql-693"><span class="linenos">693</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">generateseries_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> </span></pre></div> @@ -3293,23 +3558,23 @@ Default: True</li> </div> <a class="headerlink" href="#DuckDB.Generator.bracket_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DuckDB.Generator.bracket_sql-613"><a href="#DuckDB.Generator.bracket_sql-613"><span class="linenos">613</span></a> <span class="k">def</span> <span class="nf">bracket_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Bracket</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="DuckDB.Generator.bracket_sql-614"><a href="#DuckDB.Generator.bracket_sql-614"><span class="linenos">614</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> -</span><span id="DuckDB.Generator.bracket_sql-615"><a href="#DuckDB.Generator.bracket_sql-615"><span class="linenos">615</span></a> <span class="k">if</span> <span class="nb">isinstance</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">Array</span><span class="p">):</span> -</span><span id="DuckDB.Generator.bracket_sql-616"><a href="#DuckDB.Generator.bracket_sql-616"><span class="linenos">616</span></a> <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">paren</span><span class="p">(</span><span class="n">this</span><span class="p">))</span> -</span><span id="DuckDB.Generator.bracket_sql-617"><a href="#DuckDB.Generator.bracket_sql-617"><span class="linenos">617</span></a> -</span><span id="DuckDB.Generator.bracket_sql-618"><a href="#DuckDB.Generator.bracket_sql-618"><span class="linenos">618</span></a> <span class="n">bracket</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">bracket_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="DuckDB.Generator.bracket_sql-619"><a href="#DuckDB.Generator.bracket_sql-619"><span class="linenos">619</span></a> -</span><span id="DuckDB.Generator.bracket_sql-620"><a href="#DuckDB.Generator.bracket_sql-620"><span class="linenos">620</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"returns_list_for_maps"</span><span class="p">):</span> -</span><span id="DuckDB.Generator.bracket_sql-621"><a href="#DuckDB.Generator.bracket_sql-621"><span class="linenos">621</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">this</span><span class="o">.</span><span class="n">type</span><span class="p">:</span> -</span><span id="DuckDB.Generator.bracket_sql-622"><a href="#DuckDB.Generator.bracket_sql-622"><span class="linenos">622</span></a> <span class="kn">from</span> <span class="nn">sqlglot.optimizer.annotate_types</span> <span class="kn">import</span> <span class="n">annotate_types</span> -</span><span id="DuckDB.Generator.bracket_sql-623"><a href="#DuckDB.Generator.bracket_sql-623"><span class="linenos">623</span></a> -</span><span id="DuckDB.Generator.bracket_sql-624"><a href="#DuckDB.Generator.bracket_sql-624"><span class="linenos">624</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">annotate_types</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> -</span><span id="DuckDB.Generator.bracket_sql-625"><a href="#DuckDB.Generator.bracket_sql-625"><span class="linenos">625</span></a> -</span><span id="DuckDB.Generator.bracket_sql-626"><a href="#DuckDB.Generator.bracket_sql-626"><span class="linenos">626</span></a> <span class="k">if</span> <span class="n">this</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">MAP</span><span class="p">):</span> -</span><span id="DuckDB.Generator.bracket_sql-627"><a href="#DuckDB.Generator.bracket_sql-627"><span class="linenos">627</span></a> <span class="n">bracket</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">bracket</span><span class="si">}</span><span class="s2">)[1]"</span> -</span><span id="DuckDB.Generator.bracket_sql-628"><a href="#DuckDB.Generator.bracket_sql-628"><span class="linenos">628</span></a> -</span><span id="DuckDB.Generator.bracket_sql-629"><a href="#DuckDB.Generator.bracket_sql-629"><span class="linenos">629</span></a> <span class="k">return</span> <span class="n">bracket</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DuckDB.Generator.bracket_sql-695"><a href="#DuckDB.Generator.bracket_sql-695"><span class="linenos">695</span></a> <span class="k">def</span> <span class="nf">bracket_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Bracket</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="DuckDB.Generator.bracket_sql-696"><a href="#DuckDB.Generator.bracket_sql-696"><span class="linenos">696</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> +</span><span id="DuckDB.Generator.bracket_sql-697"><a href="#DuckDB.Generator.bracket_sql-697"><span class="linenos">697</span></a> <span class="k">if</span> <span class="nb">isinstance</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">Array</span><span class="p">):</span> +</span><span id="DuckDB.Generator.bracket_sql-698"><a href="#DuckDB.Generator.bracket_sql-698"><span class="linenos">698</span></a> <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">paren</span><span class="p">(</span><span class="n">this</span><span class="p">))</span> +</span><span id="DuckDB.Generator.bracket_sql-699"><a href="#DuckDB.Generator.bracket_sql-699"><span class="linenos">699</span></a> +</span><span id="DuckDB.Generator.bracket_sql-700"><a href="#DuckDB.Generator.bracket_sql-700"><span class="linenos">700</span></a> <span class="n">bracket</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">bracket_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="DuckDB.Generator.bracket_sql-701"><a href="#DuckDB.Generator.bracket_sql-701"><span class="linenos">701</span></a> +</span><span id="DuckDB.Generator.bracket_sql-702"><a href="#DuckDB.Generator.bracket_sql-702"><span class="linenos">702</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"returns_list_for_maps"</span><span class="p">):</span> +</span><span id="DuckDB.Generator.bracket_sql-703"><a href="#DuckDB.Generator.bracket_sql-703"><span class="linenos">703</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">this</span><span class="o">.</span><span class="n">type</span><span class="p">:</span> +</span><span id="DuckDB.Generator.bracket_sql-704"><a href="#DuckDB.Generator.bracket_sql-704"><span class="linenos">704</span></a> <span class="kn">from</span> <span class="nn">sqlglot.optimizer.annotate_types</span> <span class="kn">import</span> <span class="n">annotate_types</span> +</span><span id="DuckDB.Generator.bracket_sql-705"><a href="#DuckDB.Generator.bracket_sql-705"><span class="linenos">705</span></a> +</span><span id="DuckDB.Generator.bracket_sql-706"><a href="#DuckDB.Generator.bracket_sql-706"><span class="linenos">706</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">annotate_types</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> +</span><span id="DuckDB.Generator.bracket_sql-707"><a href="#DuckDB.Generator.bracket_sql-707"><span class="linenos">707</span></a> +</span><span id="DuckDB.Generator.bracket_sql-708"><a href="#DuckDB.Generator.bracket_sql-708"><span class="linenos">708</span></a> <span class="k">if</span> <span class="n">this</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">MAP</span><span class="p">):</span> +</span><span id="DuckDB.Generator.bracket_sql-709"><a href="#DuckDB.Generator.bracket_sql-709"><span class="linenos">709</span></a> <span class="n">bracket</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">bracket</span><span class="si">}</span><span class="s2">)[1]"</span> +</span><span id="DuckDB.Generator.bracket_sql-710"><a href="#DuckDB.Generator.bracket_sql-710"><span class="linenos">710</span></a> +</span><span id="DuckDB.Generator.bracket_sql-711"><a href="#DuckDB.Generator.bracket_sql-711"><span class="linenos">711</span></a> <span class="k">return</span> <span class="n">bracket</span> </span></pre></div> @@ -3327,21 +3592,21 @@ Default: True</li> </div> <a class="headerlink" href="#DuckDB.Generator.withingroup_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DuckDB.Generator.withingroup_sql-631"><a href="#DuckDB.Generator.withingroup_sql-631"><span class="linenos">631</span></a> <span class="k">def</span> <span class="nf">withingroup_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">WithinGroup</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="DuckDB.Generator.withingroup_sql-632"><a href="#DuckDB.Generator.withingroup_sql-632"><span class="linenos">632</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> -</span><span id="DuckDB.Generator.withingroup_sql-633"><a href="#DuckDB.Generator.withingroup_sql-633"><span class="linenos">633</span></a> -</span><span id="DuckDB.Generator.withingroup_sql-634"><a href="#DuckDB.Generator.withingroup_sql-634"><span class="linenos">634</span></a> <span class="n">func</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> -</span><span id="DuckDB.Generator.withingroup_sql-635"><a href="#DuckDB.Generator.withingroup_sql-635"><span class="linenos">635</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">func</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">PERCENTILES</span><span class="p">):</span> -</span><span id="DuckDB.Generator.withingroup_sql-636"><a href="#DuckDB.Generator.withingroup_sql-636"><span class="linenos">636</span></a> <span class="c1"># Make the order key the first arg and slide the fraction to the right</span> -</span><span id="DuckDB.Generator.withingroup_sql-637"><a href="#DuckDB.Generator.withingroup_sql-637"><span class="linenos">637</span></a> <span class="c1"># https://duckdb.org/docs/sql/aggregates#ordered-set-aggregate-functions</span> -</span><span id="DuckDB.Generator.withingroup_sql-638"><a href="#DuckDB.Generator.withingroup_sql-638"><span class="linenos">638</span></a> <span class="n">order_col</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">find</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Ordered</span><span class="p">)</span> -</span><span id="DuckDB.Generator.withingroup_sql-639"><a href="#DuckDB.Generator.withingroup_sql-639"><span class="linenos">639</span></a> <span class="k">if</span> <span class="n">order_col</span><span class="p">:</span> -</span><span id="DuckDB.Generator.withingroup_sql-640"><a href="#DuckDB.Generator.withingroup_sql-640"><span class="linenos">640</span></a> <span class="n">func</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"expression"</span><span class="p">,</span> <span class="n">func</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> -</span><span id="DuckDB.Generator.withingroup_sql-641"><a href="#DuckDB.Generator.withingroup_sql-641"><span class="linenos">641</span></a> <span class="n">func</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"this"</span><span class="p">,</span> <span class="n">order_col</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> -</span><span id="DuckDB.Generator.withingroup_sql-642"><a href="#DuckDB.Generator.withingroup_sql-642"><span class="linenos">642</span></a> -</span><span id="DuckDB.Generator.withingroup_sql-643"><a href="#DuckDB.Generator.withingroup_sql-643"><span class="linenos">643</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span><span class="o">.</span><span class="n">rstrip</span><span class="p">(</span><span class="s2">")"</span><span class="p">)</span> -</span><span id="DuckDB.Generator.withingroup_sql-644"><a href="#DuckDB.Generator.withingroup_sql-644"><span class="linenos">644</span></a> -</span><span id="DuckDB.Generator.withingroup_sql-645"><a href="#DuckDB.Generator.withingroup_sql-645"><span class="linenos">645</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">)"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DuckDB.Generator.withingroup_sql-713"><a href="#DuckDB.Generator.withingroup_sql-713"><span class="linenos">713</span></a> <span class="k">def</span> <span class="nf">withingroup_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">WithinGroup</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="DuckDB.Generator.withingroup_sql-714"><a href="#DuckDB.Generator.withingroup_sql-714"><span class="linenos">714</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> +</span><span id="DuckDB.Generator.withingroup_sql-715"><a href="#DuckDB.Generator.withingroup_sql-715"><span class="linenos">715</span></a> +</span><span id="DuckDB.Generator.withingroup_sql-716"><a href="#DuckDB.Generator.withingroup_sql-716"><span class="linenos">716</span></a> <span class="n">func</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> +</span><span id="DuckDB.Generator.withingroup_sql-717"><a href="#DuckDB.Generator.withingroup_sql-717"><span class="linenos">717</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">func</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">PERCENTILES</span><span class="p">):</span> +</span><span id="DuckDB.Generator.withingroup_sql-718"><a href="#DuckDB.Generator.withingroup_sql-718"><span class="linenos">718</span></a> <span class="c1"># Make the order key the first arg and slide the fraction to the right</span> +</span><span id="DuckDB.Generator.withingroup_sql-719"><a href="#DuckDB.Generator.withingroup_sql-719"><span class="linenos">719</span></a> <span class="c1"># https://duckdb.org/docs/sql/aggregates#ordered-set-aggregate-functions</span> +</span><span id="DuckDB.Generator.withingroup_sql-720"><a href="#DuckDB.Generator.withingroup_sql-720"><span class="linenos">720</span></a> <span class="n">order_col</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">find</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Ordered</span><span class="p">)</span> +</span><span id="DuckDB.Generator.withingroup_sql-721"><a href="#DuckDB.Generator.withingroup_sql-721"><span class="linenos">721</span></a> <span class="k">if</span> <span class="n">order_col</span><span class="p">:</span> +</span><span id="DuckDB.Generator.withingroup_sql-722"><a href="#DuckDB.Generator.withingroup_sql-722"><span class="linenos">722</span></a> <span class="n">func</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"expression"</span><span class="p">,</span> <span class="n">func</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> +</span><span id="DuckDB.Generator.withingroup_sql-723"><a href="#DuckDB.Generator.withingroup_sql-723"><span class="linenos">723</span></a> <span class="n">func</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"this"</span><span class="p">,</span> <span class="n">order_col</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> +</span><span id="DuckDB.Generator.withingroup_sql-724"><a href="#DuckDB.Generator.withingroup_sql-724"><span class="linenos">724</span></a> +</span><span id="DuckDB.Generator.withingroup_sql-725"><a href="#DuckDB.Generator.withingroup_sql-725"><span class="linenos">725</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span><span class="o">.</span><span class="n">rstrip</span><span class="p">(</span><span class="s2">")"</span><span class="p">)</span> +</span><span id="DuckDB.Generator.withingroup_sql-726"><a href="#DuckDB.Generator.withingroup_sql-726"><span class="linenos">726</span></a> +</span><span id="DuckDB.Generator.withingroup_sql-727"><a href="#DuckDB.Generator.withingroup_sql-727"><span class="linenos">727</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">)"</span> </span></pre></div> @@ -3437,7 +3702,6 @@ Default: True</li> <dd id="DuckDB.Generator.WITH_PROPERTIES_PREFIX" class="variable"><a href="../generator.html#Generator.WITH_PROPERTIES_PREFIX">WITH_PROPERTIES_PREFIX</a></dd> <dd id="DuckDB.Generator.TIME_PART_SINGULARS" class="variable"><a href="../generator.html#Generator.TIME_PART_SINGULARS">TIME_PART_SINGULARS</a></dd> <dd id="DuckDB.Generator.TOKEN_MAPPING" class="variable"><a href="../generator.html#Generator.TOKEN_MAPPING">TOKEN_MAPPING</a></dd> - <dd id="DuckDB.Generator.RESERVED_KEYWORDS" class="variable"><a href="../generator.html#Generator.RESERVED_KEYWORDS">RESERVED_KEYWORDS</a></dd> <dd id="DuckDB.Generator.WITH_SEPARATED_COMMENTS" class="variable"><a href="../generator.html#Generator.WITH_SEPARATED_COMMENTS">WITH_SEPARATED_COMMENTS</a></dd> <dd id="DuckDB.Generator.EXCLUDE_COMMENTS" class="variable"><a href="../generator.html#Generator.EXCLUDE_COMMENTS">EXCLUDE_COMMENTS</a></dd> <dd id="DuckDB.Generator.PARAMETERIZABLE_TEXT_TYPES" class="variable"><a href="../generator.html#Generator.PARAMETERIZABLE_TEXT_TYPES">PARAMETERIZABLE_TEXT_TYPES</a></dd> @@ -3775,6 +4039,7 @@ Default: True</li> <dd id="DuckDB.Generator.semicolon_sql" class="function"><a href="../generator.html#Generator.semicolon_sql">semicolon_sql</a></dd> <dd id="DuckDB.Generator.datadeletionproperty_sql" class="function"><a href="../generator.html#Generator.datadeletionproperty_sql">datadeletionproperty_sql</a></dd> <dd id="DuckDB.Generator.maskingpolicycolumnconstraint_sql" class="function"><a href="../generator.html#Generator.maskingpolicycolumnconstraint_sql">maskingpolicycolumnconstraint_sql</a></dd> + <dd id="DuckDB.Generator.gapfill_sql" class="function"><a href="../generator.html#Generator.gapfill_sql">gapfill_sql</a></dd> </div> </dl> |