diff options
Diffstat (limited to 'docs/sqlglot/dialects/duckdb.html')
-rw-r--r-- | docs/sqlglot/dialects/duckdb.html | 4026 |
1 files changed, 2023 insertions, 2003 deletions
diff --git a/docs/sqlglot/dialects/duckdb.html b/docs/sqlglot/dialects/duckdb.html index 22a989c..64c7a37 100644 --- a/docs/sqlglot/dialects/duckdb.html +++ b/docs/sqlglot/dialects/duckdb.html @@ -34,6 +34,9 @@ <a class="variable" href="#DATETIME_DELTA">DATETIME_DELTA</a> </li> <li> + <a class="variable" href="#WRAPPED_JSON_EXTRACT_EXPRESSIONS">WRAPPED_JSON_EXTRACT_EXPRESSIONS</a> + </li> + <li> <a class="class" href="#DuckDB">DuckDB</a> <ul class="memberlist"> <li> @@ -525,7 +528,7 @@ </span><span id="L-158"><a href="#L-158"><span class="linenos">158</span></a> </span><span id="L-159"><a href="#L-159"><span class="linenos">159</span></a><span class="k">def</span> <span class="nf">_datatype_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">DuckDB</span><span class="o">.</span><span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> </span><span id="L-160"><a href="#L-160"><span class="linenos">160</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="s2">"array"</span><span class="p">):</span> -</span><span id="L-161"><a href="#L-161"><span class="linenos">161</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">[]"</span> +</span><span id="L-161"><a href="#L-161"><span class="linenos">161</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">[</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">key</span><span class="o">=</span><span class="s1">'values'</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">]"</span> </span><span id="L-162"><a href="#L-162"><span class="linenos">162</span></a> </span><span id="L-163"><a href="#L-163"><span class="linenos">163</span></a> <span class="c1"># Type TIMESTAMP / TIME WITH TIME ZONE does not support any modifiers</span> </span><span id="L-164"><a href="#L-164"><span class="linenos">164</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="s2">"timestamptz"</span><span class="p">,</span> <span class="s2">"timetz"</span><span class="p">):</span> @@ -553,647 +556,652 @@ </span><span id="L-186"><a href="#L-186"><span class="linenos">186</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"TO_TIMESTAMP"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Div</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">timestamp</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"POW"</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="n">scale</span><span class="p">)))</span> </span><span id="L-187"><a href="#L-187"><span class="linenos">187</span></a> </span><span id="L-188"><a href="#L-188"><span class="linenos">188</span></a> -</span><span id="L-189"><a href="#L-189"><span class="linenos">189</span></a><span class="k">def</span> <span class="nf">_arrow_json_extract_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">DuckDB</span><span class="o">.</span><span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">JSON_EXTRACT_TYPE</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-190"><a href="#L-190"><span class="linenos">190</span></a> <span class="n">arrow_sql</span> <span class="o">=</span> <span class="n">arrow_json_extract_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> -</span><span id="L-191"><a href="#L-191"><span class="linenos">191</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">same_parent</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">parent</span><span class="p">,</span> <span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Binary</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Bracket</span><span class="p">)):</span> -</span><span id="L-192"><a href="#L-192"><span class="linenos">192</span></a> <span class="n">arrow_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">arrow_sql</span><span class="p">)</span> -</span><span id="L-193"><a href="#L-193"><span class="linenos">193</span></a> <span class="k">return</span> <span class="n">arrow_sql</span> -</span><span id="L-194"><a href="#L-194"><span class="linenos">194</span></a> -</span><span id="L-195"><a href="#L-195"><span class="linenos">195</span></a> -</span><span id="L-196"><a href="#L-196"><span class="linenos">196</span></a><span class="k">class</span> <span class="nc">DuckDB</span><span class="p">(</span><span class="n">Dialect</span><span class="p">):</span> -</span><span id="L-197"><a href="#L-197"><span class="linenos">197</span></a> <span class="n">NULL_ORDERING</span> <span class="o">=</span> <span class="s2">"nulls_are_last"</span> -</span><span id="L-198"><a href="#L-198"><span class="linenos">198</span></a> <span class="n">SUPPORTS_USER_DEFINED_TYPES</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-199"><a href="#L-199"><span class="linenos">199</span></a> <span class="n">SAFE_DIVISION</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="L-200"><a href="#L-200"><span class="linenos">200</span></a> <span class="n">INDEX_OFFSET</span> <span class="o">=</span> <span class="mi">1</span> -</span><span id="L-201"><a href="#L-201"><span class="linenos">201</span></a> <span class="n">CONCAT_COALESCE</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="L-202"><a href="#L-202"><span class="linenos">202</span></a> <span class="n">SUPPORTS_ORDER_BY_ALL</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="L-203"><a href="#L-203"><span class="linenos">203</span></a> -</span><span id="L-204"><a href="#L-204"><span class="linenos">204</span></a> <span class="c1"># https://duckdb.org/docs/sql/introduction.html#creating-a-new-table</span> -</span><span id="L-205"><a href="#L-205"><span class="linenos">205</span></a> <span class="n">NORMALIZATION_STRATEGY</span> <span class="o">=</span> <span class="n">NormalizationStrategy</span><span class="o">.</span><span class="n">CASE_INSENSITIVE</span> -</span><span id="L-206"><a href="#L-206"><span class="linenos">206</span></a> -</span><span id="L-207"><a href="#L-207"><span class="linenos">207</span></a> <span class="k">def</span> <span class="nf">to_json_path</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">])</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]:</span> -</span><span id="L-208"><a href="#L-208"><span class="linenos">208</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">path</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="p">):</span> -</span><span id="L-209"><a href="#L-209"><span class="linenos">209</span></a> <span class="c1"># DuckDB also supports the JSON pointer syntax, where every path starts with a `/`.</span> -</span><span id="L-210"><a href="#L-210"><span class="linenos">210</span></a> <span class="c1"># Additionally, it allows accessing the back of lists using the `[#-i]` syntax.</span> -</span><span id="L-211"><a href="#L-211"><span class="linenos">211</span></a> <span class="c1"># This check ensures we'll avoid trying to parse these as JSON paths, which can</span> -</span><span id="L-212"><a href="#L-212"><span class="linenos">212</span></a> <span class="c1"># either result in a noisy warning or in an invalid representation of the path.</span> -</span><span id="L-213"><a href="#L-213"><span class="linenos">213</span></a> <span class="n">path_text</span> <span class="o">=</span> <span class="n">path</span><span class="o">.</span><span class="n">name</span> -</span><span id="L-214"><a href="#L-214"><span class="linenos">214</span></a> <span class="k">if</span> <span class="n">path_text</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"/"</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">"[#"</span> <span class="ow">in</span> <span class="n">path_text</span><span class="p">:</span> -</span><span id="L-215"><a href="#L-215"><span class="linenos">215</span></a> <span class="k">return</span> <span class="n">path</span> -</span><span id="L-216"><a href="#L-216"><span class="linenos">216</span></a> -</span><span id="L-217"><a href="#L-217"><span class="linenos">217</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">to_json_path</span><span class="p">(</span><span class="n">path</span><span class="p">)</span> -</span><span id="L-218"><a href="#L-218"><span class="linenos">218</span></a> -</span><span id="L-219"><a href="#L-219"><span class="linenos">219</span></a> <span class="k">class</span> <span class="nc">Tokenizer</span><span class="p">(</span><span class="n">tokens</span><span class="o">.</span><span class="n">Tokenizer</span><span class="p">):</span> -</span><span id="L-220"><a href="#L-220"><span class="linenos">220</span></a> <span class="n">HEREDOC_STRINGS</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"$"</span><span class="p">]</span> +</span><span id="L-189"><a href="#L-189"><span class="linenos">189</span></a><span class="n">WRAPPED_JSON_EXTRACT_EXPRESSIONS</span> <span class="o">=</span> <span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Binary</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Bracket</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">In</span><span class="p">)</span> +</span><span id="L-190"><a href="#L-190"><span class="linenos">190</span></a> +</span><span id="L-191"><a href="#L-191"><span class="linenos">191</span></a> +</span><span id="L-192"><a href="#L-192"><span class="linenos">192</span></a><span class="k">def</span> <span class="nf">_arrow_json_extract_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">DuckDB</span><span class="o">.</span><span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">JSON_EXTRACT_TYPE</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-193"><a href="#L-193"><span class="linenos">193</span></a> <span class="n">arrow_sql</span> <span class="o">=</span> <span class="n">arrow_json_extract_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> +</span><span id="L-194"><a href="#L-194"><span class="linenos">194</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">same_parent</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span> +</span><span id="L-195"><a href="#L-195"><span class="linenos">195</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">parent</span><span class="p">,</span> <span class="n">WRAPPED_JSON_EXTRACT_EXPRESSIONS</span> +</span><span id="L-196"><a href="#L-196"><span class="linenos">196</span></a> <span class="p">):</span> +</span><span id="L-197"><a href="#L-197"><span class="linenos">197</span></a> <span class="n">arrow_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">arrow_sql</span><span class="p">)</span> +</span><span id="L-198"><a href="#L-198"><span class="linenos">198</span></a> <span class="k">return</span> <span class="n">arrow_sql</span> +</span><span id="L-199"><a href="#L-199"><span class="linenos">199</span></a> +</span><span id="L-200"><a href="#L-200"><span class="linenos">200</span></a> +</span><span id="L-201"><a href="#L-201"><span class="linenos">201</span></a><span class="k">class</span> <span class="nc">DuckDB</span><span class="p">(</span><span class="n">Dialect</span><span class="p">):</span> +</span><span id="L-202"><a href="#L-202"><span class="linenos">202</span></a> <span class="n">NULL_ORDERING</span> <span class="o">=</span> <span class="s2">"nulls_are_last"</span> +</span><span id="L-203"><a href="#L-203"><span class="linenos">203</span></a> <span class="n">SUPPORTS_USER_DEFINED_TYPES</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-204"><a href="#L-204"><span class="linenos">204</span></a> <span class="n">SAFE_DIVISION</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-205"><a href="#L-205"><span class="linenos">205</span></a> <span class="n">INDEX_OFFSET</span> <span class="o">=</span> <span class="mi">1</span> +</span><span id="L-206"><a href="#L-206"><span class="linenos">206</span></a> <span class="n">CONCAT_COALESCE</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-207"><a href="#L-207"><span class="linenos">207</span></a> <span class="n">SUPPORTS_ORDER_BY_ALL</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-208"><a href="#L-208"><span class="linenos">208</span></a> +</span><span id="L-209"><a href="#L-209"><span class="linenos">209</span></a> <span class="c1"># https://duckdb.org/docs/sql/introduction.html#creating-a-new-table</span> +</span><span id="L-210"><a href="#L-210"><span class="linenos">210</span></a> <span class="n">NORMALIZATION_STRATEGY</span> <span class="o">=</span> <span class="n">NormalizationStrategy</span><span class="o">.</span><span class="n">CASE_INSENSITIVE</span> +</span><span id="L-211"><a href="#L-211"><span class="linenos">211</span></a> +</span><span id="L-212"><a href="#L-212"><span class="linenos">212</span></a> <span class="k">def</span> <span class="nf">to_json_path</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">])</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]:</span> +</span><span id="L-213"><a href="#L-213"><span class="linenos">213</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">path</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="p">):</span> +</span><span id="L-214"><a href="#L-214"><span class="linenos">214</span></a> <span class="c1"># DuckDB also supports the JSON pointer syntax, where every path starts with a `/`.</span> +</span><span id="L-215"><a href="#L-215"><span class="linenos">215</span></a> <span class="c1"># Additionally, it allows accessing the back of lists using the `[#-i]` syntax.</span> +</span><span id="L-216"><a href="#L-216"><span class="linenos">216</span></a> <span class="c1"># This check ensures we'll avoid trying to parse these as JSON paths, which can</span> +</span><span id="L-217"><a href="#L-217"><span class="linenos">217</span></a> <span class="c1"># either result in a noisy warning or in an invalid representation of the path.</span> +</span><span id="L-218"><a href="#L-218"><span class="linenos">218</span></a> <span class="n">path_text</span> <span class="o">=</span> <span class="n">path</span><span class="o">.</span><span class="n">name</span> +</span><span id="L-219"><a href="#L-219"><span class="linenos">219</span></a> <span class="k">if</span> <span class="n">path_text</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"/"</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">"[#"</span> <span class="ow">in</span> <span class="n">path_text</span><span class="p">:</span> +</span><span id="L-220"><a href="#L-220"><span class="linenos">220</span></a> <span class="k">return</span> <span class="n">path</span> </span><span id="L-221"><a href="#L-221"><span class="linenos">221</span></a> -</span><span id="L-222"><a href="#L-222"><span class="linenos">222</span></a> <span class="n">HEREDOC_TAG_IS_IDENTIFIER</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="L-223"><a href="#L-223"><span class="linenos">223</span></a> <span class="n">HEREDOC_STRING_ALTERNATIVE</span> <span class="o">=</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PARAMETER</span> -</span><span id="L-224"><a href="#L-224"><span class="linenos">224</span></a> -</span><span id="L-225"><a href="#L-225"><span class="linenos">225</span></a> <span class="n">KEYWORDS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-226"><a href="#L-226"><span class="linenos">226</span></a> <span class="o">**</span><span class="n">tokens</span><span class="o">.</span><span class="n">Tokenizer</span><span class="o">.</span><span class="n">KEYWORDS</span><span class="p">,</span> -</span><span id="L-227"><a href="#L-227"><span class="linenos">227</span></a> <span class="s2">"//"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DIV</span><span class="p">,</span> -</span><span id="L-228"><a href="#L-228"><span class="linenos">228</span></a> <span class="s2">"ATTACH"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">COMMAND</span><span class="p">,</span> -</span><span id="L-229"><a href="#L-229"><span class="linenos">229</span></a> <span class="s2">"BINARY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VARBINARY</span><span class="p">,</span> -</span><span id="L-230"><a href="#L-230"><span class="linenos">230</span></a> <span class="s2">"BITSTRING"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BIT</span><span class="p">,</span> -</span><span id="L-231"><a href="#L-231"><span class="linenos">231</span></a> <span class="s2">"BPCHAR"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TEXT</span><span class="p">,</span> -</span><span id="L-232"><a href="#L-232"><span class="linenos">232</span></a> <span class="s2">"CHAR"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TEXT</span><span class="p">,</span> -</span><span id="L-233"><a href="#L-233"><span class="linenos">233</span></a> <span class="s2">"CHARACTER VARYING"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TEXT</span><span class="p">,</span> -</span><span id="L-234"><a href="#L-234"><span class="linenos">234</span></a> <span class="s2">"EXCLUDE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">EXCEPT</span><span class="p">,</span> -</span><span id="L-235"><a href="#L-235"><span class="linenos">235</span></a> <span class="s2">"LOGICAL"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BOOLEAN</span><span class="p">,</span> -</span><span id="L-236"><a href="#L-236"><span class="linenos">236</span></a> <span class="s2">"ONLY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ONLY</span><span class="p">,</span> -</span><span id="L-237"><a href="#L-237"><span class="linenos">237</span></a> <span class="s2">"PIVOT_WIDER"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PIVOT</span><span class="p">,</span> -</span><span id="L-238"><a href="#L-238"><span class="linenos">238</span></a> <span class="s2">"POSITIONAL"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">POSITIONAL</span><span class="p">,</span> -</span><span id="L-239"><a href="#L-239"><span class="linenos">239</span></a> <span class="s2">"SIGNED"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">INT</span><span class="p">,</span> -</span><span id="L-240"><a href="#L-240"><span class="linenos">240</span></a> <span class="s2">"STRING"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TEXT</span><span class="p">,</span> -</span><span id="L-241"><a href="#L-241"><span class="linenos">241</span></a> <span class="s2">"UBIGINT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">UBIGINT</span><span class="p">,</span> -</span><span id="L-242"><a href="#L-242"><span class="linenos">242</span></a> <span class="s2">"UINTEGER"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">UINT</span><span class="p">,</span> -</span><span id="L-243"><a href="#L-243"><span class="linenos">243</span></a> <span class="s2">"USMALLINT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">USMALLINT</span><span class="p">,</span> -</span><span id="L-244"><a href="#L-244"><span class="linenos">244</span></a> <span class="s2">"UTINYINT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">UTINYINT</span><span class="p">,</span> -</span><span id="L-245"><a href="#L-245"><span class="linenos">245</span></a> <span class="s2">"TIMESTAMP_S"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TIMESTAMP_S</span><span class="p">,</span> -</span><span id="L-246"><a href="#L-246"><span class="linenos">246</span></a> <span class="s2">"TIMESTAMP_MS"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TIMESTAMP_MS</span><span class="p">,</span> -</span><span id="L-247"><a href="#L-247"><span class="linenos">247</span></a> <span class="s2">"TIMESTAMP_NS"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TIMESTAMP_NS</span><span class="p">,</span> -</span><span id="L-248"><a href="#L-248"><span class="linenos">248</span></a> <span class="s2">"TIMESTAMP_US"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TIMESTAMP</span><span class="p">,</span> -</span><span id="L-249"><a href="#L-249"><span class="linenos">249</span></a> <span class="s2">"VARCHAR"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TEXT</span><span class="p">,</span> -</span><span id="L-250"><a href="#L-250"><span class="linenos">250</span></a> <span class="p">}</span> -</span><span id="L-251"><a href="#L-251"><span class="linenos">251</span></a> <span class="n">KEYWORDS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">"/*+"</span><span class="p">)</span> -</span><span id="L-252"><a href="#L-252"><span class="linenos">252</span></a> -</span><span id="L-253"><a href="#L-253"><span class="linenos">253</span></a> <span class="n">SINGLE_TOKENS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-254"><a href="#L-254"><span class="linenos">254</span></a> <span class="o">**</span><span class="n">tokens</span><span class="o">.</span><span class="n">Tokenizer</span><span class="o">.</span><span class="n">SINGLE_TOKENS</span><span class="p">,</span> -</span><span id="L-255"><a href="#L-255"><span class="linenos">255</span></a> <span class="s2">"$"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PARAMETER</span><span class="p">,</span> +</span><span id="L-222"><a href="#L-222"><span class="linenos">222</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">to_json_path</span><span class="p">(</span><span class="n">path</span><span class="p">)</span> +</span><span id="L-223"><a href="#L-223"><span class="linenos">223</span></a> +</span><span id="L-224"><a href="#L-224"><span class="linenos">224</span></a> <span class="k">class</span> <span class="nc">Tokenizer</span><span class="p">(</span><span class="n">tokens</span><span class="o">.</span><span class="n">Tokenizer</span><span class="p">):</span> +</span><span id="L-225"><a href="#L-225"><span class="linenos">225</span></a> <span class="n">HEREDOC_STRINGS</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"$"</span><span class="p">]</span> +</span><span id="L-226"><a href="#L-226"><span class="linenos">226</span></a> +</span><span id="L-227"><a href="#L-227"><span class="linenos">227</span></a> <span class="n">HEREDOC_TAG_IS_IDENTIFIER</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-228"><a href="#L-228"><span class="linenos">228</span></a> <span class="n">HEREDOC_STRING_ALTERNATIVE</span> <span class="o">=</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PARAMETER</span> +</span><span id="L-229"><a href="#L-229"><span class="linenos">229</span></a> +</span><span id="L-230"><a href="#L-230"><span class="linenos">230</span></a> <span class="n">KEYWORDS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-231"><a href="#L-231"><span class="linenos">231</span></a> <span class="o">**</span><span class="n">tokens</span><span class="o">.</span><span class="n">Tokenizer</span><span class="o">.</span><span class="n">KEYWORDS</span><span class="p">,</span> +</span><span id="L-232"><a href="#L-232"><span class="linenos">232</span></a> <span class="s2">"//"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DIV</span><span class="p">,</span> +</span><span id="L-233"><a href="#L-233"><span class="linenos">233</span></a> <span class="s2">"ATTACH"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">COMMAND</span><span class="p">,</span> +</span><span id="L-234"><a href="#L-234"><span class="linenos">234</span></a> <span class="s2">"BINARY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VARBINARY</span><span class="p">,</span> +</span><span id="L-235"><a href="#L-235"><span class="linenos">235</span></a> <span class="s2">"BITSTRING"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BIT</span><span class="p">,</span> +</span><span id="L-236"><a href="#L-236"><span class="linenos">236</span></a> <span class="s2">"BPCHAR"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TEXT</span><span class="p">,</span> +</span><span id="L-237"><a href="#L-237"><span class="linenos">237</span></a> <span class="s2">"CHAR"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TEXT</span><span class="p">,</span> +</span><span id="L-238"><a href="#L-238"><span class="linenos">238</span></a> <span class="s2">"CHARACTER VARYING"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TEXT</span><span class="p">,</span> +</span><span id="L-239"><a href="#L-239"><span class="linenos">239</span></a> <span class="s2">"EXCLUDE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">EXCEPT</span><span class="p">,</span> +</span><span id="L-240"><a href="#L-240"><span class="linenos">240</span></a> <span class="s2">"LOGICAL"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BOOLEAN</span><span class="p">,</span> +</span><span id="L-241"><a href="#L-241"><span class="linenos">241</span></a> <span class="s2">"ONLY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ONLY</span><span class="p">,</span> +</span><span id="L-242"><a href="#L-242"><span class="linenos">242</span></a> <span class="s2">"PIVOT_WIDER"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PIVOT</span><span class="p">,</span> +</span><span id="L-243"><a href="#L-243"><span class="linenos">243</span></a> <span class="s2">"POSITIONAL"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">POSITIONAL</span><span class="p">,</span> +</span><span id="L-244"><a href="#L-244"><span class="linenos">244</span></a> <span class="s2">"SIGNED"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">INT</span><span class="p">,</span> +</span><span id="L-245"><a href="#L-245"><span class="linenos">245</span></a> <span class="s2">"STRING"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TEXT</span><span class="p">,</span> +</span><span id="L-246"><a href="#L-246"><span class="linenos">246</span></a> <span class="s2">"SUMMARIZE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SUMMARIZE</span><span class="p">,</span> +</span><span id="L-247"><a href="#L-247"><span class="linenos">247</span></a> <span class="s2">"TIMESTAMP_S"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TIMESTAMP_S</span><span class="p">,</span> +</span><span id="L-248"><a href="#L-248"><span class="linenos">248</span></a> <span class="s2">"TIMESTAMP_MS"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TIMESTAMP_MS</span><span class="p">,</span> +</span><span id="L-249"><a href="#L-249"><span class="linenos">249</span></a> <span class="s2">"TIMESTAMP_NS"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TIMESTAMP_NS</span><span class="p">,</span> +</span><span id="L-250"><a href="#L-250"><span class="linenos">250</span></a> <span class="s2">"TIMESTAMP_US"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TIMESTAMP</span><span class="p">,</span> +</span><span id="L-251"><a href="#L-251"><span class="linenos">251</span></a> <span class="s2">"UBIGINT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">UBIGINT</span><span class="p">,</span> +</span><span id="L-252"><a href="#L-252"><span class="linenos">252</span></a> <span class="s2">"UINTEGER"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">UINT</span><span class="p">,</span> +</span><span id="L-253"><a href="#L-253"><span class="linenos">253</span></a> <span class="s2">"USMALLINT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">USMALLINT</span><span class="p">,</span> +</span><span id="L-254"><a href="#L-254"><span class="linenos">254</span></a> <span class="s2">"UTINYINT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">UTINYINT</span><span class="p">,</span> +</span><span id="L-255"><a href="#L-255"><span class="linenos">255</span></a> <span class="s2">"VARCHAR"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TEXT</span><span class="p">,</span> </span><span id="L-256"><a href="#L-256"><span class="linenos">256</span></a> <span class="p">}</span> -</span><span id="L-257"><a href="#L-257"><span class="linenos">257</span></a> -</span><span id="L-258"><a href="#L-258"><span class="linenos">258</span></a> <span class="k">class</span> <span class="nc">Parser</span><span class="p">(</span><span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="p">):</span> -</span><span id="L-259"><a href="#L-259"><span class="linenos">259</span></a> <span class="n">BITWISE</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-260"><a href="#L-260"><span class="linenos">260</span></a> <span class="o">**</span><span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">BITWISE</span><span class="p">,</span> -</span><span id="L-261"><a href="#L-261"><span class="linenos">261</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">TILDA</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpLike</span><span class="p">,</span> +</span><span id="L-257"><a href="#L-257"><span class="linenos">257</span></a> <span class="n">KEYWORDS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">"/*+"</span><span class="p">)</span> +</span><span id="L-258"><a href="#L-258"><span class="linenos">258</span></a> +</span><span id="L-259"><a href="#L-259"><span class="linenos">259</span></a> <span class="n">SINGLE_TOKENS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-260"><a href="#L-260"><span class="linenos">260</span></a> <span class="o">**</span><span class="n">tokens</span><span class="o">.</span><span class="n">Tokenizer</span><span class="o">.</span><span class="n">SINGLE_TOKENS</span><span class="p">,</span> +</span><span id="L-261"><a href="#L-261"><span class="linenos">261</span></a> <span class="s2">"$"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PARAMETER</span><span class="p">,</span> </span><span id="L-262"><a href="#L-262"><span class="linenos">262</span></a> <span class="p">}</span> </span><span id="L-263"><a href="#L-263"><span class="linenos">263</span></a> -</span><span id="L-264"><a href="#L-264"><span class="linenos">264</span></a> <span class="n">FUNCTIONS_WITH_ALIASED_ARGS</span> <span class="o">=</span> <span class="p">{</span><span class="o">*</span><span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">FUNCTIONS_WITH_ALIASED_ARGS</span><span class="p">,</span> <span class="s2">"STRUCT_PACK"</span><span class="p">}</span> -</span><span id="L-265"><a href="#L-265"><span class="linenos">265</span></a> -</span><span id="L-266"><a href="#L-266"><span class="linenos">266</span></a> <span class="n">FUNCTIONS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-267"><a href="#L-267"><span class="linenos">267</span></a> <span class="o">**</span><span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">FUNCTIONS</span><span class="p">,</span> -</span><span id="L-268"><a href="#L-268"><span class="linenos">268</span></a> <span class="s2">"ARRAY_REVERSE_SORT"</span><span class="p">:</span> <span class="n">_build_sort_array_desc</span><span class="p">,</span> -</span><span id="L-269"><a href="#L-269"><span class="linenos">269</span></a> <span class="s2">"ARRAY_SORT"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SortArray</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="L-270"><a href="#L-270"><span class="linenos">270</span></a> <span class="s2">"DATEDIFF"</span><span class="p">:</span> <span class="n">_build_date_diff</span><span class="p">,</span> -</span><span id="L-271"><a href="#L-271"><span class="linenos">271</span></a> <span class="s2">"DATE_DIFF"</span><span class="p">:</span> <span class="n">_build_date_diff</span><span class="p">,</span> -</span><span id="L-272"><a href="#L-272"><span class="linenos">272</span></a> <span class="s2">"DATE_TRUNC"</span><span class="p">:</span> <span class="n">date_trunc_to_time</span><span class="p">,</span> -</span><span id="L-273"><a href="#L-273"><span class="linenos">273</span></a> <span class="s2">"DATETRUNC"</span><span class="p">:</span> <span class="n">date_trunc_to_time</span><span class="p">,</span> -</span><span id="L-274"><a href="#L-274"><span class="linenos">274</span></a> <span class="s2">"DECODE"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Decode</span><span class="p">(</span> -</span><span id="L-275"><a href="#L-275"><span class="linenos">275</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">charset</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">string</span><span class="p">(</span><span class="s2">"utf-8"</span><span class="p">)</span> -</span><span id="L-276"><a href="#L-276"><span class="linenos">276</span></a> <span class="p">),</span> -</span><span id="L-277"><a href="#L-277"><span class="linenos">277</span></a> <span class="s2">"ENCODE"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Encode</span><span class="p">(</span> -</span><span id="L-278"><a href="#L-278"><span class="linenos">278</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">charset</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">string</span><span class="p">(</span><span class="s2">"utf-8"</span><span class="p">)</span> -</span><span id="L-279"><a href="#L-279"><span class="linenos">279</span></a> <span class="p">),</span> -</span><span id="L-280"><a href="#L-280"><span class="linenos">280</span></a> <span class="s2">"EPOCH"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TimeToUnix</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="L-281"><a href="#L-281"><span class="linenos">281</span></a> <span class="s2">"EPOCH_MS"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToTime</span><span class="p">(</span> -</span><span id="L-282"><a href="#L-282"><span class="linenos">282</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">scale</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">UnixToTime</span><span class="o">.</span><span class="n">MILLIS</span> -</span><span id="L-283"><a href="#L-283"><span class="linenos">283</span></a> <span class="p">),</span> -</span><span id="L-284"><a href="#L-284"><span class="linenos">284</span></a> <span class="s2">"JSON"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ParseJSON</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="L-285"><a href="#L-285"><span class="linenos">285</span></a> <span class="s2">"JSON_EXTRACT_PATH"</span><span class="p">:</span> <span class="n">parser</span><span class="o">.</span><span class="n">build_extract_json_with_path</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">JSONExtract</span><span class="p">),</span> -</span><span id="L-286"><a href="#L-286"><span class="linenos">286</span></a> <span class="s2">"JSON_EXTRACT_STRING"</span><span class="p">:</span> <span class="n">parser</span><span class="o">.</span><span class="n">build_extract_json_with_path</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">JSONExtractScalar</span><span class="p">),</span> -</span><span id="L-287"><a href="#L-287"><span class="linenos">287</span></a> <span class="s2">"LIST_HAS"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayContains</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="L-288"><a href="#L-288"><span class="linenos">288</span></a> <span class="s2">"LIST_REVERSE_SORT"</span><span class="p">:</span> <span class="n">_build_sort_array_desc</span><span class="p">,</span> -</span><span id="L-289"><a href="#L-289"><span class="linenos">289</span></a> <span class="s2">"LIST_SORT"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SortArray</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="L-290"><a href="#L-290"><span class="linenos">290</span></a> <span class="s2">"LIST_VALUE"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Array</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="L-291"><a href="#L-291"><span class="linenos">291</span></a> <span class="s2">"MAKE_TIME"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TimeFromParts</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="L-292"><a href="#L-292"><span class="linenos">292</span></a> <span class="s2">"MAKE_TIMESTAMP"</span><span class="p">:</span> <span class="n">_build_make_timestamp</span><span class="p">,</span> -</span><span id="L-293"><a href="#L-293"><span class="linenos">293</span></a> <span class="s2">"MEDIAN"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">PercentileCont</span><span class="p">(</span> -</span><span id="L-294"><a href="#L-294"><span class="linenos">294</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">number</span><span class="p">(</span><span class="mf">0.5</span><span class="p">)</span> -</span><span id="L-295"><a href="#L-295"><span class="linenos">295</span></a> <span class="p">),</span> -</span><span id="L-296"><a href="#L-296"><span class="linenos">296</span></a> <span class="s2">"QUANTILE_CONT"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">PercentileCont</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="L-297"><a href="#L-297"><span class="linenos">297</span></a> <span class="s2">"QUANTILE_DISC"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">PercentileDisc</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="L-298"><a href="#L-298"><span class="linenos">298</span></a> <span class="s2">"REGEXP_EXTRACT"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpExtract</span><span class="p">(</span> -</span><span id="L-299"><a href="#L-299"><span class="linenos">299</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">expression</span><span class="o">=</span><span class="n">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 class="n">group</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">2</span><span class="p">)</span> -</span><span id="L-300"><a href="#L-300"><span class="linenos">300</span></a> <span class="p">),</span> -</span><span id="L-301"><a href="#L-301"><span class="linenos">301</span></a> <span class="s2">"REGEXP_MATCHES"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpLike</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="L-302"><a href="#L-302"><span class="linenos">302</span></a> <span class="s2">"REGEXP_REPLACE"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpReplace</span><span class="p">(</span> -</span><span id="L-303"><a href="#L-303"><span class="linenos">303</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> -</span><span id="L-304"><a href="#L-304"><span class="linenos">304</span></a> <span class="n">expression</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-305"><a href="#L-305"><span class="linenos">305</span></a> <span class="n">replacement</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">2</span><span class="p">),</span> -</span><span id="L-306"><a href="#L-306"><span class="linenos">306</span></a> <span class="n">modifiers</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">3</span><span class="p">),</span> -</span><span id="L-307"><a href="#L-307"><span class="linenos">307</span></a> <span class="p">),</span> -</span><span id="L-308"><a href="#L-308"><span class="linenos">308</span></a> <span class="s2">"STRFTIME"</span><span class="p">:</span> <span class="n">build_formatted_time</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">TimeToStr</span><span class="p">,</span> <span class="s2">"duckdb"</span><span class="p">),</span> -</span><span id="L-309"><a href="#L-309"><span class="linenos">309</span></a> <span class="s2">"STRING_SPLIT"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Split</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="L-310"><a href="#L-310"><span class="linenos">310</span></a> <span class="s2">"STRING_SPLIT_REGEX"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpSplit</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="L-311"><a href="#L-311"><span class="linenos">311</span></a> <span class="s2">"STRING_TO_ARRAY"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Split</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="L-312"><a href="#L-312"><span class="linenos">312</span></a> <span class="s2">"STRPTIME"</span><span class="p">:</span> <span class="n">build_formatted_time</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">StrToTime</span><span class="p">,</span> <span class="s2">"duckdb"</span><span class="p">),</span> -</span><span id="L-313"><a href="#L-313"><span class="linenos">313</span></a> <span class="s2">"STRUCT_PACK"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Struct</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="L-314"><a href="#L-314"><span class="linenos">314</span></a> <span class="s2">"STR_SPLIT"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Split</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="L-315"><a href="#L-315"><span class="linenos">315</span></a> <span class="s2">"STR_SPLIT_REGEX"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpSplit</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="L-316"><a href="#L-316"><span class="linenos">316</span></a> <span class="s2">"TO_TIMESTAMP"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToTime</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="L-317"><a href="#L-317"><span class="linenos">317</span></a> <span class="s2">"UNNEST"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Explode</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="L-318"><a href="#L-318"><span class="linenos">318</span></a> <span class="s2">"XOR"</span><span class="p">:</span> <span class="n">binary_from_function</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">BitwiseXor</span><span class="p">),</span> -</span><span id="L-319"><a href="#L-319"><span class="linenos">319</span></a> <span class="s2">"GENERATE_SERIES"</span><span class="p">:</span> <span class="n">_build_generate_series</span><span class="p">(),</span> -</span><span id="L-320"><a href="#L-320"><span class="linenos">320</span></a> <span class="s2">"RANGE"</span><span class="p">:</span> <span class="n">_build_generate_series</span><span class="p">(</span><span class="n">end_exclusive</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> -</span><span id="L-321"><a href="#L-321"><span class="linenos">321</span></a> <span class="p">}</span> -</span><span id="L-322"><a href="#L-322"><span class="linenos">322</span></a> -</span><span id="L-323"><a href="#L-323"><span class="linenos">323</span></a> <span class="n">FUNCTIONS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">"DATE_SUB"</span><span class="p">)</span> -</span><span id="L-324"><a href="#L-324"><span class="linenos">324</span></a> -</span><span id="L-325"><a href="#L-325"><span class="linenos">325</span></a> <span class="n">FUNCTION_PARSERS</span> <span class="o">=</span> <span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">FUNCTION_PARSERS</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> -</span><span id="L-326"><a href="#L-326"><span class="linenos">326</span></a> <span class="n">FUNCTION_PARSERS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">"DECODE"</span><span class="p">)</span> -</span><span id="L-327"><a href="#L-327"><span class="linenos">327</span></a> -</span><span id="L-328"><a href="#L-328"><span class="linenos">328</span></a> <span class="n">NO_PAREN_FUNCTION_PARSERS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-329"><a href="#L-329"><span class="linenos">329</span></a> <span class="o">**</span><span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">NO_PAREN_FUNCTION_PARSERS</span><span class="p">,</span> -</span><span id="L-330"><a href="#L-330"><span class="linenos">330</span></a> <span class="s2">"MAP"</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_map</span><span class="p">(),</span> -</span><span id="L-331"><a href="#L-331"><span class="linenos">331</span></a> <span class="p">}</span> -</span><span id="L-332"><a href="#L-332"><span class="linenos">332</span></a> -</span><span id="L-333"><a href="#L-333"><span class="linenos">333</span></a> <span class="n">TABLE_ALIAS_TOKENS</span> <span class="o">=</span> <span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">TABLE_ALIAS_TOKENS</span> <span class="o">-</span> <span class="p">{</span> -</span><span id="L-334"><a href="#L-334"><span class="linenos">334</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">SEMI</span><span class="p">,</span> -</span><span id="L-335"><a href="#L-335"><span class="linenos">335</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">ANTI</span><span class="p">,</span> -</span><span id="L-336"><a href="#L-336"><span class="linenos">336</span></a> <span class="p">}</span> -</span><span id="L-337"><a href="#L-337"><span class="linenos">337</span></a> -</span><span id="L-338"><a href="#L-338"><span class="linenos">338</span></a> <span class="n">PLACEHOLDER_PARSERS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-339"><a href="#L-339"><span class="linenos">339</span></a> <span class="o">**</span><span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">PLACEHOLDER_PARSERS</span><span class="p">,</span> -</span><span id="L-340"><a href="#L-340"><span class="linenos">340</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">PARAMETER</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">:</span> <span class="p">(</span> -</span><span id="L-341"><a href="#L-341"><span class="linenos">341</span></a> <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">Placeholder</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">_prev</span><span class="o">.</span><span class="n">text</span><span class="p">)</span> -</span><span id="L-342"><a href="#L-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">NUMBER</span><span class="p">)</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_set</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">ID_VAR_TOKENS</span><span class="p">)</span> -</span><span id="L-343"><a href="#L-343"><span class="linenos">343</span></a> <span class="k">else</span> <span class="kc">None</span> -</span><span id="L-344"><a href="#L-344"><span class="linenos">344</span></a> <span class="p">),</span> -</span><span id="L-345"><a href="#L-345"><span class="linenos">345</span></a> <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="n">TYPE_CONVERTERS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-348"><a href="#L-348"><span class="linenos">348</span></a> <span class="c1"># https://duckdb.org/docs/sql/data_types/numeric</span> -</span><span id="L-349"><a href="#L-349"><span class="linenos">349</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">DECIMAL</span><span class="p">:</span> <span class="n">build_default_decimal_type</span><span class="p">(</span><span class="n">precision</span><span class="o">=</span><span class="mi">18</span><span class="p">,</span> <span class="n">scale</span><span class="o">=</span><span class="mi">3</span><span class="p">),</span> -</span><span id="L-350"><a href="#L-350"><span class="linenos">350</span></a> <span class="c1"># https://duckdb.org/docs/sql/data_types/text</span> -</span><span id="L-351"><a href="#L-351"><span class="linenos">351</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">TEXT</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">dtype</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">build</span><span class="p">(</span><span class="s2">"TEXT"</span><span class="p">),</span> -</span><span id="L-352"><a href="#L-352"><span class="linenos">352</span></a> <span class="p">}</span> -</span><span id="L-353"><a href="#L-353"><span class="linenos">353</span></a> -</span><span id="L-354"><a href="#L-354"><span class="linenos">354</span></a> <span class="k">def</span> <span class="nf">_parse_table_sample</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">as_modifier</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">TableSample</span><span class="p">]:</span> -</span><span id="L-355"><a href="#L-355"><span class="linenos">355</span></a> <span class="c1"># https://duckdb.org/docs/sql/samples.html</span> -</span><span id="L-356"><a href="#L-356"><span class="linenos">356</span></a> <span class="n">sample</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_parse_table_sample</span><span class="p">(</span><span class="n">as_modifier</span><span class="o">=</span><span class="n">as_modifier</span><span class="p">)</span> -</span><span id="L-357"><a href="#L-357"><span class="linenos">357</span></a> <span class="k">if</span> <span class="n">sample</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">sample</span><span 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-358"><a href="#L-358"><span class="linenos">358</span></a> <span class="k">if</span> <span class="n">sample</span><span 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-359"><a href="#L-359"><span class="linenos">359</span></a> <span class="n">sample</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-360"><a href="#L-360"><span class="linenos">360</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-361"><a href="#L-361"><span class="linenos">361</span></a> <span class="n">sample</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">"SYSTEM"</span><span class="p">))</span> -</span><span id="L-362"><a href="#L-362"><span class="linenos">362</span></a> -</span><span id="L-363"><a href="#L-363"><span class="linenos">363</span></a> <span class="k">return</span> <span class="n">sample</span> -</span><span id="L-364"><a href="#L-364"><span class="linenos">364</span></a> -</span><span id="L-365"><a href="#L-365"><span class="linenos">365</span></a> <span class="k">def</span> <span class="nf">_parse_bracket</span><span class="p">(</span> -</span><span id="L-366"><a href="#L-366"><span class="linenos">366</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">this</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-367"><a href="#L-367"><span class="linenos">367</span></a> <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> -</span><span id="L-368"><a href="#L-368"><span class="linenos">368</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">_parse_bracket</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> -</span><span id="L-369"><a href="#L-369"><span class="linenos">369</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">bracket</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Bracket</span><span class="p">):</span> -</span><span id="L-370"><a href="#L-370"><span class="linenos">370</span></a> <span class="n">bracket</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"returns_list_for_maps"</span><span class="p">,</span> <span class="kc">True</span><span class="p">)</span> -</span><span id="L-371"><a href="#L-371"><span class="linenos">371</span></a> -</span><span id="L-372"><a href="#L-372"><span class="linenos">372</span></a> <span class="k">return</span> <span class="n">bracket</span> -</span><span id="L-373"><a href="#L-373"><span class="linenos">373</span></a> -</span><span id="L-374"><a href="#L-374"><span class="linenos">374</span></a> <span class="k">def</span> <span class="nf">_parse_map</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">ToMap</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Map</span><span class="p">:</span> -</span><span id="L-375"><a href="#L-375"><span class="linenos">375</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-376"><a href="#L-376"><span class="linenos">376</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-264"><a href="#L-264"><span class="linenos">264</span></a> <span class="k">class</span> <span class="nc">Parser</span><span class="p">(</span><span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="p">):</span> +</span><span id="L-265"><a href="#L-265"><span class="linenos">265</span></a> <span class="n">BITWISE</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-266"><a href="#L-266"><span class="linenos">266</span></a> <span class="o">**</span><span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">BITWISE</span><span class="p">,</span> +</span><span id="L-267"><a href="#L-267"><span class="linenos">267</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">TILDA</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpLike</span><span class="p">,</span> +</span><span id="L-268"><a href="#L-268"><span class="linenos">268</span></a> <span class="p">}</span> +</span><span id="L-269"><a href="#L-269"><span class="linenos">269</span></a> +</span><span id="L-270"><a href="#L-270"><span class="linenos">270</span></a> <span class="n">FUNCTIONS_WITH_ALIASED_ARGS</span> <span class="o">=</span> <span class="p">{</span><span class="o">*</span><span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">FUNCTIONS_WITH_ALIASED_ARGS</span><span class="p">,</span> <span class="s2">"STRUCT_PACK"</span><span class="p">}</span> +</span><span id="L-271"><a href="#L-271"><span class="linenos">271</span></a> +</span><span id="L-272"><a href="#L-272"><span class="linenos">272</span></a> <span class="n">FUNCTIONS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-273"><a href="#L-273"><span class="linenos">273</span></a> <span class="o">**</span><span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">FUNCTIONS</span><span class="p">,</span> +</span><span id="L-274"><a href="#L-274"><span class="linenos">274</span></a> <span class="s2">"ARRAY_REVERSE_SORT"</span><span class="p">:</span> <span class="n">_build_sort_array_desc</span><span class="p">,</span> +</span><span id="L-275"><a href="#L-275"><span class="linenos">275</span></a> <span class="s2">"ARRAY_SORT"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SortArray</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="L-276"><a href="#L-276"><span class="linenos">276</span></a> <span class="s2">"DATEDIFF"</span><span class="p">:</span> <span class="n">_build_date_diff</span><span class="p">,</span> +</span><span id="L-277"><a href="#L-277"><span class="linenos">277</span></a> <span class="s2">"DATE_DIFF"</span><span class="p">:</span> <span class="n">_build_date_diff</span><span class="p">,</span> +</span><span id="L-278"><a href="#L-278"><span class="linenos">278</span></a> <span class="s2">"DATE_TRUNC"</span><span class="p">:</span> <span class="n">date_trunc_to_time</span><span class="p">,</span> +</span><span id="L-279"><a href="#L-279"><span class="linenos">279</span></a> <span class="s2">"DATETRUNC"</span><span class="p">:</span> <span class="n">date_trunc_to_time</span><span class="p">,</span> +</span><span id="L-280"><a href="#L-280"><span class="linenos">280</span></a> <span class="s2">"DECODE"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Decode</span><span class="p">(</span> +</span><span id="L-281"><a href="#L-281"><span class="linenos">281</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">charset</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">string</span><span class="p">(</span><span class="s2">"utf-8"</span><span class="p">)</span> +</span><span id="L-282"><a href="#L-282"><span class="linenos">282</span></a> <span class="p">),</span> +</span><span id="L-283"><a href="#L-283"><span class="linenos">283</span></a> <span class="s2">"ENCODE"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Encode</span><span class="p">(</span> +</span><span id="L-284"><a href="#L-284"><span class="linenos">284</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">charset</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">string</span><span class="p">(</span><span class="s2">"utf-8"</span><span class="p">)</span> +</span><span id="L-285"><a href="#L-285"><span class="linenos">285</span></a> <span class="p">),</span> +</span><span id="L-286"><a href="#L-286"><span class="linenos">286</span></a> <span class="s2">"EPOCH"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TimeToUnix</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="L-287"><a href="#L-287"><span class="linenos">287</span></a> <span class="s2">"EPOCH_MS"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToTime</span><span class="p">(</span> +</span><span id="L-288"><a href="#L-288"><span class="linenos">288</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">scale</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">UnixToTime</span><span class="o">.</span><span class="n">MILLIS</span> +</span><span id="L-289"><a href="#L-289"><span class="linenos">289</span></a> <span class="p">),</span> +</span><span id="L-290"><a href="#L-290"><span class="linenos">290</span></a> <span class="s2">"JSON"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ParseJSON</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="L-291"><a href="#L-291"><span class="linenos">291</span></a> <span class="s2">"JSON_EXTRACT_PATH"</span><span class="p">:</span> <span class="n">parser</span><span class="o">.</span><span class="n">build_extract_json_with_path</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">JSONExtract</span><span class="p">),</span> +</span><span id="L-292"><a href="#L-292"><span class="linenos">292</span></a> <span class="s2">"JSON_EXTRACT_STRING"</span><span class="p">:</span> <span class="n">parser</span><span class="o">.</span><span class="n">build_extract_json_with_path</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">JSONExtractScalar</span><span class="p">),</span> +</span><span id="L-293"><a href="#L-293"><span class="linenos">293</span></a> <span class="s2">"LIST_HAS"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayContains</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="L-294"><a href="#L-294"><span class="linenos">294</span></a> <span class="s2">"LIST_REVERSE_SORT"</span><span class="p">:</span> <span class="n">_build_sort_array_desc</span><span class="p">,</span> +</span><span id="L-295"><a href="#L-295"><span class="linenos">295</span></a> <span class="s2">"LIST_SORT"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SortArray</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="L-296"><a href="#L-296"><span class="linenos">296</span></a> <span class="s2">"LIST_VALUE"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Array</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="L-297"><a href="#L-297"><span class="linenos">297</span></a> <span class="s2">"MAKE_TIME"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TimeFromParts</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="L-298"><a href="#L-298"><span class="linenos">298</span></a> <span class="s2">"MAKE_TIMESTAMP"</span><span class="p">:</span> <span class="n">_build_make_timestamp</span><span class="p">,</span> +</span><span id="L-299"><a href="#L-299"><span class="linenos">299</span></a> <span class="s2">"MEDIAN"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">PercentileCont</span><span class="p">(</span> +</span><span id="L-300"><a href="#L-300"><span class="linenos">300</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">number</span><span class="p">(</span><span class="mf">0.5</span><span class="p">)</span> +</span><span id="L-301"><a href="#L-301"><span class="linenos">301</span></a> <span class="p">),</span> +</span><span id="L-302"><a href="#L-302"><span class="linenos">302</span></a> <span class="s2">"QUANTILE_CONT"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">PercentileCont</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="L-303"><a href="#L-303"><span class="linenos">303</span></a> <span class="s2">"QUANTILE_DISC"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">PercentileDisc</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="L-304"><a href="#L-304"><span class="linenos">304</span></a> <span class="s2">"REGEXP_EXTRACT"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpExtract</span><span class="p">(</span> +</span><span id="L-305"><a href="#L-305"><span class="linenos">305</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">expression</span><span class="o">=</span><span class="n">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 class="n">group</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">2</span><span class="p">)</span> +</span><span id="L-306"><a href="#L-306"><span class="linenos">306</span></a> <span class="p">),</span> +</span><span id="L-307"><a href="#L-307"><span class="linenos">307</span></a> <span class="s2">"REGEXP_MATCHES"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpLike</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="L-308"><a href="#L-308"><span class="linenos">308</span></a> <span class="s2">"REGEXP_REPLACE"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpReplace</span><span class="p">(</span> +</span><span id="L-309"><a href="#L-309"><span class="linenos">309</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> +</span><span id="L-310"><a href="#L-310"><span class="linenos">310</span></a> <span class="n">expression</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-311"><a href="#L-311"><span class="linenos">311</span></a> <span class="n">replacement</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">2</span><span class="p">),</span> +</span><span id="L-312"><a href="#L-312"><span class="linenos">312</span></a> <span class="n">modifiers</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">3</span><span class="p">),</span> +</span><span id="L-313"><a href="#L-313"><span class="linenos">313</span></a> <span class="p">),</span> +</span><span id="L-314"><a href="#L-314"><span class="linenos">314</span></a> <span class="s2">"STRFTIME"</span><span class="p">:</span> <span class="n">build_formatted_time</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">TimeToStr</span><span class="p">,</span> <span class="s2">"duckdb"</span><span class="p">),</span> +</span><span id="L-315"><a href="#L-315"><span class="linenos">315</span></a> <span class="s2">"STRING_SPLIT"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Split</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="L-316"><a href="#L-316"><span class="linenos">316</span></a> <span class="s2">"STRING_SPLIT_REGEX"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpSplit</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="L-317"><a href="#L-317"><span class="linenos">317</span></a> <span class="s2">"STRING_TO_ARRAY"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Split</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="L-318"><a href="#L-318"><span class="linenos">318</span></a> <span class="s2">"STRPTIME"</span><span class="p">:</span> <span class="n">build_formatted_time</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">StrToTime</span><span class="p">,</span> <span class="s2">"duckdb"</span><span class="p">),</span> +</span><span id="L-319"><a href="#L-319"><span class="linenos">319</span></a> <span class="s2">"STRUCT_PACK"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Struct</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="L-320"><a href="#L-320"><span class="linenos">320</span></a> <span class="s2">"STR_SPLIT"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Split</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="L-321"><a href="#L-321"><span class="linenos">321</span></a> <span class="s2">"STR_SPLIT_REGEX"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpSplit</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="L-322"><a href="#L-322"><span class="linenos">322</span></a> <span class="s2">"TO_TIMESTAMP"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToTime</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="L-323"><a href="#L-323"><span class="linenos">323</span></a> <span class="s2">"UNNEST"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Explode</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="L-324"><a href="#L-324"><span class="linenos">324</span></a> <span class="s2">"XOR"</span><span class="p">:</span> <span class="n">binary_from_function</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">BitwiseXor</span><span class="p">),</span> +</span><span id="L-325"><a href="#L-325"><span class="linenos">325</span></a> <span class="s2">"GENERATE_SERIES"</span><span class="p">:</span> <span class="n">_build_generate_series</span><span class="p">(),</span> +</span><span id="L-326"><a href="#L-326"><span class="linenos">326</span></a> <span class="s2">"RANGE"</span><span class="p">:</span> <span class="n">_build_generate_series</span><span class="p">(</span><span class="n">end_exclusive</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> +</span><span id="L-327"><a href="#L-327"><span class="linenos">327</span></a> <span class="p">}</span> +</span><span id="L-328"><a href="#L-328"><span class="linenos">328</span></a> +</span><span id="L-329"><a href="#L-329"><span class="linenos">329</span></a> <span class="n">FUNCTIONS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">"DATE_SUB"</span><span class="p">)</span> +</span><span id="L-330"><a href="#L-330"><span class="linenos">330</span></a> +</span><span id="L-331"><a href="#L-331"><span class="linenos">331</span></a> <span class="n">FUNCTION_PARSERS</span> <span class="o">=</span> <span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">FUNCTION_PARSERS</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> +</span><span id="L-332"><a href="#L-332"><span class="linenos">332</span></a> <span class="n">FUNCTION_PARSERS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">"DECODE"</span><span class="p">)</span> +</span><span id="L-333"><a href="#L-333"><span class="linenos">333</span></a> +</span><span id="L-334"><a href="#L-334"><span class="linenos">334</span></a> <span class="n">NO_PAREN_FUNCTION_PARSERS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-335"><a href="#L-335"><span class="linenos">335</span></a> <span class="o">**</span><span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">NO_PAREN_FUNCTION_PARSERS</span><span class="p">,</span> +</span><span id="L-336"><a href="#L-336"><span class="linenos">336</span></a> <span class="s2">"MAP"</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_map</span><span class="p">(),</span> +</span><span id="L-337"><a href="#L-337"><span class="linenos">337</span></a> <span class="p">}</span> +</span><span id="L-338"><a href="#L-338"><span class="linenos">338</span></a> +</span><span id="L-339"><a href="#L-339"><span class="linenos">339</span></a> <span class="n">TABLE_ALIAS_TOKENS</span> <span class="o">=</span> <span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">TABLE_ALIAS_TOKENS</span> <span class="o">-</span> <span class="p">{</span> +</span><span id="L-340"><a href="#L-340"><span class="linenos">340</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">SEMI</span><span class="p">,</span> +</span><span id="L-341"><a href="#L-341"><span class="linenos">341</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">ANTI</span><span class="p">,</span> +</span><span id="L-342"><a href="#L-342"><span class="linenos">342</span></a> <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">PLACEHOLDER_PARSERS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-345"><a href="#L-345"><span class="linenos">345</span></a> <span class="o">**</span><span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">PLACEHOLDER_PARSERS</span><span class="p">,</span> +</span><span id="L-346"><a href="#L-346"><span class="linenos">346</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">PARAMETER</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">:</span> <span class="p">(</span> +</span><span id="L-347"><a href="#L-347"><span class="linenos">347</span></a> <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">Placeholder</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">_prev</span><span class="o">.</span><span class="n">text</span><span class="p">)</span> +</span><span id="L-348"><a href="#L-348"><span class="linenos">348</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">NUMBER</span><span class="p">)</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_set</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">ID_VAR_TOKENS</span><span class="p">)</span> +</span><span id="L-349"><a href="#L-349"><span class="linenos">349</span></a> <span class="k">else</span> <span class="kc">None</span> +</span><span id="L-350"><a href="#L-350"><span class="linenos">350</span></a> <span class="p">),</span> +</span><span id="L-351"><a href="#L-351"><span class="linenos">351</span></a> <span class="p">}</span> +</span><span id="L-352"><a href="#L-352"><span class="linenos">352</span></a> +</span><span id="L-353"><a href="#L-353"><span class="linenos">353</span></a> <span class="n">TYPE_CONVERTERS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-354"><a href="#L-354"><span class="linenos">354</span></a> <span class="c1"># https://duckdb.org/docs/sql/data_types/numeric</span> +</span><span id="L-355"><a href="#L-355"><span class="linenos">355</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">DECIMAL</span><span class="p">:</span> <span class="n">build_default_decimal_type</span><span class="p">(</span><span class="n">precision</span><span class="o">=</span><span class="mi">18</span><span class="p">,</span> <span class="n">scale</span><span class="o">=</span><span class="mi">3</span><span class="p">),</span> +</span><span id="L-356"><a href="#L-356"><span class="linenos">356</span></a> <span class="c1"># https://duckdb.org/docs/sql/data_types/text</span> +</span><span id="L-357"><a href="#L-357"><span class="linenos">357</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">TEXT</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">dtype</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">build</span><span class="p">(</span><span class="s2">"TEXT"</span><span class="p">),</span> +</span><span id="L-358"><a href="#L-358"><span class="linenos">358</span></a> <span class="p">}</span> +</span><span id="L-359"><a href="#L-359"><span class="linenos">359</span></a> +</span><span id="L-360"><a href="#L-360"><span class="linenos">360</span></a> <span class="k">def</span> <span class="nf">_parse_table_sample</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">as_modifier</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">TableSample</span><span class="p">]:</span> +</span><span id="L-361"><a href="#L-361"><span class="linenos">361</span></a> <span class="c1"># https://duckdb.org/docs/sql/samples.html</span> +</span><span id="L-362"><a href="#L-362"><span class="linenos">362</span></a> <span class="n">sample</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_parse_table_sample</span><span class="p">(</span><span class="n">as_modifier</span><span class="o">=</span><span class="n">as_modifier</span><span class="p">)</span> +</span><span id="L-363"><a href="#L-363"><span class="linenos">363</span></a> <span class="k">if</span> <span class="n">sample</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">sample</span><span 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-364"><a href="#L-364"><span class="linenos">364</span></a> <span class="k">if</span> <span class="n">sample</span><span 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-365"><a href="#L-365"><span class="linenos">365</span></a> <span class="n">sample</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-366"><a href="#L-366"><span class="linenos">366</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-367"><a href="#L-367"><span class="linenos">367</span></a> <span class="n">sample</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">"SYSTEM"</span><span class="p">))</span> +</span><span id="L-368"><a href="#L-368"><span class="linenos">368</span></a> +</span><span id="L-369"><a href="#L-369"><span class="linenos">369</span></a> <span class="k">return</span> <span class="n">sample</span> +</span><span id="L-370"><a href="#L-370"><span class="linenos">370</span></a> +</span><span id="L-371"><a href="#L-371"><span class="linenos">371</span></a> <span class="k">def</span> <span class="nf">_parse_bracket</span><span class="p">(</span> +</span><span id="L-372"><a href="#L-372"><span class="linenos">372</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">this</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-373"><a href="#L-373"><span class="linenos">373</span></a> <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> +</span><span id="L-374"><a href="#L-374"><span class="linenos">374</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">_parse_bracket</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> +</span><span id="L-375"><a href="#L-375"><span class="linenos">375</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">bracket</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Bracket</span><span class="p">):</span> +</span><span id="L-376"><a href="#L-376"><span class="linenos">376</span></a> <span class="n">bracket</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"returns_list_for_maps"</span><span class="p">,</span> <span class="kc">True</span><span class="p">)</span> </span><span id="L-377"><a href="#L-377"><span class="linenos">377</span></a> -</span><span id="L-378"><a href="#L-378"><span class="linenos">378</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-379"><a href="#L-379"><span class="linenos">379</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-380"><a href="#L-380"><span class="linenos">380</span></a> -</span><span id="L-381"><a href="#L-381"><span class="linenos">381</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> -</span><span id="L-382"><a href="#L-382"><span class="linenos">382</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_field_def</span><span class="p">()</span> +</span><span id="L-378"><a href="#L-378"><span class="linenos">378</span></a> <span class="k">return</span> <span class="n">bracket</span> +</span><span id="L-379"><a href="#L-379"><span class="linenos">379</span></a> +</span><span id="L-380"><a href="#L-380"><span class="linenos">380</span></a> <span class="k">def</span> <span class="nf">_parse_map</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">ToMap</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Map</span><span class="p">:</span> +</span><span id="L-381"><a href="#L-381"><span class="linenos">381</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-382"><a href="#L-382"><span class="linenos">382</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-383"><a href="#L-383"><span class="linenos">383</span></a> -</span><span id="L-384"><a href="#L-384"><span class="linenos">384</span></a> <span class="k">def</span> <span class="nf">_pivot_column_names</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">aggregations</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">])</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> -</span><span id="L-385"><a href="#L-385"><span class="linenos">385</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">aggregations</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> -</span><span id="L-386"><a href="#L-386"><span class="linenos">386</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_pivot_column_names</span><span class="p">(</span><span class="n">aggregations</span><span class="p">)</span> -</span><span id="L-387"><a href="#L-387"><span class="linenos">387</span></a> <span class="k">return</span> <span class="n">pivot_column_names</span><span class="p">(</span><span class="n">aggregations</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="s2">"duckdb"</span><span class="p">)</span> -</span><span id="L-388"><a href="#L-388"><span class="linenos">388</span></a> -</span><span id="L-389"><a href="#L-389"><span class="linenos">389</span></a> <span class="k">class</span> <span class="nc">Generator</span><span class="p">(</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="p">):</span> -</span><span id="L-390"><a href="#L-390"><span class="linenos">390</span></a> <span class="n">PARAMETER_TOKEN</span> <span class="o">=</span> <span class="s2">"$"</span> -</span><span id="L-391"><a href="#L-391"><span class="linenos">391</span></a> <span class="n">NAMED_PLACEHOLDER_TOKEN</span> <span class="o">=</span> <span class="s2">"$"</span> -</span><span id="L-392"><a href="#L-392"><span class="linenos">392</span></a> <span class="n">JOIN_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-393"><a href="#L-393"><span class="linenos">393</span></a> <span class="n">TABLE_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-394"><a href="#L-394"><span class="linenos">394</span></a> <span class="n">QUERY_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-395"><a href="#L-395"><span class="linenos">395</span></a> <span class="n">LIMIT_FETCH</span> <span class="o">=</span> <span class="s2">"LIMIT"</span> -</span><span id="L-396"><a href="#L-396"><span class="linenos">396</span></a> <span class="n">STRUCT_DELIMITER</span> <span class="o">=</span> <span class="p">(</span><span class="s2">"("</span><span class="p">,</span> <span class="s2">")"</span><span class="p">)</span> -</span><span id="L-397"><a href="#L-397"><span class="linenos">397</span></a> <span class="n">RENAME_TABLE_WITH_DB</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-398"><a href="#L-398"><span class="linenos">398</span></a> <span class="n">NVL2_SUPPORTED</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-399"><a href="#L-399"><span class="linenos">399</span></a> <span class="n">SEMI_ANTI_JOIN_WITH_SIDE</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-400"><a href="#L-400"><span class="linenos">400</span></a> <span class="n">TABLESAMPLE_KEYWORDS</span> <span class="o">=</span> <span class="s2">"USING SAMPLE"</span> -</span><span id="L-401"><a href="#L-401"><span class="linenos">401</span></a> <span class="n">TABLESAMPLE_SEED_KEYWORD</span> <span class="o">=</span> <span class="s2">"REPEATABLE"</span> -</span><span id="L-402"><a href="#L-402"><span class="linenos">402</span></a> <span class="n">LAST_DAY_SUPPORTS_DATE_PART</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-403"><a href="#L-403"><span class="linenos">403</span></a> <span class="n">JSON_KEY_VALUE_PAIR_SEP</span> <span class="o">=</span> <span class="s2">","</span> -</span><span id="L-404"><a href="#L-404"><span class="linenos">404</span></a> <span class="n">IGNORE_NULLS_IN_FUNC</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="L-405"><a href="#L-405"><span class="linenos">405</span></a> <span class="n">JSON_PATH_BRACKETED_KEY_SUPPORTED</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-406"><a href="#L-406"><span class="linenos">406</span></a> <span class="n">SUPPORTS_CREATE_TABLE_LIKE</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-407"><a href="#L-407"><span class="linenos">407</span></a> <span class="n">MULTI_ARG_DISTINCT</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-408"><a href="#L-408"><span class="linenos">408</span></a> <span class="n">CAN_IMPLEMENT_ARRAY_ANY</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="L-409"><a href="#L-409"><span class="linenos">409</span></a> <span class="n">SUPPORTS_TO_NUMBER</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-410"><a href="#L-410"><span class="linenos">410</span></a> <span class="n">COPY_HAS_INTO_KEYWORD</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-411"><a href="#L-411"><span class="linenos">411</span></a> <span class="n">STAR_EXCEPT</span> <span class="o">=</span> <span class="s2">"EXCLUDE"</span> -</span><span id="L-412"><a href="#L-412"><span class="linenos">412</span></a> <span class="n">PAD_FILL_PATTERN_IS_REQUIRED</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="L-413"><a href="#L-413"><span class="linenos">413</span></a> -</span><span id="L-414"><a href="#L-414"><span class="linenos">414</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-415"><a href="#L-415"><span class="linenos">415</span></a> <span class="o">**</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">TRANSFORMS</span><span class="p">,</span> -</span><span id="L-416"><a href="#L-416"><span class="linenos">416</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxDistinct</span><span class="p">:</span> <span class="n">approx_count_distinct_sql</span><span class="p">,</span> -</span><span id="L-417"><a href="#L-417"><span class="linenos">417</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Array</span><span class="p">:</span> <span class="n">inline_array_unless_query</span><span class="p">,</span> -</span><span id="L-418"><a href="#L-418"><span class="linenos">418</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayContainsAll</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"ARRAY_HAS_ALL"</span><span class="p">),</span> -</span><span id="L-419"><a href="#L-419"><span class="linenos">419</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayFilter</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"LIST_FILTER"</span><span class="p">),</span> -</span><span id="L-420"><a href="#L-420"><span class="linenos">420</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArraySize</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"ARRAY_LENGTH"</span><span class="p">),</span> -</span><span id="L-421"><a href="#L-421"><span class="linenos">421</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArgMax</span><span class="p">:</span> <span class="n">arg_max_or_min_no_count</span><span class="p">(</span><span class="s2">"ARG_MAX"</span><span class="p">),</span> -</span><span id="L-422"><a href="#L-422"><span class="linenos">422</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArgMin</span><span class="p">:</span> <span class="n">arg_max_or_min_no_count</span><span class="p">(</span><span class="s2">"ARG_MIN"</span><span class="p">),</span> -</span><span id="L-423"><a href="#L-423"><span class="linenos">423</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArraySort</span><span class="p">:</span> <span class="n">_array_sort_sql</span><span class="p">,</span> -</span><span id="L-424"><a href="#L-424"><span class="linenos">424</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArraySum</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"LIST_SUM"</span><span class="p">),</span> -</span><span id="L-425"><a href="#L-425"><span class="linenos">425</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseXor</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"XOR"</span><span class="p">),</span> -</span><span id="L-426"><a href="#L-426"><span class="linenos">426</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CommentColumnConstraint</span><span class="p">:</span> <span class="n">no_comment_column_constraint_sql</span><span class="p">,</span> -</span><span id="L-427"><a href="#L-427"><span class="linenos">427</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CurrentDate</span><span class="p">:</span> <span class="k">lambda</span> <span class="o">*</span><span class="n">_</span><span class="p">:</span> <span class="s2">"CURRENT_DATE"</span><span class="p">,</span> -</span><span id="L-428"><a href="#L-428"><span class="linenos">428</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CurrentTime</span><span class="p">:</span> <span class="k">lambda</span> <span class="o">*</span><span class="n">_</span><span class="p">:</span> <span class="s2">"CURRENT_TIME"</span><span class="p">,</span> -</span><span id="L-429"><a href="#L-429"><span class="linenos">429</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CurrentTimestamp</span><span class="p">:</span> <span class="k">lambda</span> <span class="o">*</span><span class="n">_</span><span class="p">:</span> <span class="s2">"CURRENT_TIMESTAMP"</span><span class="p">,</span> -</span><span id="L-430"><a href="#L-430"><span class="linenos">430</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DayOfMonth</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"DAYOFMONTH"</span><span class="p">),</span> -</span><span id="L-431"><a href="#L-431"><span class="linenos">431</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DayOfWeek</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"DAYOFWEEK"</span><span class="p">),</span> -</span><span id="L-432"><a href="#L-432"><span class="linenos">432</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DayOfYear</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"DAYOFYEAR"</span><span class="p">),</span> -</span><span id="L-433"><a href="#L-433"><span class="linenos">433</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">:</span> <span class="n">_datatype_sql</span><span class="p">,</span> -</span><span id="L-434"><a href="#L-434"><span class="linenos">434</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Date</span><span class="p">:</span> <span class="n">_date_sql</span><span class="p">,</span> -</span><span id="L-435"><a href="#L-435"><span class="linenos">435</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</span><span class="p">:</span> <span class="n">_date_delta_sql</span><span class="p">,</span> -</span><span id="L-436"><a href="#L-436"><span class="linenos">436</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateFromParts</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"MAKE_DATE"</span><span class="p">),</span> -</span><span id="L-437"><a href="#L-437"><span class="linenos">437</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateSub</span><span class="p">:</span> <span class="n">_date_delta_sql</span><span class="p">,</span> -</span><span id="L-438"><a href="#L-438"><span class="linenos">438</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateDiff</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="L-439"><a href="#L-439"><span class="linenos">439</span></a> <span class="s2">"DATE_DIFF"</span><span class="p">,</span> <span class="sa">f</span><span class="s2">"'</span><span class="si">{</span><span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'unit'</span><span class="p">)</span><span class="w"> </span><span class="ow">or</span><span class="w"> </span><span class="s1">'DAY'</span><span class="si">}</span><span class="s2">'"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span> -</span><span id="L-440"><a href="#L-440"><span class="linenos">440</span></a> <span class="p">),</span> -</span><span id="L-441"><a href="#L-441"><span class="linenos">441</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateStrToDate</span><span class="p">:</span> <span class="n">datestrtodate_sql</span><span class="p">,</span> -</span><span id="L-442"><a href="#L-442"><span class="linenos">442</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Datetime</span><span class="p">:</span> <span class="n">no_datetime_sql</span><span class="p">,</span> -</span><span id="L-443"><a href="#L-443"><span class="linenos">443</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DatetimeSub</span><span class="p">:</span> <span class="n">_date_delta_sql</span><span class="p">,</span> -</span><span id="L-444"><a href="#L-444"><span class="linenos">444</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DatetimeAdd</span><span class="p">:</span> <span class="n">_date_delta_sql</span><span class="p">,</span> -</span><span id="L-445"><a href="#L-445"><span class="linenos">445</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateToDi</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> -</span><span id="L-446"><a href="#L-446"><span class="linenos">446</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"CAST(STRFTIME(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="n">DuckDB</span><span class="o">.</span><span class="n">DATEINT_FORMAT</span><span class="si">}</span><span class="s2">) AS INT)"</span><span class="p">,</span> -</span><span id="L-447"><a href="#L-447"><span class="linenos">447</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Decode</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="n">encode_decode_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">,</span> <span class="s2">"DECODE"</span><span class="p">,</span> <span class="n">replace</span><span class="o">=</span><span class="kc">False</span><span class="p">),</span> -</span><span id="L-448"><a href="#L-448"><span class="linenos">448</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DiToDate</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> -</span><span id="L-449"><a href="#L-449"><span class="linenos">449</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"CAST(STRPTIME(CAST(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS TEXT), </span><span class="si">{</span><span class="n">DuckDB</span><span class="o">.</span><span class="n">DATEINT_FORMAT</span><span class="si">}</span><span class="s2">) AS DATE)"</span><span class="p">,</span> -</span><span id="L-450"><a href="#L-450"><span class="linenos">450</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Encode</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="n">encode_decode_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">,</span> <span class="s2">"ENCODE"</span><span class="p">,</span> <span class="n">replace</span><span class="o">=</span><span class="kc">False</span><span class="p">),</span> -</span><span id="L-451"><a href="#L-451"><span class="linenos">451</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Explode</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"UNNEST"</span><span class="p">),</span> -</span><span id="L-452"><a href="#L-452"><span class="linenos">452</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">IntDiv</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="s2">"//"</span><span class="p">),</span> -</span><span id="L-453"><a href="#L-453"><span class="linenos">453</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">IsInf</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"ISINF"</span><span class="p">),</span> -</span><span id="L-454"><a href="#L-454"><span class="linenos">454</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">IsNan</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"ISNAN"</span><span class="p">),</span> -</span><span id="L-455"><a href="#L-455"><span class="linenos">455</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtract</span><span class="p">:</span> <span class="n">_arrow_json_extract_sql</span><span class="p">,</span> -</span><span id="L-456"><a href="#L-456"><span class="linenos">456</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtractScalar</span><span class="p">:</span> <span class="n">_arrow_json_extract_sql</span><span class="p">,</span> -</span><span id="L-457"><a href="#L-457"><span class="linenos">457</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONFormat</span><span class="p">:</span> <span class="n">_json_format_sql</span><span class="p">,</span> -</span><span id="L-458"><a href="#L-458"><span class="linenos">458</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LogicalOr</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"BOOL_OR"</span><span class="p">),</span> -</span><span id="L-459"><a href="#L-459"><span class="linenos">459</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LogicalAnd</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"BOOL_AND"</span><span class="p">),</span> -</span><span id="L-460"><a href="#L-460"><span class="linenos">460</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MD5Digest</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"UNHEX"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"MD5"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">)),</span> -</span><span id="L-461"><a href="#L-461"><span class="linenos">461</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MonthsBetween</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="L-462"><a href="#L-462"><span class="linenos">462</span></a> <span class="s2">"DATEDIFF"</span><span class="p">,</span> -</span><span id="L-463"><a href="#L-463"><span class="linenos">463</span></a> <span class="s2">"'month'"</span><span class="p">,</span> -</span><span id="L-464"><a href="#L-464"><span class="linenos">464</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMP</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> -</span><span id="L-465"><a href="#L-465"><span class="linenos">465</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMP</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> -</span><span id="L-466"><a href="#L-466"><span class="linenos">466</span></a> <span class="p">),</span> -</span><span id="L-467"><a href="#L-467"><span class="linenos">467</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PercentileCont</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"QUANTILE_CONT"</span><span class="p">),</span> -</span><span id="L-468"><a href="#L-468"><span class="linenos">468</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PercentileDisc</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"QUANTILE_DISC"</span><span class="p">),</span> -</span><span id="L-469"><a href="#L-469"><span class="linenos">469</span></a> <span class="c1"># DuckDB doesn't allow qualified columns inside of PIVOT expressions.</span> -</span><span id="L-470"><a href="#L-470"><span class="linenos">470</span></a> <span class="c1"># See: https://github.com/duckdb/duckdb/blob/671faf92411182f81dce42ac43de8bfb05d9909e/src/planner/binder/tableref/bind_pivot.cpp#L61-L62</span> -</span><span id="L-471"><a href="#L-471"><span class="linenos">471</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Pivot</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">([</span><span class="n">transforms</span><span class="o">.</span><span class="n">unqualify_columns</span><span class="p">]),</span> -</span><span id="L-472"><a href="#L-472"><span class="linenos">472</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpExtract</span><span class="p">:</span> <span class="n">regexp_extract_sql</span><span class="p">,</span> -</span><span id="L-473"><a href="#L-473"><span class="linenos">473</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpReplace</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="L-474"><a href="#L-474"><span class="linenos">474</span></a> <span class="s2">"REGEXP_REPLACE"</span><span class="p">,</span> -</span><span id="L-475"><a href="#L-475"><span class="linenos">475</span></a> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> -</span><span id="L-476"><a href="#L-476"><span class="linenos">476</span></a> <span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> -</span><span id="L-477"><a href="#L-477"><span class="linenos">477</span></a> <span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"replacement"</span><span class="p">),</span> -</span><span id="L-478"><a href="#L-478"><span class="linenos">478</span></a> <span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"modifiers"</span><span class="p">),</span> -</span><span id="L-479"><a href="#L-479"><span class="linenos">479</span></a> <span class="p">),</span> -</span><span id="L-480"><a href="#L-480"><span class="linenos">480</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpLike</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"REGEXP_MATCHES"</span><span class="p">),</span> -</span><span id="L-481"><a href="#L-481"><span class="linenos">481</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpSplit</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"STR_SPLIT_REGEX"</span><span class="p">),</span> -</span><span id="L-482"><a href="#L-482"><span class="linenos">482</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Return</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">),</span> -</span><span id="L-483"><a href="#L-483"><span class="linenos">483</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ReturnsProperty</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="s2">"TABLE"</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">e</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">Schema</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span><span class="p">,</span> -</span><span id="L-484"><a href="#L-484"><span class="linenos">484</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Rand</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"RANDOM"</span><span class="p">),</span> -</span><span id="L-485"><a href="#L-485"><span class="linenos">485</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SafeDivide</span><span class="p">:</span> <span class="n">no_safe_divide_sql</span><span class="p">,</span> -</span><span id="L-486"><a href="#L-486"><span class="linenos">486</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Split</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"STR_SPLIT"</span><span class="p">),</span> -</span><span id="L-487"><a href="#L-487"><span class="linenos">487</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SortArray</span><span class="p">:</span> <span class="n">_sort_array_sql</span><span class="p">,</span> -</span><span id="L-488"><a href="#L-488"><span class="linenos">488</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrPosition</span><span class="p">:</span> <span class="n">str_position_sql</span><span class="p">,</span> -</span><span id="L-489"><a href="#L-489"><span class="linenos">489</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToUnix</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="L-490"><a href="#L-490"><span class="linenos">490</span></a> <span class="s2">"EPOCH"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"STRPTIME"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span><span class="n">e</span><span class="p">))</span> -</span><span id="L-491"><a href="#L-491"><span class="linenos">491</span></a> <span class="p">),</span> -</span><span id="L-492"><a href="#L-492"><span class="linenos">492</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Struct</span><span class="p">:</span> <span class="n">_struct_sql</span><span class="p">,</span> -</span><span id="L-493"><a href="#L-493"><span class="linenos">493</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeAdd</span><span class="p">:</span> <span class="n">_date_delta_sql</span><span class="p">,</span> -</span><span id="L-494"><a href="#L-494"><span class="linenos">494</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Time</span><span class="p">:</span> <span class="n">no_time_sql</span><span class="p">,</span> -</span><span id="L-495"><a href="#L-495"><span class="linenos">495</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Timestamp</span><span class="p">:</span> <span class="n">no_timestamp_sql</span><span class="p">,</span> -</span><span id="L-496"><a href="#L-496"><span class="linenos">496</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimestampDiff</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="L-497"><a href="#L-497"><span class="linenos">497</span></a> <span class="s2">"DATE_DIFF"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">unit</span><span class="p">),</span> <span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span> -</span><span id="L-498"><a href="#L-498"><span class="linenos">498</span></a> <span class="p">),</span> -</span><span id="L-499"><a href="#L-499"><span class="linenos">499</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimestampTrunc</span><span class="p">:</span> <span class="n">timestamptrunc_sql</span><span class="p">(),</span> -</span><span id="L-500"><a href="#L-500"><span class="linenos">500</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeStrToDate</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">e</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">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">DATE</span><span class="p">)),</span> -</span><span id="L-501"><a href="#L-501"><span class="linenos">501</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeStrToTime</span><span class="p">:</span> <span class="n">timestrtotime_sql</span><span class="p">,</span> -</span><span id="L-502"><a href="#L-502"><span class="linenos">502</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeStrToUnix</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="L-503"><a href="#L-503"><span class="linenos">503</span></a> <span class="s2">"EPOCH"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMP</span><span class="p">)</span> +</span><span id="L-384"><a href="#L-384"><span class="linenos">384</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-385"><a href="#L-385"><span class="linenos">385</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-386"><a href="#L-386"><span class="linenos">386</span></a> +</span><span id="L-387"><a href="#L-387"><span class="linenos">387</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> +</span><span id="L-388"><a href="#L-388"><span class="linenos">388</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_field_def</span><span class="p">()</span> +</span><span id="L-389"><a href="#L-389"><span class="linenos">389</span></a> +</span><span id="L-390"><a href="#L-390"><span class="linenos">390</span></a> <span class="k">def</span> <span class="nf">_pivot_column_names</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">aggregations</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">])</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> +</span><span id="L-391"><a href="#L-391"><span class="linenos">391</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">aggregations</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> +</span><span id="L-392"><a href="#L-392"><span class="linenos">392</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_pivot_column_names</span><span class="p">(</span><span class="n">aggregations</span><span class="p">)</span> +</span><span id="L-393"><a href="#L-393"><span class="linenos">393</span></a> <span class="k">return</span> <span class="n">pivot_column_names</span><span class="p">(</span><span class="n">aggregations</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="s2">"duckdb"</span><span class="p">)</span> +</span><span id="L-394"><a href="#L-394"><span class="linenos">394</span></a> +</span><span id="L-395"><a href="#L-395"><span class="linenos">395</span></a> <span class="k">class</span> <span class="nc">Generator</span><span class="p">(</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="p">):</span> +</span><span id="L-396"><a href="#L-396"><span class="linenos">396</span></a> <span class="n">PARAMETER_TOKEN</span> <span class="o">=</span> <span class="s2">"$"</span> +</span><span id="L-397"><a href="#L-397"><span class="linenos">397</span></a> <span class="n">NAMED_PLACEHOLDER_TOKEN</span> <span class="o">=</span> <span class="s2">"$"</span> +</span><span id="L-398"><a href="#L-398"><span class="linenos">398</span></a> <span class="n">JOIN_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-399"><a href="#L-399"><span class="linenos">399</span></a> <span class="n">TABLE_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-400"><a href="#L-400"><span class="linenos">400</span></a> <span class="n">QUERY_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-401"><a href="#L-401"><span class="linenos">401</span></a> <span class="n">LIMIT_FETCH</span> <span class="o">=</span> <span class="s2">"LIMIT"</span> +</span><span id="L-402"><a href="#L-402"><span class="linenos">402</span></a> <span class="n">STRUCT_DELIMITER</span> <span class="o">=</span> <span class="p">(</span><span class="s2">"("</span><span class="p">,</span> <span class="s2">")"</span><span class="p">)</span> +</span><span id="L-403"><a href="#L-403"><span class="linenos">403</span></a> <span class="n">RENAME_TABLE_WITH_DB</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-404"><a href="#L-404"><span class="linenos">404</span></a> <span class="n">NVL2_SUPPORTED</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-405"><a href="#L-405"><span class="linenos">405</span></a> <span class="n">SEMI_ANTI_JOIN_WITH_SIDE</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-406"><a href="#L-406"><span class="linenos">406</span></a> <span class="n">TABLESAMPLE_KEYWORDS</span> <span class="o">=</span> <span class="s2">"USING SAMPLE"</span> +</span><span id="L-407"><a href="#L-407"><span class="linenos">407</span></a> <span class="n">TABLESAMPLE_SEED_KEYWORD</span> <span class="o">=</span> <span class="s2">"REPEATABLE"</span> +</span><span id="L-408"><a href="#L-408"><span class="linenos">408</span></a> <span class="n">LAST_DAY_SUPPORTS_DATE_PART</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-409"><a href="#L-409"><span class="linenos">409</span></a> <span class="n">JSON_KEY_VALUE_PAIR_SEP</span> <span class="o">=</span> <span class="s2">","</span> +</span><span id="L-410"><a href="#L-410"><span class="linenos">410</span></a> <span class="n">IGNORE_NULLS_IN_FUNC</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-411"><a href="#L-411"><span class="linenos">411</span></a> <span class="n">JSON_PATH_BRACKETED_KEY_SUPPORTED</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-412"><a href="#L-412"><span class="linenos">412</span></a> <span class="n">SUPPORTS_CREATE_TABLE_LIKE</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-413"><a href="#L-413"><span class="linenos">413</span></a> <span class="n">MULTI_ARG_DISTINCT</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-414"><a href="#L-414"><span class="linenos">414</span></a> <span class="n">CAN_IMPLEMENT_ARRAY_ANY</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-415"><a href="#L-415"><span class="linenos">415</span></a> <span class="n">SUPPORTS_TO_NUMBER</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-416"><a href="#L-416"><span class="linenos">416</span></a> <span class="n">COPY_HAS_INTO_KEYWORD</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-417"><a href="#L-417"><span class="linenos">417</span></a> <span class="n">STAR_EXCEPT</span> <span class="o">=</span> <span class="s2">"EXCLUDE"</span> +</span><span id="L-418"><a href="#L-418"><span class="linenos">418</span></a> <span class="n">PAD_FILL_PATTERN_IS_REQUIRED</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-419"><a href="#L-419"><span class="linenos">419</span></a> +</span><span id="L-420"><a href="#L-420"><span class="linenos">420</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-421"><a href="#L-421"><span class="linenos">421</span></a> <span class="o">**</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">TRANSFORMS</span><span class="p">,</span> +</span><span id="L-422"><a href="#L-422"><span class="linenos">422</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxDistinct</span><span class="p">:</span> <span class="n">approx_count_distinct_sql</span><span class="p">,</span> +</span><span id="L-423"><a href="#L-423"><span class="linenos">423</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Array</span><span class="p">:</span> <span class="n">inline_array_unless_query</span><span class="p">,</span> +</span><span id="L-424"><a href="#L-424"><span class="linenos">424</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayContainsAll</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"ARRAY_HAS_ALL"</span><span class="p">),</span> +</span><span id="L-425"><a href="#L-425"><span class="linenos">425</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayFilter</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"LIST_FILTER"</span><span class="p">),</span> +</span><span id="L-426"><a href="#L-426"><span class="linenos">426</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArraySize</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"ARRAY_LENGTH"</span><span class="p">),</span> +</span><span id="L-427"><a href="#L-427"><span class="linenos">427</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArgMax</span><span class="p">:</span> <span class="n">arg_max_or_min_no_count</span><span class="p">(</span><span class="s2">"ARG_MAX"</span><span class="p">),</span> +</span><span id="L-428"><a href="#L-428"><span class="linenos">428</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArgMin</span><span class="p">:</span> <span class="n">arg_max_or_min_no_count</span><span class="p">(</span><span class="s2">"ARG_MIN"</span><span class="p">),</span> +</span><span id="L-429"><a href="#L-429"><span class="linenos">429</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArraySort</span><span class="p">:</span> <span class="n">_array_sort_sql</span><span class="p">,</span> +</span><span id="L-430"><a href="#L-430"><span class="linenos">430</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArraySum</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"LIST_SUM"</span><span class="p">),</span> +</span><span id="L-431"><a href="#L-431"><span class="linenos">431</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseXor</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"XOR"</span><span class="p">),</span> +</span><span id="L-432"><a href="#L-432"><span class="linenos">432</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CommentColumnConstraint</span><span class="p">:</span> <span class="n">no_comment_column_constraint_sql</span><span class="p">,</span> +</span><span id="L-433"><a href="#L-433"><span class="linenos">433</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CurrentDate</span><span class="p">:</span> <span class="k">lambda</span> <span class="o">*</span><span class="n">_</span><span class="p">:</span> <span class="s2">"CURRENT_DATE"</span><span class="p">,</span> +</span><span id="L-434"><a href="#L-434"><span class="linenos">434</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CurrentTime</span><span class="p">:</span> <span class="k">lambda</span> <span class="o">*</span><span class="n">_</span><span class="p">:</span> <span class="s2">"CURRENT_TIME"</span><span class="p">,</span> +</span><span id="L-435"><a href="#L-435"><span class="linenos">435</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CurrentTimestamp</span><span class="p">:</span> <span class="k">lambda</span> <span class="o">*</span><span class="n">_</span><span class="p">:</span> <span class="s2">"CURRENT_TIMESTAMP"</span><span class="p">,</span> +</span><span id="L-436"><a href="#L-436"><span class="linenos">436</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DayOfMonth</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"DAYOFMONTH"</span><span class="p">),</span> +</span><span id="L-437"><a href="#L-437"><span class="linenos">437</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DayOfWeek</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"DAYOFWEEK"</span><span class="p">),</span> +</span><span id="L-438"><a href="#L-438"><span class="linenos">438</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DayOfYear</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"DAYOFYEAR"</span><span class="p">),</span> +</span><span id="L-439"><a href="#L-439"><span class="linenos">439</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">:</span> <span class="n">_datatype_sql</span><span class="p">,</span> +</span><span id="L-440"><a href="#L-440"><span class="linenos">440</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Date</span><span class="p">:</span> <span class="n">_date_sql</span><span class="p">,</span> +</span><span id="L-441"><a href="#L-441"><span class="linenos">441</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</span><span class="p">:</span> <span class="n">_date_delta_sql</span><span class="p">,</span> +</span><span id="L-442"><a href="#L-442"><span class="linenos">442</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateFromParts</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"MAKE_DATE"</span><span class="p">),</span> +</span><span id="L-443"><a href="#L-443"><span class="linenos">443</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateSub</span><span class="p">:</span> <span class="n">_date_delta_sql</span><span class="p">,</span> +</span><span id="L-444"><a href="#L-444"><span class="linenos">444</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateDiff</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> +</span><span id="L-445"><a href="#L-445"><span class="linenos">445</span></a> <span class="s2">"DATE_DIFF"</span><span class="p">,</span> <span class="sa">f</span><span class="s2">"'</span><span class="si">{</span><span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'unit'</span><span class="p">)</span><span class="w"> </span><span class="ow">or</span><span class="w"> </span><span class="s1">'DAY'</span><span class="si">}</span><span class="s2">'"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span> +</span><span id="L-446"><a href="#L-446"><span class="linenos">446</span></a> <span class="p">),</span> +</span><span id="L-447"><a href="#L-447"><span class="linenos">447</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateStrToDate</span><span class="p">:</span> <span class="n">datestrtodate_sql</span><span class="p">,</span> +</span><span id="L-448"><a href="#L-448"><span class="linenos">448</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Datetime</span><span class="p">:</span> <span class="n">no_datetime_sql</span><span class="p">,</span> +</span><span id="L-449"><a href="#L-449"><span class="linenos">449</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DatetimeSub</span><span class="p">:</span> <span class="n">_date_delta_sql</span><span class="p">,</span> +</span><span id="L-450"><a href="#L-450"><span class="linenos">450</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DatetimeAdd</span><span class="p">:</span> <span class="n">_date_delta_sql</span><span class="p">,</span> +</span><span id="L-451"><a href="#L-451"><span class="linenos">451</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateToDi</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> +</span><span id="L-452"><a href="#L-452"><span class="linenos">452</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"CAST(STRFTIME(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="n">DuckDB</span><span class="o">.</span><span class="n">DATEINT_FORMAT</span><span class="si">}</span><span class="s2">) AS INT)"</span><span class="p">,</span> +</span><span id="L-453"><a href="#L-453"><span class="linenos">453</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Decode</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="n">encode_decode_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">,</span> <span class="s2">"DECODE"</span><span class="p">,</span> <span class="n">replace</span><span class="o">=</span><span class="kc">False</span><span class="p">),</span> +</span><span id="L-454"><a href="#L-454"><span class="linenos">454</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DiToDate</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> +</span><span id="L-455"><a href="#L-455"><span class="linenos">455</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"CAST(STRPTIME(CAST(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS TEXT), </span><span class="si">{</span><span class="n">DuckDB</span><span class="o">.</span><span class="n">DATEINT_FORMAT</span><span class="si">}</span><span class="s2">) AS DATE)"</span><span class="p">,</span> +</span><span id="L-456"><a href="#L-456"><span class="linenos">456</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Encode</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="n">encode_decode_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">,</span> <span class="s2">"ENCODE"</span><span class="p">,</span> <span class="n">replace</span><span class="o">=</span><span class="kc">False</span><span class="p">),</span> +</span><span id="L-457"><a href="#L-457"><span class="linenos">457</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Explode</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"UNNEST"</span><span class="p">),</span> +</span><span id="L-458"><a href="#L-458"><span class="linenos">458</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">IntDiv</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="s2">"//"</span><span class="p">),</span> +</span><span id="L-459"><a href="#L-459"><span class="linenos">459</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">IsInf</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"ISINF"</span><span class="p">),</span> +</span><span id="L-460"><a href="#L-460"><span class="linenos">460</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">IsNan</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"ISNAN"</span><span class="p">),</span> +</span><span id="L-461"><a href="#L-461"><span class="linenos">461</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtract</span><span class="p">:</span> <span class="n">_arrow_json_extract_sql</span><span class="p">,</span> +</span><span id="L-462"><a href="#L-462"><span class="linenos">462</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtractScalar</span><span class="p">:</span> <span class="n">_arrow_json_extract_sql</span><span class="p">,</span> +</span><span id="L-463"><a href="#L-463"><span class="linenos">463</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONFormat</span><span class="p">:</span> <span class="n">_json_format_sql</span><span class="p">,</span> +</span><span id="L-464"><a href="#L-464"><span class="linenos">464</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LogicalOr</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"BOOL_OR"</span><span class="p">),</span> +</span><span id="L-465"><a href="#L-465"><span class="linenos">465</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LogicalAnd</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"BOOL_AND"</span><span class="p">),</span> +</span><span id="L-466"><a href="#L-466"><span class="linenos">466</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MD5Digest</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"UNHEX"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"MD5"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">)),</span> +</span><span id="L-467"><a href="#L-467"><span class="linenos">467</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MonthsBetween</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> +</span><span id="L-468"><a href="#L-468"><span class="linenos">468</span></a> <span class="s2">"DATEDIFF"</span><span class="p">,</span> +</span><span id="L-469"><a href="#L-469"><span class="linenos">469</span></a> <span class="s2">"'month'"</span><span class="p">,</span> +</span><span id="L-470"><a href="#L-470"><span class="linenos">470</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMP</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> +</span><span id="L-471"><a href="#L-471"><span class="linenos">471</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMP</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> +</span><span id="L-472"><a href="#L-472"><span class="linenos">472</span></a> <span class="p">),</span> +</span><span id="L-473"><a href="#L-473"><span class="linenos">473</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PercentileCont</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"QUANTILE_CONT"</span><span class="p">),</span> +</span><span id="L-474"><a href="#L-474"><span class="linenos">474</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PercentileDisc</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"QUANTILE_DISC"</span><span class="p">),</span> +</span><span id="L-475"><a href="#L-475"><span class="linenos">475</span></a> <span class="c1"># DuckDB doesn't allow qualified columns inside of PIVOT expressions.</span> +</span><span id="L-476"><a href="#L-476"><span class="linenos">476</span></a> <span class="c1"># See: https://github.com/duckdb/duckdb/blob/671faf92411182f81dce42ac43de8bfb05d9909e/src/planner/binder/tableref/bind_pivot.cpp#L61-L62</span> +</span><span id="L-477"><a href="#L-477"><span class="linenos">477</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Pivot</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">([</span><span class="n">transforms</span><span class="o">.</span><span class="n">unqualify_columns</span><span class="p">]),</span> +</span><span id="L-478"><a href="#L-478"><span class="linenos">478</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpExtract</span><span class="p">:</span> <span class="n">regexp_extract_sql</span><span class="p">,</span> +</span><span id="L-479"><a href="#L-479"><span class="linenos">479</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpReplace</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> +</span><span id="L-480"><a href="#L-480"><span class="linenos">480</span></a> <span class="s2">"REGEXP_REPLACE"</span><span class="p">,</span> +</span><span id="L-481"><a href="#L-481"><span class="linenos">481</span></a> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> +</span><span id="L-482"><a href="#L-482"><span class="linenos">482</span></a> <span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> +</span><span id="L-483"><a href="#L-483"><span class="linenos">483</span></a> <span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"replacement"</span><span class="p">),</span> +</span><span id="L-484"><a href="#L-484"><span class="linenos">484</span></a> <span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"modifiers"</span><span class="p">),</span> +</span><span id="L-485"><a href="#L-485"><span class="linenos">485</span></a> <span class="p">),</span> +</span><span id="L-486"><a href="#L-486"><span class="linenos">486</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpLike</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"REGEXP_MATCHES"</span><span class="p">),</span> +</span><span id="L-487"><a href="#L-487"><span class="linenos">487</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpSplit</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"STR_SPLIT_REGEX"</span><span class="p">),</span> +</span><span id="L-488"><a href="#L-488"><span class="linenos">488</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Return</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">),</span> +</span><span id="L-489"><a href="#L-489"><span class="linenos">489</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ReturnsProperty</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="s2">"TABLE"</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">e</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">Schema</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span><span class="p">,</span> +</span><span id="L-490"><a href="#L-490"><span class="linenos">490</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Rand</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"RANDOM"</span><span class="p">),</span> +</span><span id="L-491"><a href="#L-491"><span class="linenos">491</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SafeDivide</span><span class="p">:</span> <span class="n">no_safe_divide_sql</span><span class="p">,</span> +</span><span id="L-492"><a href="#L-492"><span class="linenos">492</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Split</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"STR_SPLIT"</span><span class="p">),</span> +</span><span id="L-493"><a href="#L-493"><span class="linenos">493</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SortArray</span><span class="p">:</span> <span class="n">_sort_array_sql</span><span class="p">,</span> +</span><span id="L-494"><a href="#L-494"><span class="linenos">494</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrPosition</span><span class="p">:</span> <span class="n">str_position_sql</span><span class="p">,</span> +</span><span id="L-495"><a href="#L-495"><span class="linenos">495</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToUnix</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> +</span><span id="L-496"><a href="#L-496"><span class="linenos">496</span></a> <span class="s2">"EPOCH"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"STRPTIME"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span><span class="n">e</span><span class="p">))</span> +</span><span id="L-497"><a href="#L-497"><span class="linenos">497</span></a> <span class="p">),</span> +</span><span id="L-498"><a href="#L-498"><span class="linenos">498</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Struct</span><span class="p">:</span> <span class="n">_struct_sql</span><span class="p">,</span> +</span><span id="L-499"><a href="#L-499"><span class="linenos">499</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeAdd</span><span class="p">:</span> <span class="n">_date_delta_sql</span><span class="p">,</span> +</span><span id="L-500"><a href="#L-500"><span class="linenos">500</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Time</span><span class="p">:</span> <span class="n">no_time_sql</span><span class="p">,</span> +</span><span id="L-501"><a href="#L-501"><span class="linenos">501</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Timestamp</span><span class="p">:</span> <span class="n">no_timestamp_sql</span><span class="p">,</span> +</span><span id="L-502"><a href="#L-502"><span class="linenos">502</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimestampDiff</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> +</span><span id="L-503"><a href="#L-503"><span class="linenos">503</span></a> <span class="s2">"DATE_DIFF"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">unit</span><span class="p">),</span> <span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span> </span><span id="L-504"><a href="#L-504"><span class="linenos">504</span></a> <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">TimeToStr</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"STRFTIME"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span><span class="n">e</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">TimeToUnix</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"EPOCH"</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">TsOrDiToDi</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> -</span><span id="L-508"><a href="#L-508"><span class="linenos">508</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"CAST(SUBSTR(REPLACE(CAST(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS TEXT), '-', ''), 1, 8) AS INT)"</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">TsOrDsAdd</span><span class="p">:</span> <span class="n">_date_delta_sql</span><span class="p">,</span> -</span><span id="L-510"><a href="#L-510"><span class="linenos">510</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsDiff</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="L-511"><a href="#L-511"><span class="linenos">511</span></a> <span class="s2">"DATE_DIFF"</span><span class="p">,</span> -</span><span id="L-512"><a href="#L-512"><span class="linenos">512</span></a> <span class="sa">f</span><span class="s2">"'</span><span class="si">{</span><span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'unit'</span><span class="p">)</span><span class="w"> </span><span class="ow">or</span><span class="w"> </span><span class="s1">'DAY'</span><span class="si">}</span><span class="s2">'"</span><span class="p">,</span> -</span><span id="L-513"><a href="#L-513"><span class="linenos">513</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMP</span><span class="p">),</span> -</span><span id="L-514"><a href="#L-514"><span class="linenos">514</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMP</span><span class="p">),</span> -</span><span id="L-515"><a href="#L-515"><span class="linenos">515</span></a> <span class="p">),</span> -</span><span id="L-516"><a href="#L-516"><span class="linenos">516</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToStr</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="L-517"><a href="#L-517"><span class="linenos">517</span></a> <span class="s2">"STRFTIME"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"TO_TIMESTAMP"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">),</span> <span class="bp">self</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span><span class="n">e</span><span class="p">)</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 class="n">exp</span><span class="o">.</span><span class="n">UnixToTime</span><span class="p">:</span> <span class="n">_unix_to_time_sql</span><span class="p">,</span> -</span><span id="L-520"><a href="#L-520"><span class="linenos">520</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToTimeStr</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"CAST(TO_TIMESTAMP(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">) AS TEXT)"</span><span class="p">,</span> -</span><span id="L-521"><a href="#L-521"><span class="linenos">521</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VariancePop</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"VAR_POP"</span><span class="p">),</span> -</span><span id="L-522"><a href="#L-522"><span class="linenos">522</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">WeekOfYear</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"WEEKOFYEAR"</span><span class="p">),</span> -</span><span id="L-523"><a href="#L-523"><span class="linenos">523</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Xor</span><span class="p">:</span> <span class="n">bool_xor_sql</span><span class="p">,</span> -</span><span id="L-524"><a href="#L-524"><span class="linenos">524</span></a> <span class="p">}</span> -</span><span id="L-525"><a href="#L-525"><span class="linenos">525</span></a> -</span><span id="L-526"><a href="#L-526"><span class="linenos">526</span></a> <span class="n">SUPPORTED_JSON_PATH_PARTS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-527"><a href="#L-527"><span class="linenos">527</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONPathKey</span><span class="p">,</span> -</span><span id="L-528"><a href="#L-528"><span class="linenos">528</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONPathRoot</span><span class="p">,</span> -</span><span id="L-529"><a href="#L-529"><span class="linenos">529</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONPathSubscript</span><span class="p">,</span> -</span><span id="L-530"><a href="#L-530"><span class="linenos">530</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONPathWildcard</span><span class="p">,</span> -</span><span id="L-531"><a href="#L-531"><span class="linenos">531</span></a> <span class="p">}</span> -</span><span id="L-532"><a href="#L-532"><span class="linenos">532</span></a> -</span><span id="L-533"><a href="#L-533"><span class="linenos">533</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-534"><a href="#L-534"><span class="linenos">534</span></a> <span class="o">**</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">TYPE_MAPPING</span><span class="p">,</span> -</span><span id="L-535"><a href="#L-535"><span class="linenos">535</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">BINARY</span><span class="p">:</span> <span class="s2">"BLOB"</span><span class="p">,</span> -</span><span id="L-536"><a href="#L-536"><span class="linenos">536</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">BPCHAR</span><span class="p">:</span> <span class="s2">"TEXT"</span><span class="p">,</span> -</span><span id="L-537"><a href="#L-537"><span class="linenos">537</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">CHAR</span><span class="p">:</span> <span class="s2">"TEXT"</span><span class="p">,</span> -</span><span id="L-538"><a href="#L-538"><span class="linenos">538</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">FLOAT</span><span class="p">:</span> <span class="s2">"REAL"</span><span class="p">,</span> -</span><span id="L-539"><a href="#L-539"><span class="linenos">539</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">NCHAR</span><span class="p">:</span> <span class="s2">"TEXT"</span><span class="p">,</span> -</span><span id="L-540"><a href="#L-540"><span class="linenos">540</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">NVARCHAR</span><span class="p">:</span> <span class="s2">"TEXT"</span><span class="p">,</span> -</span><span id="L-541"><a href="#L-541"><span class="linenos">541</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">UINT</span><span class="p">:</span> <span class="s2">"UINTEGER"</span><span class="p">,</span> -</span><span id="L-542"><a href="#L-542"><span class="linenos">542</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-543"><a href="#L-543"><span class="linenos">543</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-544"><a href="#L-544"><span class="linenos">544</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-545"><a href="#L-545"><span class="linenos">545</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-546"><a href="#L-546"><span class="linenos">546</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-547"><a href="#L-547"><span class="linenos">547</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-548"><a href="#L-548"><span class="linenos">548</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-549"><a href="#L-549"><span class="linenos">549</span></a> <span class="p">}</span> -</span><span id="L-550"><a href="#L-550"><span class="linenos">550</span></a> -</span><span id="L-551"><a href="#L-551"><span class="linenos">551</span></a> <span class="c1"># https://github.com/duckdb/duckdb/blob/ff7f24fd8e3128d94371827523dae85ebaf58713/third_party/libpg_query/grammar/keywords/reserved_keywords.list#L1-L77</span> -</span><span id="L-552"><a href="#L-552"><span class="linenos">552</span></a> <span class="n">RESERVED_KEYWORDS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-553"><a href="#L-553"><span class="linenos">553</span></a> <span class="s2">"array"</span><span class="p">,</span> -</span><span id="L-554"><a href="#L-554"><span class="linenos">554</span></a> <span class="s2">"analyse"</span><span class="p">,</span> -</span><span id="L-555"><a href="#L-555"><span class="linenos">555</span></a> <span class="s2">"union"</span><span class="p">,</span> -</span><span id="L-556"><a href="#L-556"><span class="linenos">556</span></a> <span class="s2">"all"</span><span class="p">,</span> -</span><span id="L-557"><a href="#L-557"><span class="linenos">557</span></a> <span class="s2">"when"</span><span class="p">,</span> -</span><span id="L-558"><a href="#L-558"><span class="linenos">558</span></a> <span class="s2">"in_p"</span><span class="p">,</span> -</span><span id="L-559"><a href="#L-559"><span class="linenos">559</span></a> <span class="s2">"default"</span><span class="p">,</span> -</span><span id="L-560"><a href="#L-560"><span class="linenos">560</span></a> <span class="s2">"create_p"</span><span class="p">,</span> -</span><span id="L-561"><a href="#L-561"><span class="linenos">561</span></a> <span class="s2">"window"</span><span class="p">,</span> -</span><span id="L-562"><a href="#L-562"><span class="linenos">562</span></a> <span class="s2">"asymmetric"</span><span class="p">,</span> -</span><span id="L-563"><a href="#L-563"><span class="linenos">563</span></a> <span class="s2">"to"</span><span class="p">,</span> -</span><span id="L-564"><a href="#L-564"><span class="linenos">564</span></a> <span class="s2">"else"</span><span class="p">,</span> -</span><span id="L-565"><a href="#L-565"><span class="linenos">565</span></a> <span class="s2">"localtime"</span><span class="p">,</span> -</span><span id="L-566"><a href="#L-566"><span class="linenos">566</span></a> <span class="s2">"from"</span><span class="p">,</span> -</span><span id="L-567"><a href="#L-567"><span class="linenos">567</span></a> <span class="s2">"end_p"</span><span class="p">,</span> -</span><span id="L-568"><a href="#L-568"><span class="linenos">568</span></a> <span class="s2">"select"</span><span class="p">,</span> -</span><span id="L-569"><a href="#L-569"><span class="linenos">569</span></a> <span class="s2">"current_date"</span><span class="p">,</span> -</span><span id="L-570"><a href="#L-570"><span class="linenos">570</span></a> <span class="s2">"foreign"</span><span class="p">,</span> -</span><span id="L-571"><a href="#L-571"><span class="linenos">571</span></a> <span class="s2">"with"</span><span class="p">,</span> -</span><span id="L-572"><a href="#L-572"><span class="linenos">572</span></a> <span class="s2">"grant"</span><span class="p">,</span> -</span><span id="L-573"><a href="#L-573"><span class="linenos">573</span></a> <span class="s2">"session_user"</span><span class="p">,</span> -</span><span id="L-574"><a href="#L-574"><span class="linenos">574</span></a> <span class="s2">"or"</span><span class="p">,</span> -</span><span id="L-575"><a href="#L-575"><span class="linenos">575</span></a> <span class="s2">"except"</span><span class="p">,</span> -</span><span id="L-576"><a href="#L-576"><span class="linenos">576</span></a> <span class="s2">"references"</span><span class="p">,</span> -</span><span id="L-577"><a href="#L-577"><span class="linenos">577</span></a> <span class="s2">"fetch"</span><span class="p">,</span> -</span><span id="L-578"><a href="#L-578"><span class="linenos">578</span></a> <span class="s2">"limit"</span><span class="p">,</span> -</span><span id="L-579"><a href="#L-579"><span class="linenos">579</span></a> <span class="s2">"group_p"</span><span class="p">,</span> -</span><span id="L-580"><a href="#L-580"><span class="linenos">580</span></a> <span class="s2">"leading"</span><span class="p">,</span> -</span><span id="L-581"><a href="#L-581"><span class="linenos">581</span></a> <span class="s2">"into"</span><span class="p">,</span> -</span><span id="L-582"><a href="#L-582"><span class="linenos">582</span></a> <span class="s2">"collate"</span><span class="p">,</span> -</span><span id="L-583"><a href="#L-583"><span class="linenos">583</span></a> <span class="s2">"offset"</span><span class="p">,</span> -</span><span id="L-584"><a href="#L-584"><span class="linenos">584</span></a> <span class="s2">"do"</span><span class="p">,</span> -</span><span id="L-585"><a href="#L-585"><span class="linenos">585</span></a> <span class="s2">"then"</span><span class="p">,</span> -</span><span id="L-586"><a href="#L-586"><span class="linenos">586</span></a> <span class="s2">"localtimestamp"</span><span class="p">,</span> -</span><span id="L-587"><a href="#L-587"><span class="linenos">587</span></a> <span class="s2">"check_p"</span><span class="p">,</span> -</span><span id="L-588"><a href="#L-588"><span class="linenos">588</span></a> <span class="s2">"lateral_p"</span><span class="p">,</span> -</span><span id="L-589"><a href="#L-589"><span class="linenos">589</span></a> <span class="s2">"current_role"</span><span class="p">,</span> -</span><span id="L-590"><a href="#L-590"><span class="linenos">590</span></a> <span class="s2">"where"</span><span class="p">,</span> -</span><span id="L-591"><a href="#L-591"><span class="linenos">591</span></a> <span class="s2">"asc_p"</span><span class="p">,</span> -</span><span id="L-592"><a href="#L-592"><span class="linenos">592</span></a> <span class="s2">"placing"</span><span class="p">,</span> -</span><span id="L-593"><a href="#L-593"><span class="linenos">593</span></a> <span class="s2">"desc_p"</span><span class="p">,</span> -</span><span id="L-594"><a href="#L-594"><span class="linenos">594</span></a> <span class="s2">"user"</span><span class="p">,</span> -</span><span id="L-595"><a href="#L-595"><span class="linenos">595</span></a> <span class="s2">"unique"</span><span class="p">,</span> -</span><span id="L-596"><a href="#L-596"><span class="linenos">596</span></a> <span class="s2">"initially"</span><span class="p">,</span> -</span><span id="L-597"><a href="#L-597"><span class="linenos">597</span></a> <span class="s2">"column"</span><span class="p">,</span> -</span><span id="L-598"><a href="#L-598"><span class="linenos">598</span></a> <span class="s2">"both"</span><span class="p">,</span> -</span><span id="L-599"><a href="#L-599"><span class="linenos">599</span></a> <span class="s2">"some"</span><span class="p">,</span> -</span><span id="L-600"><a href="#L-600"><span class="linenos">600</span></a> <span class="s2">"as"</span><span class="p">,</span> -</span><span id="L-601"><a href="#L-601"><span class="linenos">601</span></a> <span class="s2">"any"</span><span class="p">,</span> -</span><span id="L-602"><a href="#L-602"><span class="linenos">602</span></a> <span class="s2">"only"</span><span class="p">,</span> -</span><span id="L-603"><a href="#L-603"><span class="linenos">603</span></a> <span class="s2">"deferrable"</span><span class="p">,</span> -</span><span id="L-604"><a href="#L-604"><span class="linenos">604</span></a> <span class="s2">"null_p"</span><span class="p">,</span> -</span><span id="L-605"><a href="#L-605"><span class="linenos">605</span></a> <span class="s2">"current_time"</span><span class="p">,</span> -</span><span id="L-606"><a href="#L-606"><span class="linenos">606</span></a> <span class="s2">"true_p"</span><span class="p">,</span> -</span><span id="L-607"><a href="#L-607"><span class="linenos">607</span></a> <span class="s2">"table"</span><span class="p">,</span> -</span><span id="L-608"><a href="#L-608"><span class="linenos">608</span></a> <span class="s2">"case"</span><span class="p">,</span> -</span><span id="L-609"><a href="#L-609"><span class="linenos">609</span></a> <span class="s2">"trailing"</span><span class="p">,</span> -</span><span id="L-610"><a href="#L-610"><span class="linenos">610</span></a> <span class="s2">"variadic"</span><span class="p">,</span> -</span><span id="L-611"><a href="#L-611"><span class="linenos">611</span></a> <span class="s2">"for"</span><span class="p">,</span> -</span><span id="L-612"><a href="#L-612"><span class="linenos">612</span></a> <span class="s2">"on"</span><span class="p">,</span> -</span><span id="L-613"><a href="#L-613"><span class="linenos">613</span></a> <span class="s2">"distinct"</span><span class="p">,</span> -</span><span id="L-614"><a href="#L-614"><span class="linenos">614</span></a> <span class="s2">"false_p"</span><span class="p">,</span> -</span><span id="L-615"><a href="#L-615"><span class="linenos">615</span></a> <span class="s2">"not"</span><span class="p">,</span> -</span><span id="L-616"><a href="#L-616"><span class="linenos">616</span></a> <span class="s2">"constraint"</span><span class="p">,</span> -</span><span id="L-617"><a href="#L-617"><span class="linenos">617</span></a> <span class="s2">"current_timestamp"</span><span class="p">,</span> -</span><span id="L-618"><a href="#L-618"><span class="linenos">618</span></a> <span class="s2">"returning"</span><span class="p">,</span> -</span><span id="L-619"><a href="#L-619"><span class="linenos">619</span></a> <span class="s2">"primary"</span><span class="p">,</span> -</span><span id="L-620"><a href="#L-620"><span class="linenos">620</span></a> <span class="s2">"intersect"</span><span class="p">,</span> -</span><span id="L-621"><a href="#L-621"><span class="linenos">621</span></a> <span class="s2">"having"</span><span class="p">,</span> -</span><span id="L-622"><a href="#L-622"><span class="linenos">622</span></a> <span class="s2">"analyze"</span><span class="p">,</span> -</span><span id="L-623"><a href="#L-623"><span class="linenos">623</span></a> <span class="s2">"current_user"</span><span class="p">,</span> -</span><span id="L-624"><a href="#L-624"><span class="linenos">624</span></a> <span class="s2">"and"</span><span class="p">,</span> -</span><span id="L-625"><a href="#L-625"><span class="linenos">625</span></a> <span class="s2">"cast"</span><span class="p">,</span> -</span><span id="L-626"><a href="#L-626"><span class="linenos">626</span></a> <span class="s2">"symmetric"</span><span class="p">,</span> -</span><span id="L-627"><a href="#L-627"><span class="linenos">627</span></a> <span class="s2">"using"</span><span class="p">,</span> -</span><span id="L-628"><a href="#L-628"><span class="linenos">628</span></a> <span class="s2">"order"</span><span class="p">,</span> -</span><span id="L-629"><a href="#L-629"><span class="linenos">629</span></a> <span class="s2">"current_catalog"</span><span class="p">,</span> -</span><span id="L-630"><a href="#L-630"><span class="linenos">630</span></a> <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="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-633"><a href="#L-633"><span class="linenos">633</span></a> -</span><span id="L-634"><a href="#L-634"><span class="linenos">634</span></a> <span class="c1"># DuckDB doesn't generally support CREATE TABLE .. properties</span> -</span><span id="L-635"><a href="#L-635"><span class="linenos">635</span></a> <span class="c1"># https://duckdb.org/docs/sql/statements/create_table.html</span> -</span><span id="L-636"><a href="#L-636"><span class="linenos">636</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-637"><a href="#L-637"><span class="linenos">637</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-638"><a href="#L-638"><span class="linenos">638</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-639"><a href="#L-639"><span class="linenos">639</span></a> <span class="p">}</span> -</span><span id="L-640"><a href="#L-640"><span class="linenos">640</span></a> -</span><span id="L-641"><a href="#L-641"><span class="linenos">641</span></a> <span class="c1"># There are a few exceptions (e.g. temporary tables) which are supported or</span> -</span><span id="L-642"><a href="#L-642"><span class="linenos">642</span></a> <span class="c1"># can be transpiled to DuckDB, so we explicitly override them accordingly</span> -</span><span id="L-643"><a href="#L-643"><span class="linenos">643</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-644"><a href="#L-644"><span class="linenos">644</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-645"><a href="#L-645"><span class="linenos">645</span></a> <span class="n">PROPERTIES_LOCATION</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">ReturnsProperty</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_ALIAS</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">TimestampTrunc</span><span class="p">:</span> <span class="n">timestamptrunc_sql</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">TimeStrToDate</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">e</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">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">DATE</span><span class="p">)),</span> +</span><span id="L-507"><a href="#L-507"><span class="linenos">507</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeStrToTime</span><span class="p">:</span> <span class="n">timestrtotime_sql</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">TimeStrToUnix</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> +</span><span id="L-509"><a href="#L-509"><span class="linenos">509</span></a> <span class="s2">"EPOCH"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMP</span><span class="p">)</span> +</span><span id="L-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 class="n">exp</span><span class="o">.</span><span class="n">TimeToStr</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"STRFTIME"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span><span class="n">e</span><span class="p">)),</span> +</span><span id="L-512"><a href="#L-512"><span class="linenos">512</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeToUnix</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"EPOCH"</span><span class="p">),</span> +</span><span id="L-513"><a href="#L-513"><span class="linenos">513</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDiToDi</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> +</span><span id="L-514"><a href="#L-514"><span class="linenos">514</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"CAST(SUBSTR(REPLACE(CAST(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS TEXT), '-', ''), 1, 8) AS INT)"</span><span class="p">,</span> +</span><span id="L-515"><a href="#L-515"><span class="linenos">515</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsAdd</span><span class="p">:</span> <span class="n">_date_delta_sql</span><span class="p">,</span> +</span><span id="L-516"><a href="#L-516"><span class="linenos">516</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsDiff</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> +</span><span id="L-517"><a href="#L-517"><span class="linenos">517</span></a> <span class="s2">"DATE_DIFF"</span><span class="p">,</span> +</span><span id="L-518"><a href="#L-518"><span class="linenos">518</span></a> <span class="sa">f</span><span class="s2">"'</span><span class="si">{</span><span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'unit'</span><span class="p">)</span><span class="w"> </span><span class="ow">or</span><span class="w"> </span><span class="s1">'DAY'</span><span class="si">}</span><span class="s2">'"</span><span class="p">,</span> +</span><span id="L-519"><a href="#L-519"><span class="linenos">519</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMP</span><span class="p">),</span> +</span><span id="L-520"><a href="#L-520"><span class="linenos">520</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMP</span><span class="p">),</span> +</span><span id="L-521"><a href="#L-521"><span class="linenos">521</span></a> <span class="p">),</span> +</span><span id="L-522"><a href="#L-522"><span class="linenos">522</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToStr</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> +</span><span id="L-523"><a href="#L-523"><span class="linenos">523</span></a> <span class="s2">"STRFTIME"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"TO_TIMESTAMP"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">),</span> <span class="bp">self</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> +</span><span id="L-524"><a href="#L-524"><span class="linenos">524</span></a> <span class="p">),</span> +</span><span id="L-525"><a href="#L-525"><span class="linenos">525</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToTime</span><span class="p">:</span> <span class="n">_unix_to_time_sql</span><span class="p">,</span> +</span><span id="L-526"><a href="#L-526"><span class="linenos">526</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToTimeStr</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"CAST(TO_TIMESTAMP(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">) AS TEXT)"</span><span class="p">,</span> +</span><span id="L-527"><a href="#L-527"><span class="linenos">527</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VariancePop</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"VAR_POP"</span><span class="p">),</span> +</span><span id="L-528"><a href="#L-528"><span class="linenos">528</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">WeekOfYear</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"WEEKOFYEAR"</span><span class="p">),</span> +</span><span id="L-529"><a href="#L-529"><span class="linenos">529</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Xor</span><span class="p">:</span> <span class="n">bool_xor_sql</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="n">SUPPORTED_JSON_PATH_PARTS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-533"><a href="#L-533"><span class="linenos">533</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONPathKey</span><span class="p">,</span> +</span><span id="L-534"><a href="#L-534"><span class="linenos">534</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONPathRoot</span><span class="p">,</span> +</span><span id="L-535"><a href="#L-535"><span class="linenos">535</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONPathSubscript</span><span class="p">,</span> +</span><span id="L-536"><a href="#L-536"><span class="linenos">536</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONPathWildcard</span><span class="p">,</span> +</span><span id="L-537"><a href="#L-537"><span class="linenos">537</span></a> <span class="p">}</span> +</span><span id="L-538"><a href="#L-538"><span class="linenos">538</span></a> +</span><span id="L-539"><a href="#L-539"><span class="linenos">539</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-540"><a href="#L-540"><span class="linenos">540</span></a> <span class="o">**</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">TYPE_MAPPING</span><span class="p">,</span> +</span><span id="L-541"><a href="#L-541"><span class="linenos">541</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">BINARY</span><span class="p">:</span> <span class="s2">"BLOB"</span><span class="p">,</span> +</span><span id="L-542"><a href="#L-542"><span class="linenos">542</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">BPCHAR</span><span class="p">:</span> <span class="s2">"TEXT"</span><span class="p">,</span> +</span><span id="L-543"><a href="#L-543"><span class="linenos">543</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">CHAR</span><span class="p">:</span> <span class="s2">"TEXT"</span><span class="p">,</span> +</span><span id="L-544"><a href="#L-544"><span class="linenos">544</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">FLOAT</span><span class="p">:</span> <span class="s2">"REAL"</span><span class="p">,</span> +</span><span id="L-545"><a href="#L-545"><span class="linenos">545</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">NCHAR</span><span class="p">:</span> <span class="s2">"TEXT"</span><span class="p">,</span> +</span><span id="L-546"><a href="#L-546"><span class="linenos">546</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">NVARCHAR</span><span class="p">:</span> <span class="s2">"TEXT"</span><span class="p">,</span> +</span><span id="L-547"><a href="#L-547"><span class="linenos">547</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">UINT</span><span class="p">:</span> <span class="s2">"UINTEGER"</span><span class="p">,</span> +</span><span id="L-548"><a href="#L-548"><span class="linenos">548</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-549"><a href="#L-549"><span class="linenos">549</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-550"><a href="#L-550"><span class="linenos">550</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-551"><a href="#L-551"><span class="linenos">551</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-552"><a href="#L-552"><span class="linenos">552</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-553"><a href="#L-553"><span class="linenos">553</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-554"><a href="#L-554"><span class="linenos">554</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-555"><a href="#L-555"><span class="linenos">555</span></a> <span class="p">}</span> +</span><span id="L-556"><a href="#L-556"><span class="linenos">556</span></a> +</span><span id="L-557"><a href="#L-557"><span class="linenos">557</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-558"><a href="#L-558"><span class="linenos">558</span></a> <span class="n">RESERVED_KEYWORDS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-559"><a href="#L-559"><span class="linenos">559</span></a> <span class="s2">"array"</span><span class="p">,</span> +</span><span id="L-560"><a href="#L-560"><span class="linenos">560</span></a> <span class="s2">"analyse"</span><span class="p">,</span> +</span><span id="L-561"><a href="#L-561"><span class="linenos">561</span></a> <span class="s2">"union"</span><span class="p">,</span> +</span><span id="L-562"><a href="#L-562"><span class="linenos">562</span></a> <span class="s2">"all"</span><span class="p">,</span> +</span><span id="L-563"><a href="#L-563"><span class="linenos">563</span></a> <span class="s2">"when"</span><span class="p">,</span> +</span><span id="L-564"><a href="#L-564"><span class="linenos">564</span></a> <span class="s2">"in_p"</span><span class="p">,</span> +</span><span id="L-565"><a href="#L-565"><span class="linenos">565</span></a> <span class="s2">"default"</span><span class="p">,</span> +</span><span id="L-566"><a href="#L-566"><span class="linenos">566</span></a> <span class="s2">"create_p"</span><span class="p">,</span> +</span><span id="L-567"><a href="#L-567"><span class="linenos">567</span></a> <span class="s2">"window"</span><span class="p">,</span> +</span><span id="L-568"><a href="#L-568"><span class="linenos">568</span></a> <span class="s2">"asymmetric"</span><span class="p">,</span> +</span><span id="L-569"><a href="#L-569"><span class="linenos">569</span></a> <span class="s2">"to"</span><span class="p">,</span> +</span><span id="L-570"><a href="#L-570"><span class="linenos">570</span></a> <span class="s2">"else"</span><span class="p">,</span> +</span><span id="L-571"><a href="#L-571"><span class="linenos">571</span></a> <span class="s2">"localtime"</span><span class="p">,</span> +</span><span id="L-572"><a href="#L-572"><span class="linenos">572</span></a> <span class="s2">"from"</span><span class="p">,</span> +</span><span id="L-573"><a href="#L-573"><span class="linenos">573</span></a> <span class="s2">"end_p"</span><span class="p">,</span> +</span><span id="L-574"><a href="#L-574"><span class="linenos">574</span></a> <span class="s2">"select"</span><span class="p">,</span> +</span><span id="L-575"><a href="#L-575"><span class="linenos">575</span></a> <span class="s2">"current_date"</span><span class="p">,</span> +</span><span id="L-576"><a href="#L-576"><span class="linenos">576</span></a> <span class="s2">"foreign"</span><span class="p">,</span> +</span><span id="L-577"><a href="#L-577"><span class="linenos">577</span></a> <span class="s2">"with"</span><span class="p">,</span> +</span><span id="L-578"><a href="#L-578"><span class="linenos">578</span></a> <span class="s2">"grant"</span><span class="p">,</span> +</span><span id="L-579"><a href="#L-579"><span class="linenos">579</span></a> <span class="s2">"session_user"</span><span class="p">,</span> +</span><span id="L-580"><a href="#L-580"><span class="linenos">580</span></a> <span class="s2">"or"</span><span class="p">,</span> +</span><span id="L-581"><a href="#L-581"><span class="linenos">581</span></a> <span class="s2">"except"</span><span class="p">,</span> +</span><span id="L-582"><a href="#L-582"><span class="linenos">582</span></a> <span class="s2">"references"</span><span class="p">,</span> +</span><span id="L-583"><a href="#L-583"><span class="linenos">583</span></a> <span class="s2">"fetch"</span><span class="p">,</span> +</span><span id="L-584"><a href="#L-584"><span class="linenos">584</span></a> <span class="s2">"limit"</span><span class="p">,</span> +</span><span id="L-585"><a href="#L-585"><span class="linenos">585</span></a> <span class="s2">"group_p"</span><span class="p">,</span> +</span><span id="L-586"><a href="#L-586"><span class="linenos">586</span></a> <span class="s2">"leading"</span><span class="p">,</span> +</span><span id="L-587"><a href="#L-587"><span class="linenos">587</span></a> <span class="s2">"into"</span><span class="p">,</span> +</span><span id="L-588"><a href="#L-588"><span class="linenos">588</span></a> <span class="s2">"collate"</span><span class="p">,</span> +</span><span id="L-589"><a href="#L-589"><span class="linenos">589</span></a> <span class="s2">"offset"</span><span class="p">,</span> +</span><span id="L-590"><a href="#L-590"><span class="linenos">590</span></a> <span class="s2">"do"</span><span class="p">,</span> +</span><span id="L-591"><a href="#L-591"><span class="linenos">591</span></a> <span class="s2">"then"</span><span class="p">,</span> +</span><span id="L-592"><a href="#L-592"><span class="linenos">592</span></a> <span class="s2">"localtimestamp"</span><span class="p">,</span> +</span><span id="L-593"><a href="#L-593"><span class="linenos">593</span></a> <span class="s2">"check_p"</span><span class="p">,</span> +</span><span id="L-594"><a href="#L-594"><span class="linenos">594</span></a> <span class="s2">"lateral_p"</span><span class="p">,</span> +</span><span id="L-595"><a href="#L-595"><span class="linenos">595</span></a> <span class="s2">"current_role"</span><span class="p">,</span> +</span><span id="L-596"><a href="#L-596"><span class="linenos">596</span></a> <span class="s2">"where"</span><span class="p">,</span> +</span><span id="L-597"><a href="#L-597"><span class="linenos">597</span></a> <span class="s2">"asc_p"</span><span class="p">,</span> +</span><span id="L-598"><a href="#L-598"><span class="linenos">598</span></a> <span class="s2">"placing"</span><span class="p">,</span> +</span><span id="L-599"><a href="#L-599"><span class="linenos">599</span></a> <span class="s2">"desc_p"</span><span class="p">,</span> +</span><span id="L-600"><a href="#L-600"><span class="linenos">600</span></a> <span class="s2">"user"</span><span class="p">,</span> +</span><span id="L-601"><a href="#L-601"><span class="linenos">601</span></a> <span class="s2">"unique"</span><span class="p">,</span> +</span><span id="L-602"><a href="#L-602"><span class="linenos">602</span></a> <span class="s2">"initially"</span><span class="p">,</span> +</span><span id="L-603"><a href="#L-603"><span class="linenos">603</span></a> <span class="s2">"column"</span><span class="p">,</span> +</span><span id="L-604"><a href="#L-604"><span class="linenos">604</span></a> <span class="s2">"both"</span><span class="p">,</span> +</span><span id="L-605"><a href="#L-605"><span class="linenos">605</span></a> <span class="s2">"some"</span><span class="p">,</span> +</span><span id="L-606"><a href="#L-606"><span class="linenos">606</span></a> <span class="s2">"as"</span><span class="p">,</span> +</span><span id="L-607"><a href="#L-607"><span class="linenos">607</span></a> <span class="s2">"any"</span><span class="p">,</span> +</span><span id="L-608"><a href="#L-608"><span class="linenos">608</span></a> <span class="s2">"only"</span><span class="p">,</span> +</span><span id="L-609"><a href="#L-609"><span class="linenos">609</span></a> <span class="s2">"deferrable"</span><span class="p">,</span> +</span><span id="L-610"><a href="#L-610"><span class="linenos">610</span></a> <span class="s2">"null_p"</span><span class="p">,</span> +</span><span id="L-611"><a href="#L-611"><span class="linenos">611</span></a> <span class="s2">"current_time"</span><span class="p">,</span> +</span><span id="L-612"><a href="#L-612"><span class="linenos">612</span></a> <span class="s2">"true_p"</span><span class="p">,</span> +</span><span id="L-613"><a href="#L-613"><span class="linenos">613</span></a> <span class="s2">"table"</span><span class="p">,</span> +</span><span id="L-614"><a href="#L-614"><span class="linenos">614</span></a> <span class="s2">"case"</span><span class="p">,</span> +</span><span id="L-615"><a href="#L-615"><span class="linenos">615</span></a> <span class="s2">"trailing"</span><span class="p">,</span> +</span><span id="L-616"><a href="#L-616"><span class="linenos">616</span></a> <span class="s2">"variadic"</span><span class="p">,</span> +</span><span id="L-617"><a href="#L-617"><span class="linenos">617</span></a> <span class="s2">"for"</span><span class="p">,</span> +</span><span id="L-618"><a href="#L-618"><span class="linenos">618</span></a> <span class="s2">"on"</span><span class="p">,</span> +</span><span id="L-619"><a href="#L-619"><span class="linenos">619</span></a> <span class="s2">"distinct"</span><span class="p">,</span> +</span><span id="L-620"><a href="#L-620"><span class="linenos">620</span></a> <span class="s2">"false_p"</span><span class="p">,</span> +</span><span id="L-621"><a href="#L-621"><span class="linenos">621</span></a> <span class="s2">"not"</span><span class="p">,</span> +</span><span id="L-622"><a href="#L-622"><span class="linenos">622</span></a> <span class="s2">"constraint"</span><span class="p">,</span> +</span><span id="L-623"><a href="#L-623"><span class="linenos">623</span></a> <span class="s2">"current_timestamp"</span><span class="p">,</span> +</span><span id="L-624"><a href="#L-624"><span class="linenos">624</span></a> <span class="s2">"returning"</span><span class="p">,</span> +</span><span id="L-625"><a href="#L-625"><span class="linenos">625</span></a> <span class="s2">"primary"</span><span class="p">,</span> +</span><span id="L-626"><a href="#L-626"><span class="linenos">626</span></a> <span class="s2">"intersect"</span><span class="p">,</span> +</span><span id="L-627"><a href="#L-627"><span class="linenos">627</span></a> <span class="s2">"having"</span><span class="p">,</span> +</span><span id="L-628"><a href="#L-628"><span class="linenos">628</span></a> <span class="s2">"analyze"</span><span class="p">,</span> +</span><span id="L-629"><a href="#L-629"><span class="linenos">629</span></a> <span class="s2">"current_user"</span><span class="p">,</span> +</span><span id="L-630"><a href="#L-630"><span class="linenos">630</span></a> <span class="s2">"and"</span><span class="p">,</span> +</span><span id="L-631"><a href="#L-631"><span class="linenos">631</span></a> <span class="s2">"cast"</span><span class="p">,</span> +</span><span id="L-632"><a href="#L-632"><span class="linenos">632</span></a> <span class="s2">"symmetric"</span><span class="p">,</span> +</span><span id="L-633"><a href="#L-633"><span class="linenos">633</span></a> <span class="s2">"using"</span><span class="p">,</span> +</span><span id="L-634"><a href="#L-634"><span class="linenos">634</span></a> <span class="s2">"order"</span><span class="p">,</span> +</span><span id="L-635"><a href="#L-635"><span class="linenos">635</span></a> <span class="s2">"current_catalog"</span><span class="p">,</span> +</span><span id="L-636"><a href="#L-636"><span class="linenos">636</span></a> <span class="p">}</span> +</span><span id="L-637"><a href="#L-637"><span class="linenos">637</span></a> +</span><span id="L-638"><a href="#L-638"><span class="linenos">638</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-639"><a href="#L-639"><span class="linenos">639</span></a> +</span><span id="L-640"><a href="#L-640"><span class="linenos">640</span></a> <span class="c1"># DuckDB doesn't generally support CREATE TABLE .. properties</span> +</span><span id="L-641"><a href="#L-641"><span class="linenos">641</span></a> <span class="c1"># https://duckdb.org/docs/sql/statements/create_table.html</span> +</span><span id="L-642"><a href="#L-642"><span class="linenos">642</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-643"><a href="#L-643"><span class="linenos">643</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-644"><a href="#L-644"><span class="linenos">644</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-645"><a href="#L-645"><span class="linenos">645</span></a> <span class="p">}</span> </span><span id="L-646"><a href="#L-646"><span class="linenos">646</span></a> -</span><span id="L-647"><a href="#L-647"><span class="linenos">647</span></a> <span class="k">def</span> <span class="nf">strtotime_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">StrToTime</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-648"><a href="#L-648"><span class="linenos">648</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">"safe"</span><span class="p">):</span> -</span><span id="L-649"><a href="#L-649"><span class="linenos">649</span></a> <span class="n">formatted_time</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="L-650"><a href="#L-650"><span class="linenos">650</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CAST(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s1">'TRY_STRPTIME'</span><span class="p">,</span><span class="w"> </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">formatted_time</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS TIMESTAMP)"</span> -</span><span id="L-651"><a href="#L-651"><span class="linenos">651</span></a> <span class="k">return</span> <span class="n">str_to_time_sql</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-647"><a href="#L-647"><span class="linenos">647</span></a> <span class="c1"># There are a few exceptions (e.g. temporary tables) which are supported or</span> +</span><span id="L-648"><a href="#L-648"><span class="linenos">648</span></a> <span class="c1"># can be transpiled to DuckDB, so we explicitly override them accordingly</span> +</span><span id="L-649"><a href="#L-649"><span class="linenos">649</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-650"><a href="#L-650"><span class="linenos">650</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-651"><a href="#L-651"><span class="linenos">651</span></a> <span class="n">PROPERTIES_LOCATION</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">ReturnsProperty</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_ALIAS</span> </span><span id="L-652"><a href="#L-652"><span class="linenos">652</span></a> -</span><span id="L-653"><a href="#L-653"><span class="linenos">653</span></a> <span class="k">def</span> <span class="nf">strtodate_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">StrToDate</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-653"><a href="#L-653"><span class="linenos">653</span></a> <span class="k">def</span> <span class="nf">strtotime_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">StrToTime</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> </span><span id="L-654"><a href="#L-654"><span class="linenos">654</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">"safe"</span><span class="p">):</span> </span><span id="L-655"><a href="#L-655"><span class="linenos">655</span></a> <span class="n">formatted_time</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="L-656"><a href="#L-656"><span class="linenos">656</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CAST(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s1">'TRY_STRPTIME'</span><span class="p">,</span><span class="w"> </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">formatted_time</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS DATE)"</span> -</span><span id="L-657"><a href="#L-657"><span class="linenos">657</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CAST(</span><span class="si">{</span><span class="n">str_to_time_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="w"> </span><span class="n">expression</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS DATE)"</span> +</span><span id="L-656"><a href="#L-656"><span class="linenos">656</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CAST(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s1">'TRY_STRPTIME'</span><span class="p">,</span><span class="w"> </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">formatted_time</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS TIMESTAMP)"</span> +</span><span id="L-657"><a href="#L-657"><span class="linenos">657</span></a> <span class="k">return</span> <span class="n">str_to_time_sql</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-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">def</span> <span class="nf">parsejson_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ParseJSON</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-660"><a href="#L-660"><span class="linenos">660</span></a> <span class="n">arg</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> -</span><span id="L-661"><a href="#L-661"><span class="linenos">661</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">"safe"</span><span class="p">):</span> -</span><span id="L-662"><a href="#L-662"><span class="linenos">662</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">case</span><span class="p">()</span><span class="o">.</span><span class="n">when</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"json_valid"</span><span class="p">,</span> <span class="n">arg</span><span class="p">),</span> <span class="n">arg</span><span class="p">)</span><span class="o">.</span><span class="n">else_</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">null</span><span class="p">()))</span> -</span><span id="L-663"><a href="#L-663"><span class="linenos">663</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"JSON"</span><span class="p">,</span> <span class="n">arg</span><span class="p">)</span> +</span><span id="L-659"><a href="#L-659"><span class="linenos">659</span></a> <span class="k">def</span> <span class="nf">strtodate_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">StrToDate</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-660"><a href="#L-660"><span class="linenos">660</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">"safe"</span><span class="p">):</span> +</span><span id="L-661"><a href="#L-661"><span class="linenos">661</span></a> <span class="n">formatted_time</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-662"><a href="#L-662"><span class="linenos">662</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CAST(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s1">'TRY_STRPTIME'</span><span class="p">,</span><span class="w"> </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">formatted_time</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS DATE)"</span> +</span><span id="L-663"><a href="#L-663"><span class="linenos">663</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CAST(</span><span class="si">{</span><span class="n">str_to_time_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="w"> </span><span class="n">expression</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS DATE)"</span> </span><span id="L-664"><a href="#L-664"><span class="linenos">664</span></a> -</span><span id="L-665"><a href="#L-665"><span class="linenos">665</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-666"><a href="#L-666"><span class="linenos">666</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-667"><a href="#L-667"><span class="linenos">667</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-668"><a href="#L-668"><span class="linenos">668</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> -</span><span id="L-669"><a href="#L-669"><span class="linenos">669</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-670"><a href="#L-670"><span class="linenos">670</span></a> <span class="p">)</span> -</span><span id="L-671"><a href="#L-671"><span class="linenos">671</span></a> -</span><span id="L-672"><a href="#L-672"><span class="linenos">672</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-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">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-675"><a href="#L-675"><span class="linenos">675</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-676"><a href="#L-676"><span class="linenos">676</span></a> -</span><span id="L-677"><a href="#L-677"><span class="linenos">677</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-678"><a href="#L-678"><span class="linenos">678</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-679"><a href="#L-679"><span class="linenos">679</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-680"><a href="#L-680"><span class="linenos">680</span></a> -</span><span id="L-681"><a href="#L-681"><span class="linenos">681</span></a> <span class="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-682"><a href="#L-682"><span class="linenos">682</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-683"><a href="#L-683"><span class="linenos">683</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-684"><a href="#L-684"><span class="linenos">684</span></a> -</span><span id="L-685"><a href="#L-685"><span class="linenos">685</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-686"><a href="#L-686"><span class="linenos">686</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-687"><a href="#L-687"><span class="linenos">687</span></a> -</span><span id="L-688"><a href="#L-688"><span class="linenos">688</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-689"><a href="#L-689"><span class="linenos">689</span></a> -</span><span id="L-690"><a href="#L-690"><span class="linenos">690</span></a> <span class="k">def</span> <span class="nf">tablesample_sql</span><span class="p">(</span> -</span><span id="L-691"><a href="#L-691"><span class="linenos">691</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="L-692"><a href="#L-692"><span class="linenos">692</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-693"><a href="#L-693"><span class="linenos">693</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-694"><a href="#L-694"><span class="linenos">694</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-695"><a href="#L-695"><span class="linenos">695</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-696"><a href="#L-696"><span class="linenos">696</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-697"><a href="#L-697"><span class="linenos">697</span></a> <span class="c1"># This sample clause only applies to a single source, not the entire resulting relation</span> -</span><span id="L-698"><a href="#L-698"><span class="linenos">698</span></a> <span class="n">tablesample_keyword</span> <span class="o">=</span> <span class="s2">"TABLESAMPLE"</span> -</span><span id="L-699"><a href="#L-699"><span class="linenos">699</span></a> -</span><span id="L-700"><a href="#L-700"><span class="linenos">700</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-701"><a href="#L-701"><span class="linenos">701</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-702"><a href="#L-702"><span class="linenos">702</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-703"><a href="#L-703"><span class="linenos">703</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span> -</span><span id="L-704"><a href="#L-704"><span class="linenos">704</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-705"><a href="#L-705"><span class="linenos">705</span></a> <span class="s2">"defaulting to reservoir sampling"</span> -</span><span id="L-706"><a href="#L-706"><span class="linenos">706</span></a> <span class="p">)</span> -</span><span id="L-707"><a href="#L-707"><span class="linenos">707</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-708"><a href="#L-708"><span class="linenos">708</span></a> -</span><span id="L-709"><a href="#L-709"><span class="linenos">709</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-710"><a href="#L-710"><span class="linenos">710</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-711"><a href="#L-711"><span class="linenos">711</span></a> <span class="p">)</span> -</span><span id="L-712"><a href="#L-712"><span class="linenos">712</span></a> -</span><span id="L-713"><a href="#L-713"><span class="linenos">713</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-714"><a href="#L-714"><span class="linenos">714</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-715"><a href="#L-715"><span class="linenos">715</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-716"><a href="#L-716"><span class="linenos">716</span></a> -</span><span id="L-717"><a href="#L-717"><span class="linenos">717</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-718"><a href="#L-718"><span class="linenos">718</span></a> <span class="n">multiplier</span> <span class="o">=</span> <span class="mi">7</span> -</span><span id="L-719"><a href="#L-719"><span class="linenos">719</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-720"><a href="#L-720"><span class="linenos">720</span></a> <span class="n">multiplier</span> <span class="o">=</span> <span class="mi">90</span> -</span><span id="L-721"><a href="#L-721"><span class="linenos">721</span></a> -</span><span id="L-722"><a href="#L-722"><span class="linenos">722</span></a> <span class="k">if</span> <span class="n">multiplier</span><span class="p">:</span> -</span><span id="L-723"><a href="#L-723"><span class="linenos">723</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-724"><a href="#L-724"><span class="linenos">724</span></a> -</span><span id="L-725"><a href="#L-725"><span class="linenos">725</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-726"><a href="#L-726"><span class="linenos">726</span></a> -</span><span id="L-727"><a href="#L-727"><span class="linenos">727</span></a> <span class="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-728"><a href="#L-728"><span class="linenos">728</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-729"><a href="#L-729"><span class="linenos">729</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-730"><a href="#L-730"><span class="linenos">730</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-731"><a href="#L-731"><span class="linenos">731</span></a> -</span><span id="L-732"><a href="#L-732"><span class="linenos">732</span></a> <span class="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-733"><a href="#L-733"><span class="linenos">733</span></a> <span class="k">if</span> <span class="p">(</span> -</span><span id="L-734"><a href="#L-734"><span class="linenos">734</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-735"><a href="#L-735"><span class="linenos">735</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-736"><a href="#L-736"><span class="linenos">736</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-737"><a href="#L-737"><span class="linenos">737</span></a> <span class="p">):</span> -</span><span id="L-738"><a href="#L-738"><span class="linenos">738</span></a> <span class="c1"># Some dialects support `LEFT JOIN UNNEST(...)` without an explicit ON clause</span> -</span><span id="L-739"><a href="#L-739"><span class="linenos">739</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-740"><a href="#L-740"><span class="linenos">740</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-741"><a href="#L-741"><span class="linenos">741</span></a> -</span><span id="L-742"><a href="#L-742"><span class="linenos">742</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-743"><a href="#L-743"><span class="linenos">743</span></a> -</span><span id="L-744"><a href="#L-744"><span class="linenos">744</span></a> <span class="k">def</span> <span class="nf">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-745"><a href="#L-745"><span class="linenos">745</span></a> <span class="c1"># GENERATE_SERIES(a, b) -> [a, b], RANGE(a, b) -> [a, b)</span> -</span><span id="L-746"><a href="#L-746"><span class="linenos">746</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-747"><a href="#L-747"><span class="linenos">747</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-748"><a href="#L-748"><span class="linenos">748</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-665"><a href="#L-665"><span class="linenos">665</span></a> <span class="k">def</span> <span class="nf">parsejson_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ParseJSON</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-666"><a href="#L-666"><span class="linenos">666</span></a> <span class="n">arg</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> +</span><span id="L-667"><a href="#L-667"><span class="linenos">667</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">"safe"</span><span class="p">):</span> +</span><span id="L-668"><a href="#L-668"><span class="linenos">668</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">case</span><span class="p">()</span><span class="o">.</span><span class="n">when</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"json_valid"</span><span class="p">,</span> <span class="n">arg</span><span class="p">),</span> <span class="n">arg</span><span class="p">)</span><span class="o">.</span><span class="n">else_</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">null</span><span class="p">()))</span> +</span><span id="L-669"><a href="#L-669"><span class="linenos">669</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"JSON"</span><span class="p">,</span> <span class="n">arg</span><span class="p">)</span> +</span><span id="L-670"><a href="#L-670"><span class="linenos">670</span></a> +</span><span id="L-671"><a href="#L-671"><span class="linenos">671</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-672"><a href="#L-672"><span class="linenos">672</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-673"><a href="#L-673"><span class="linenos">673</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-674"><a href="#L-674"><span class="linenos">674</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> +</span><span id="L-675"><a href="#L-675"><span class="linenos">675</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-676"><a href="#L-676"><span class="linenos">676</span></a> <span class="p">)</span> +</span><span id="L-677"><a href="#L-677"><span class="linenos">677</span></a> +</span><span id="L-678"><a href="#L-678"><span class="linenos">678</span></a> <span class="k">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-679"><a href="#L-679"><span class="linenos">679</span></a> +</span><span id="L-680"><a href="#L-680"><span class="linenos">680</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-681"><a href="#L-681"><span class="linenos">681</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-682"><a href="#L-682"><span class="linenos">682</span></a> +</span><span id="L-683"><a href="#L-683"><span class="linenos">683</span></a> <span class="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-684"><a href="#L-684"><span class="linenos">684</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-685"><a href="#L-685"><span class="linenos">685</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-686"><a href="#L-686"><span class="linenos">686</span></a> +</span><span id="L-687"><a href="#L-687"><span class="linenos">687</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-688"><a href="#L-688"><span class="linenos">688</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-689"><a href="#L-689"><span class="linenos">689</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-690"><a href="#L-690"><span class="linenos">690</span></a> +</span><span id="L-691"><a href="#L-691"><span class="linenos">691</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-692"><a href="#L-692"><span class="linenos">692</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-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">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-695"><a href="#L-695"><span class="linenos">695</span></a> +</span><span id="L-696"><a href="#L-696"><span class="linenos">696</span></a> <span class="k">def</span> <span class="nf">tablesample_sql</span><span class="p">(</span> +</span><span id="L-697"><a href="#L-697"><span class="linenos">697</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="L-698"><a href="#L-698"><span class="linenos">698</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-699"><a href="#L-699"><span class="linenos">699</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-700"><a href="#L-700"><span class="linenos">700</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-701"><a href="#L-701"><span class="linenos">701</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</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="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-703"><a href="#L-703"><span class="linenos">703</span></a> <span class="c1"># This sample clause only applies to a single source, not the entire resulting relation</span> +</span><span id="L-704"><a href="#L-704"><span class="linenos">704</span></a> <span class="n">tablesample_keyword</span> <span class="o">=</span> <span class="s2">"TABLESAMPLE"</span> +</span><span id="L-705"><a href="#L-705"><span class="linenos">705</span></a> +</span><span id="L-706"><a href="#L-706"><span class="linenos">706</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-707"><a href="#L-707"><span class="linenos">707</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-708"><a href="#L-708"><span class="linenos">708</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-709"><a href="#L-709"><span class="linenos">709</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span> +</span><span id="L-710"><a href="#L-710"><span class="linenos">710</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-711"><a href="#L-711"><span class="linenos">711</span></a> <span class="s2">"defaulting to reservoir sampling"</span> +</span><span id="L-712"><a href="#L-712"><span class="linenos">712</span></a> <span class="p">)</span> +</span><span id="L-713"><a href="#L-713"><span class="linenos">713</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-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="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-716"><a href="#L-716"><span class="linenos">716</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-717"><a href="#L-717"><span class="linenos">717</span></a> <span class="p">)</span> +</span><span id="L-718"><a href="#L-718"><span class="linenos">718</span></a> +</span><span id="L-719"><a href="#L-719"><span class="linenos">719</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-720"><a href="#L-720"><span class="linenos">720</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-721"><a href="#L-721"><span class="linenos">721</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-722"><a href="#L-722"><span class="linenos">722</span></a> +</span><span id="L-723"><a href="#L-723"><span class="linenos">723</span></a> <span class="k">if</span> <span class="n">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-724"><a href="#L-724"><span class="linenos">724</span></a> <span class="n">multiplier</span> <span class="o">=</span> <span class="mi">7</span> +</span><span id="L-725"><a href="#L-725"><span class="linenos">725</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-726"><a href="#L-726"><span class="linenos">726</span></a> <span class="n">multiplier</span> <span class="o">=</span> <span class="mi">90</span> +</span><span id="L-727"><a href="#L-727"><span class="linenos">727</span></a> +</span><span id="L-728"><a href="#L-728"><span class="linenos">728</span></a> <span class="k">if</span> <span class="n">multiplier</span><span class="p">:</span> +</span><span id="L-729"><a href="#L-729"><span class="linenos">729</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-730"><a href="#L-730"><span class="linenos">730</span></a> +</span><span id="L-731"><a href="#L-731"><span class="linenos">731</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-732"><a href="#L-732"><span class="linenos">732</span></a> +</span><span id="L-733"><a href="#L-733"><span class="linenos">733</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-734"><a href="#L-734"><span class="linenos">734</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-735"><a href="#L-735"><span class="linenos">735</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-736"><a href="#L-736"><span class="linenos">736</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-737"><a href="#L-737"><span class="linenos">737</span></a> +</span><span id="L-738"><a href="#L-738"><span class="linenos">738</span></a> <span class="k">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-739"><a href="#L-739"><span class="linenos">739</span></a> <span class="k">if</span> <span class="p">(</span> +</span><span id="L-740"><a href="#L-740"><span class="linenos">740</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-741"><a href="#L-741"><span class="linenos">741</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-742"><a href="#L-742"><span class="linenos">742</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-743"><a href="#L-743"><span class="linenos">743</span></a> <span class="p">):</span> +</span><span id="L-744"><a href="#L-744"><span class="linenos">744</span></a> <span class="c1"># Some dialects support `LEFT JOIN UNNEST(...)` without an explicit ON clause</span> +</span><span id="L-745"><a href="#L-745"><span class="linenos">745</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-746"><a href="#L-746"><span class="linenos">746</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-747"><a href="#L-747"><span class="linenos">747</span></a> +</span><span id="L-748"><a href="#L-748"><span class="linenos">748</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-749"><a href="#L-749"><span class="linenos">749</span></a> -</span><span id="L-750"><a href="#L-750"><span class="linenos">750</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-751"><a href="#L-751"><span class="linenos">751</span></a> -</span><span id="L-752"><a href="#L-752"><span class="linenos">752</span></a> <span class="k">def</span> <span class="nf">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-753"><a href="#L-753"><span class="linenos">753</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-754"><a href="#L-754"><span class="linenos">754</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-755"><a href="#L-755"><span class="linenos">755</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-750"><a href="#L-750"><span class="linenos">750</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-751"><a href="#L-751"><span class="linenos">751</span></a> <span class="c1"># GENERATE_SERIES(a, b) -> [a, b], RANGE(a, b) -> [a, b)</span> +</span><span id="L-752"><a href="#L-752"><span class="linenos">752</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-753"><a href="#L-753"><span class="linenos">753</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-754"><a href="#L-754"><span class="linenos">754</span></a> +</span><span id="L-755"><a href="#L-755"><span class="linenos">755</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">function_fallback_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> </span><span id="L-756"><a href="#L-756"><span class="linenos">756</span></a> -</span><span id="L-757"><a href="#L-757"><span class="linenos">757</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-758"><a href="#L-758"><span class="linenos">758</span></a> -</span><span id="L-759"><a href="#L-759"><span class="linenos">759</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-760"><a href="#L-760"><span class="linenos">760</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-761"><a href="#L-761"><span class="linenos">761</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-762"><a href="#L-762"><span class="linenos">762</span></a> -</span><span id="L-763"><a href="#L-763"><span class="linenos">763</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">annotate_types</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> -</span><span id="L-764"><a href="#L-764"><span class="linenos">764</span></a> -</span><span id="L-765"><a href="#L-765"><span class="linenos">765</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-766"><a href="#L-766"><span class="linenos">766</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-757"><a href="#L-757"><span class="linenos">757</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-758"><a href="#L-758"><span class="linenos">758</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-759"><a href="#L-759"><span class="linenos">759</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-760"><a href="#L-760"><span class="linenos">760</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-761"><a href="#L-761"><span class="linenos">761</span></a> +</span><span id="L-762"><a href="#L-762"><span class="linenos">762</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-763"><a href="#L-763"><span class="linenos">763</span></a> +</span><span id="L-764"><a href="#L-764"><span class="linenos">764</span></a> <span class="k">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-765"><a href="#L-765"><span class="linenos">765</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-766"><a href="#L-766"><span class="linenos">766</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-767"><a href="#L-767"><span class="linenos">767</span></a> -</span><span id="L-768"><a href="#L-768"><span class="linenos">768</span></a> <span class="k">return</span> <span class="n">bracket</span> +</span><span id="L-768"><a href="#L-768"><span class="linenos">768</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-769"><a href="#L-769"><span class="linenos">769</span></a> -</span><span id="L-770"><a href="#L-770"><span class="linenos">770</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-771"><a href="#L-771"><span class="linenos">771</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-770"><a href="#L-770"><span class="linenos">770</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-771"><a href="#L-771"><span class="linenos">771</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-772"><a href="#L-772"><span class="linenos">772</span></a> -</span><span id="L-773"><a href="#L-773"><span class="linenos">773</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-774"><a href="#L-774"><span class="linenos">774</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-775"><a href="#L-775"><span class="linenos">775</span></a> <span class="c1"># Make the order key the first arg and slide the fraction to the right</span> -</span><span id="L-776"><a href="#L-776"><span class="linenos">776</span></a> <span class="c1"># https://duckdb.org/docs/sql/aggregates#ordered-set-aggregate-functions</span> -</span><span id="L-777"><a href="#L-777"><span class="linenos">777</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-778"><a href="#L-778"><span class="linenos">778</span></a> <span class="k">if</span> <span class="n">order_col</span><span class="p">:</span> -</span><span id="L-779"><a href="#L-779"><span class="linenos">779</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-780"><a href="#L-780"><span class="linenos">780</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-781"><a href="#L-781"><span class="linenos">781</span></a> -</span><span id="L-782"><a href="#L-782"><span class="linenos">782</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</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-783"><a href="#L-783"><span class="linenos">783</span></a> -</span><span id="L-784"><a href="#L-784"><span class="linenos">784</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-785"><a href="#L-785"><span class="linenos">785</span></a> -</span><span id="L-786"><a href="#L-786"><span class="linenos">786</span></a> <span class="k">def</span> <span class="nf">length_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Length</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-787"><a href="#L-787"><span class="linenos">787</span></a> <span class="n">arg</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> +</span><span id="L-773"><a href="#L-773"><span class="linenos">773</span></a> <span class="k">return</span> <span class="n">bracket</span> +</span><span id="L-774"><a href="#L-774"><span class="linenos">774</span></a> +</span><span id="L-775"><a href="#L-775"><span class="linenos">775</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-776"><a href="#L-776"><span class="linenos">776</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-777"><a href="#L-777"><span class="linenos">777</span></a> +</span><span id="L-778"><a href="#L-778"><span class="linenos">778</span></a> <span class="n">func</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> +</span><span id="L-779"><a href="#L-779"><span class="linenos">779</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-780"><a href="#L-780"><span class="linenos">780</span></a> <span class="c1"># Make the order key the first arg and slide the fraction to the right</span> +</span><span id="L-781"><a href="#L-781"><span class="linenos">781</span></a> <span class="c1"># https://duckdb.org/docs/sql/aggregates#ordered-set-aggregate-functions</span> +</span><span id="L-782"><a href="#L-782"><span class="linenos">782</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-783"><a href="#L-783"><span class="linenos">783</span></a> <span class="k">if</span> <span class="n">order_col</span><span class="p">:</span> +</span><span id="L-784"><a href="#L-784"><span class="linenos">784</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-785"><a href="#L-785"><span class="linenos">785</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-786"><a href="#L-786"><span class="linenos">786</span></a> +</span><span id="L-787"><a href="#L-787"><span class="linenos">787</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</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-788"><a href="#L-788"><span class="linenos">788</span></a> -</span><span id="L-789"><a href="#L-789"><span class="linenos">789</span></a> <span class="c1"># Dialects like BQ and Snowflake also accept binary values as args, so</span> -</span><span id="L-790"><a href="#L-790"><span class="linenos">790</span></a> <span class="c1"># DDB will attempt to infer the type or resort to case/when resolution</span> -</span><span id="L-791"><a href="#L-791"><span class="linenos">791</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">"binary"</span><span class="p">)</span> <span class="ow">or</span> <span class="n">arg</span><span class="o">.</span><span class="n">is_string</span><span class="p">:</span> -</span><span id="L-792"><a href="#L-792"><span class="linenos">792</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"LENGTH"</span><span class="p">,</span> <span class="n">arg</span><span class="p">)</span> +</span><span id="L-789"><a href="#L-789"><span class="linenos">789</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-790"><a href="#L-790"><span class="linenos">790</span></a> +</span><span id="L-791"><a href="#L-791"><span class="linenos">791</span></a> <span class="k">def</span> <span class="nf">length_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Length</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-792"><a href="#L-792"><span class="linenos">792</span></a> <span class="n">arg</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> </span><span id="L-793"><a href="#L-793"><span class="linenos">793</span></a> -</span><span id="L-794"><a href="#L-794"><span class="linenos">794</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">arg</span><span class="o">.</span><span class="n">type</span><span class="p">:</span> -</span><span id="L-795"><a href="#L-795"><span class="linenos">795</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-796"><a href="#L-796"><span class="linenos">796</span></a> -</span><span id="L-797"><a href="#L-797"><span class="linenos">797</span></a> <span class="n">arg</span> <span class="o">=</span> <span class="n">annotate_types</span><span class="p">(</span><span class="n">arg</span><span class="p">)</span> +</span><span id="L-794"><a href="#L-794"><span class="linenos">794</span></a> <span class="c1"># Dialects like BQ and Snowflake also accept binary values as args, so</span> +</span><span id="L-795"><a href="#L-795"><span class="linenos">795</span></a> <span class="c1"># DDB will attempt to infer the type or resort to case/when resolution</span> +</span><span id="L-796"><a href="#L-796"><span class="linenos">796</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">"binary"</span><span class="p">)</span> <span class="ow">or</span> <span class="n">arg</span><span class="o">.</span><span class="n">is_string</span><span class="p">:</span> +</span><span id="L-797"><a href="#L-797"><span class="linenos">797</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"LENGTH"</span><span class="p">,</span> <span class="n">arg</span><span class="p">)</span> </span><span id="L-798"><a href="#L-798"><span class="linenos">798</span></a> -</span><span id="L-799"><a href="#L-799"><span class="linenos">799</span></a> <span class="k">if</span> <span class="n">arg</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="o">*</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">TEXT_TYPES</span><span class="p">):</span> -</span><span id="L-800"><a href="#L-800"><span class="linenos">800</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"LENGTH"</span><span class="p">,</span> <span class="n">arg</span><span class="p">)</span> +</span><span id="L-799"><a href="#L-799"><span class="linenos">799</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">arg</span><span class="o">.</span><span class="n">type</span><span class="p">:</span> +</span><span id="L-800"><a href="#L-800"><span class="linenos">800</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-801"><a href="#L-801"><span class="linenos">801</span></a> -</span><span id="L-802"><a href="#L-802"><span class="linenos">802</span></a> <span class="c1"># We need these casts to make duckdb's static type checker happy</span> -</span><span id="L-803"><a href="#L-803"><span class="linenos">803</span></a> <span class="n">blob</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">arg</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">VARBINARY</span><span class="p">)</span> -</span><span id="L-804"><a href="#L-804"><span class="linenos">804</span></a> <span class="n">varchar</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">arg</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">VARCHAR</span><span class="p">)</span> -</span><span id="L-805"><a href="#L-805"><span class="linenos">805</span></a> -</span><span id="L-806"><a href="#L-806"><span class="linenos">806</span></a> <span class="n">case</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="L-807"><a href="#L-807"><span class="linenos">807</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">case</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"TYPEOF"</span><span class="p">,</span> <span class="n">arg</span><span class="p">))</span> -</span><span id="L-808"><a href="#L-808"><span class="linenos">808</span></a> <span class="o">.</span><span class="n">when</span><span class="p">(</span> -</span><span id="L-809"><a href="#L-809"><span class="linenos">809</span></a> <span class="s2">"'VARCHAR'"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Anonymous</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="s2">"LENGTH"</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="n">varchar</span><span class="p">])</span> -</span><span id="L-810"><a href="#L-810"><span class="linenos">810</span></a> <span class="p">)</span> <span class="c1"># anonymous to break length_sql recursion</span> -</span><span id="L-811"><a href="#L-811"><span class="linenos">811</span></a> <span class="o">.</span><span class="n">when</span><span class="p">(</span><span class="s2">"'BLOB'"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"OCTET_LENGTH"</span><span class="p">,</span> <span class="n">blob</span><span class="p">))</span> -</span><span id="L-812"><a href="#L-812"><span class="linenos">812</span></a> <span class="p">)</span> -</span><span id="L-813"><a href="#L-813"><span class="linenos">813</span></a> -</span><span id="L-814"><a href="#L-814"><span class="linenos">814</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">case</span><span class="p">)</span> -</span><span id="L-815"><a href="#L-815"><span class="linenos">815</span></a> -</span><span id="L-816"><a href="#L-816"><span class="linenos">816</span></a> <span class="k">def</span> <span class="nf">objectinsert_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ObjectInsert</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-817"><a href="#L-817"><span class="linenos">817</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-818"><a href="#L-818"><span class="linenos">818</span></a> <span class="n">key</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"key"</span><span class="p">)</span> -</span><span id="L-819"><a href="#L-819"><span class="linenos">819</span></a> <span class="n">key_sql</span> <span class="o">=</span> <span class="n">key</span><span class="o">.</span><span class="n">name</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-820"><a href="#L-820"><span class="linenos">820</span></a> <span class="n">value_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">"value"</span><span class="p">)</span> -</span><span id="L-821"><a href="#L-821"><span class="linenos">821</span></a> -</span><span id="L-822"><a href="#L-822"><span class="linenos">822</span></a> <span class="n">kv_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">key_sql</span><span class="si">}</span><span class="s2"> := </span><span class="si">{</span><span class="n">value_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-823"><a href="#L-823"><span class="linenos">823</span></a> -</span><span id="L-824"><a href="#L-824"><span class="linenos">824</span></a> <span class="c1"># If the input struct is empty e.g. transpiling OBJECT_INSERT(OBJECT_CONSTRUCT(), key, value) from Snowflake</span> -</span><span id="L-825"><a href="#L-825"><span class="linenos">825</span></a> <span class="c1"># then we can generate STRUCT_PACK which will build it since STRUCT_INSERT({}, key := value) is not valid DuckDB</span> -</span><span id="L-826"><a href="#L-826"><span class="linenos">826</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">Struct</span><span class="p">)</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">this</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> -</span><span id="L-827"><a href="#L-827"><span class="linenos">827</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"STRUCT_PACK"</span><span class="p">,</span> <span class="n">kv_sql</span><span class="p">)</span> +</span><span id="L-802"><a href="#L-802"><span class="linenos">802</span></a> <span class="n">arg</span> <span class="o">=</span> <span class="n">annotate_types</span><span class="p">(</span><span class="n">arg</span><span class="p">)</span> +</span><span id="L-803"><a href="#L-803"><span class="linenos">803</span></a> +</span><span id="L-804"><a href="#L-804"><span class="linenos">804</span></a> <span class="k">if</span> <span class="n">arg</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="o">*</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">TEXT_TYPES</span><span class="p">):</span> +</span><span id="L-805"><a href="#L-805"><span class="linenos">805</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"LENGTH"</span><span class="p">,</span> <span class="n">arg</span><span class="p">)</span> +</span><span id="L-806"><a href="#L-806"><span class="linenos">806</span></a> +</span><span id="L-807"><a href="#L-807"><span class="linenos">807</span></a> <span class="c1"># We need these casts to make duckdb's static type checker happy</span> +</span><span id="L-808"><a href="#L-808"><span class="linenos">808</span></a> <span class="n">blob</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">arg</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">VARBINARY</span><span class="p">)</span> +</span><span id="L-809"><a href="#L-809"><span class="linenos">809</span></a> <span class="n">varchar</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">arg</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">VARCHAR</span><span class="p">)</span> +</span><span id="L-810"><a href="#L-810"><span class="linenos">810</span></a> +</span><span id="L-811"><a href="#L-811"><span class="linenos">811</span></a> <span class="n">case</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="L-812"><a href="#L-812"><span class="linenos">812</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">case</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"TYPEOF"</span><span class="p">,</span> <span class="n">arg</span><span class="p">))</span> +</span><span id="L-813"><a href="#L-813"><span class="linenos">813</span></a> <span class="o">.</span><span class="n">when</span><span class="p">(</span> +</span><span id="L-814"><a href="#L-814"><span class="linenos">814</span></a> <span class="s2">"'VARCHAR'"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Anonymous</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="s2">"LENGTH"</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="n">varchar</span><span class="p">])</span> +</span><span id="L-815"><a href="#L-815"><span class="linenos">815</span></a> <span class="p">)</span> <span class="c1"># anonymous to break length_sql recursion</span> +</span><span id="L-816"><a href="#L-816"><span class="linenos">816</span></a> <span class="o">.</span><span class="n">when</span><span class="p">(</span><span class="s2">"'BLOB'"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"OCTET_LENGTH"</span><span class="p">,</span> <span class="n">blob</span><span class="p">))</span> +</span><span id="L-817"><a href="#L-817"><span class="linenos">817</span></a> <span class="p">)</span> +</span><span id="L-818"><a href="#L-818"><span class="linenos">818</span></a> +</span><span id="L-819"><a href="#L-819"><span class="linenos">819</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">case</span><span class="p">)</span> +</span><span id="L-820"><a href="#L-820"><span class="linenos">820</span></a> +</span><span id="L-821"><a href="#L-821"><span class="linenos">821</span></a> <span class="k">def</span> <span class="nf">objectinsert_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ObjectInsert</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-822"><a href="#L-822"><span class="linenos">822</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-823"><a href="#L-823"><span class="linenos">823</span></a> <span class="n">key</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"key"</span><span class="p">)</span> +</span><span id="L-824"><a href="#L-824"><span class="linenos">824</span></a> <span class="n">key_sql</span> <span class="o">=</span> <span class="n">key</span><span class="o">.</span><span class="n">name</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-825"><a href="#L-825"><span class="linenos">825</span></a> <span class="n">value_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">"value"</span><span class="p">)</span> +</span><span id="L-826"><a href="#L-826"><span class="linenos">826</span></a> +</span><span id="L-827"><a href="#L-827"><span class="linenos">827</span></a> <span class="n">kv_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">key_sql</span><span class="si">}</span><span class="s2"> := </span><span class="si">{</span><span class="n">value_sql</span><span class="si">}</span><span class="s2">"</span> </span><span id="L-828"><a href="#L-828"><span class="linenos">828</span></a> -</span><span id="L-829"><a href="#L-829"><span class="linenos">829</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"STRUCT_INSERT"</span><span class="p">,</span> <span class="n">this</span><span class="p">,</span> <span class="n">kv_sql</span><span class="p">)</span> +</span><span id="L-829"><a href="#L-829"><span class="linenos">829</span></a> <span class="c1"># If the input struct is empty e.g. transpiling OBJECT_INSERT(OBJECT_CONSTRUCT(), key, value) from Snowflake</span> +</span><span id="L-830"><a href="#L-830"><span class="linenos">830</span></a> <span class="c1"># then we can generate STRUCT_PACK which will build it since STRUCT_INSERT({}, key := value) is not valid DuckDB</span> +</span><span id="L-831"><a href="#L-831"><span class="linenos">831</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">Struct</span><span class="p">)</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">this</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> +</span><span id="L-832"><a href="#L-832"><span class="linenos">832</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"STRUCT_PACK"</span><span class="p">,</span> <span class="n">kv_sql</span><span class="p">)</span> +</span><span id="L-833"><a href="#L-833"><span class="linenos">833</span></a> +</span><span id="L-834"><a href="#L-834"><span class="linenos">834</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"STRUCT_INSERT"</span><span class="p">,</span> <span class="n">this</span><span class="p">,</span> <span class="n">kv_sql</span><span class="p">)</span> </span></pre></div> @@ -1211,6 +1219,19 @@ </section> + <section id="WRAPPED_JSON_EXTRACT_EXPRESSIONS"> + <div class="attr variable"> + <span class="name">WRAPPED_JSON_EXTRACT_EXPRESSIONS</span> = +<input id="WRAPPED_JSON_EXTRACT_EXPRESSIONS-view-value" class="view-value-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1"> + <label class="view-value-button pdoc-button" for="WRAPPED_JSON_EXTRACT_EXPRESSIONS-view-value"></label><span class="default_value">(<class '<a href="../expressions.html#Binary">sqlglot.expressions.Binary</a>'>, <class '<a href="../expressions.html#Bracket">sqlglot.expressions.Bracket</a>'>, <class '<a href="../expressions.html#In">sqlglot.expressions.In</a>'>)</span> + + + </div> + <a class="headerlink" href="#WRAPPED_JSON_EXTRACT_EXPRESSIONS"></a> + + + + </section> <section id="DuckDB"> <input id="DuckDB-view-source" class="view-source-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1"> <div class="attr class"> @@ -1222,640 +1243,640 @@ </div> <a class="headerlink" href="#DuckDB"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DuckDB-197"><a href="#DuckDB-197"><span class="linenos">197</span></a><span class="k">class</span> <span class="nc">DuckDB</span><span class="p">(</span><span class="n">Dialect</span><span class="p">):</span> -</span><span id="DuckDB-198"><a href="#DuckDB-198"><span class="linenos">198</span></a> <span class="n">NULL_ORDERING</span> <span class="o">=</span> <span class="s2">"nulls_are_last"</span> -</span><span id="DuckDB-199"><a href="#DuckDB-199"><span class="linenos">199</span></a> <span class="n">SUPPORTS_USER_DEFINED_TYPES</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="DuckDB-200"><a href="#DuckDB-200"><span class="linenos">200</span></a> <span class="n">SAFE_DIVISION</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="DuckDB-201"><a href="#DuckDB-201"><span class="linenos">201</span></a> <span class="n">INDEX_OFFSET</span> <span class="o">=</span> <span class="mi">1</span> -</span><span id="DuckDB-202"><a href="#DuckDB-202"><span class="linenos">202</span></a> <span class="n">CONCAT_COALESCE</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="DuckDB-203"><a href="#DuckDB-203"><span class="linenos">203</span></a> <span class="n">SUPPORTS_ORDER_BY_ALL</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="DuckDB-204"><a href="#DuckDB-204"><span class="linenos">204</span></a> -</span><span id="DuckDB-205"><a href="#DuckDB-205"><span class="linenos">205</span></a> <span class="c1"># https://duckdb.org/docs/sql/introduction.html#creating-a-new-table</span> -</span><span id="DuckDB-206"><a href="#DuckDB-206"><span class="linenos">206</span></a> <span class="n">NORMALIZATION_STRATEGY</span> <span class="o">=</span> <span class="n">NormalizationStrategy</span><span class="o">.</span><span class="n">CASE_INSENSITIVE</span> -</span><span id="DuckDB-207"><a href="#DuckDB-207"><span class="linenos">207</span></a> -</span><span id="DuckDB-208"><a href="#DuckDB-208"><span class="linenos">208</span></a> <span class="k">def</span> <span class="nf">to_json_path</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">])</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]:</span> -</span><span id="DuckDB-209"><a href="#DuckDB-209"><span class="linenos">209</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">path</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="p">):</span> -</span><span id="DuckDB-210"><a href="#DuckDB-210"><span class="linenos">210</span></a> <span class="c1"># DuckDB also supports the JSON pointer syntax, where every path starts with a `/`.</span> -</span><span id="DuckDB-211"><a href="#DuckDB-211"><span class="linenos">211</span></a> <span class="c1"># Additionally, it allows accessing the back of lists using the `[#-i]` syntax.</span> -</span><span id="DuckDB-212"><a href="#DuckDB-212"><span class="linenos">212</span></a> <span class="c1"># This check ensures we'll avoid trying to parse these as JSON paths, which can</span> -</span><span id="DuckDB-213"><a href="#DuckDB-213"><span class="linenos">213</span></a> <span class="c1"># either result in a noisy warning or in an invalid representation of the path.</span> -</span><span id="DuckDB-214"><a href="#DuckDB-214"><span class="linenos">214</span></a> <span class="n">path_text</span> <span class="o">=</span> <span class="n">path</span><span class="o">.</span><span class="n">name</span> -</span><span id="DuckDB-215"><a href="#DuckDB-215"><span class="linenos">215</span></a> <span class="k">if</span> <span class="n">path_text</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"/"</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">"[#"</span> <span class="ow">in</span> <span class="n">path_text</span><span class="p">:</span> -</span><span id="DuckDB-216"><a href="#DuckDB-216"><span class="linenos">216</span></a> <span class="k">return</span> <span class="n">path</span> -</span><span id="DuckDB-217"><a href="#DuckDB-217"><span class="linenos">217</span></a> -</span><span id="DuckDB-218"><a href="#DuckDB-218"><span class="linenos">218</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">to_json_path</span><span class="p">(</span><span class="n">path</span><span class="p">)</span> -</span><span id="DuckDB-219"><a href="#DuckDB-219"><span class="linenos">219</span></a> -</span><span id="DuckDB-220"><a href="#DuckDB-220"><span class="linenos">220</span></a> <span class="k">class</span> <span class="nc">Tokenizer</span><span class="p">(</span><span class="n">tokens</span><span class="o">.</span><span class="n">Tokenizer</span><span class="p">):</span> -</span><span id="DuckDB-221"><a href="#DuckDB-221"><span class="linenos">221</span></a> <span class="n">HEREDOC_STRINGS</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"$"</span><span class="p">]</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DuckDB-202"><a href="#DuckDB-202"><span class="linenos">202</span></a><span class="k">class</span> <span class="nc">DuckDB</span><span class="p">(</span><span class="n">Dialect</span><span class="p">):</span> +</span><span id="DuckDB-203"><a href="#DuckDB-203"><span class="linenos">203</span></a> <span class="n">NULL_ORDERING</span> <span class="o">=</span> <span class="s2">"nulls_are_last"</span> +</span><span id="DuckDB-204"><a href="#DuckDB-204"><span class="linenos">204</span></a> <span class="n">SUPPORTS_USER_DEFINED_TYPES</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="DuckDB-205"><a href="#DuckDB-205"><span class="linenos">205</span></a> <span class="n">SAFE_DIVISION</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="DuckDB-206"><a href="#DuckDB-206"><span class="linenos">206</span></a> <span class="n">INDEX_OFFSET</span> <span class="o">=</span> <span class="mi">1</span> +</span><span id="DuckDB-207"><a href="#DuckDB-207"><span class="linenos">207</span></a> <span class="n">CONCAT_COALESCE</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="DuckDB-208"><a href="#DuckDB-208"><span class="linenos">208</span></a> <span class="n">SUPPORTS_ORDER_BY_ALL</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="DuckDB-209"><a href="#DuckDB-209"><span class="linenos">209</span></a> +</span><span id="DuckDB-210"><a href="#DuckDB-210"><span class="linenos">210</span></a> <span class="c1"># https://duckdb.org/docs/sql/introduction.html#creating-a-new-table</span> +</span><span id="DuckDB-211"><a href="#DuckDB-211"><span class="linenos">211</span></a> <span class="n">NORMALIZATION_STRATEGY</span> <span class="o">=</span> <span class="n">NormalizationStrategy</span><span class="o">.</span><span class="n">CASE_INSENSITIVE</span> +</span><span id="DuckDB-212"><a href="#DuckDB-212"><span class="linenos">212</span></a> +</span><span id="DuckDB-213"><a href="#DuckDB-213"><span class="linenos">213</span></a> <span class="k">def</span> <span class="nf">to_json_path</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">])</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]:</span> +</span><span id="DuckDB-214"><a href="#DuckDB-214"><span class="linenos">214</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">path</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="p">):</span> +</span><span id="DuckDB-215"><a href="#DuckDB-215"><span class="linenos">215</span></a> <span class="c1"># DuckDB also supports the JSON pointer syntax, where every path starts with a `/`.</span> +</span><span id="DuckDB-216"><a href="#DuckDB-216"><span class="linenos">216</span></a> <span class="c1"># Additionally, it allows accessing the back of lists using the `[#-i]` syntax.</span> +</span><span id="DuckDB-217"><a href="#DuckDB-217"><span class="linenos">217</span></a> <span class="c1"># This check ensures we'll avoid trying to parse these as JSON paths, which can</span> +</span><span id="DuckDB-218"><a href="#DuckDB-218"><span class="linenos">218</span></a> <span class="c1"># either result in a noisy warning or in an invalid representation of the path.</span> +</span><span id="DuckDB-219"><a href="#DuckDB-219"><span class="linenos">219</span></a> <span class="n">path_text</span> <span class="o">=</span> <span class="n">path</span><span class="o">.</span><span class="n">name</span> +</span><span id="DuckDB-220"><a href="#DuckDB-220"><span class="linenos">220</span></a> <span class="k">if</span> <span class="n">path_text</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"/"</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">"[#"</span> <span class="ow">in</span> <span class="n">path_text</span><span class="p">:</span> +</span><span id="DuckDB-221"><a href="#DuckDB-221"><span class="linenos">221</span></a> <span class="k">return</span> <span class="n">path</span> </span><span id="DuckDB-222"><a href="#DuckDB-222"><span class="linenos">222</span></a> -</span><span id="DuckDB-223"><a href="#DuckDB-223"><span class="linenos">223</span></a> <span class="n">HEREDOC_TAG_IS_IDENTIFIER</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="DuckDB-224"><a href="#DuckDB-224"><span class="linenos">224</span></a> <span class="n">HEREDOC_STRING_ALTERNATIVE</span> <span class="o">=</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PARAMETER</span> -</span><span id="DuckDB-225"><a href="#DuckDB-225"><span class="linenos">225</span></a> -</span><span id="DuckDB-226"><a href="#DuckDB-226"><span class="linenos">226</span></a> <span class="n">KEYWORDS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="DuckDB-227"><a href="#DuckDB-227"><span class="linenos">227</span></a> <span class="o">**</span><span class="n">tokens</span><span class="o">.</span><span class="n">Tokenizer</span><span class="o">.</span><span class="n">KEYWORDS</span><span class="p">,</span> -</span><span id="DuckDB-228"><a href="#DuckDB-228"><span class="linenos">228</span></a> <span class="s2">"//"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DIV</span><span class="p">,</span> -</span><span id="DuckDB-229"><a href="#DuckDB-229"><span class="linenos">229</span></a> <span class="s2">"ATTACH"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">COMMAND</span><span class="p">,</span> -</span><span id="DuckDB-230"><a href="#DuckDB-230"><span class="linenos">230</span></a> <span class="s2">"BINARY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VARBINARY</span><span class="p">,</span> -</span><span id="DuckDB-231"><a href="#DuckDB-231"><span class="linenos">231</span></a> <span class="s2">"BITSTRING"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BIT</span><span class="p">,</span> -</span><span id="DuckDB-232"><a href="#DuckDB-232"><span class="linenos">232</span></a> <span class="s2">"BPCHAR"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TEXT</span><span class="p">,</span> -</span><span id="DuckDB-233"><a href="#DuckDB-233"><span class="linenos">233</span></a> <span class="s2">"CHAR"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TEXT</span><span class="p">,</span> -</span><span id="DuckDB-234"><a href="#DuckDB-234"><span class="linenos">234</span></a> <span class="s2">"CHARACTER VARYING"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TEXT</span><span class="p">,</span> -</span><span id="DuckDB-235"><a href="#DuckDB-235"><span class="linenos">235</span></a> <span class="s2">"EXCLUDE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">EXCEPT</span><span class="p">,</span> -</span><span id="DuckDB-236"><a href="#DuckDB-236"><span class="linenos">236</span></a> <span class="s2">"LOGICAL"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BOOLEAN</span><span class="p">,</span> -</span><span id="DuckDB-237"><a href="#DuckDB-237"><span class="linenos">237</span></a> <span class="s2">"ONLY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ONLY</span><span class="p">,</span> -</span><span id="DuckDB-238"><a href="#DuckDB-238"><span class="linenos">238</span></a> <span class="s2">"PIVOT_WIDER"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PIVOT</span><span class="p">,</span> -</span><span id="DuckDB-239"><a href="#DuckDB-239"><span class="linenos">239</span></a> <span class="s2">"POSITIONAL"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">POSITIONAL</span><span class="p">,</span> -</span><span id="DuckDB-240"><a href="#DuckDB-240"><span class="linenos">240</span></a> <span class="s2">"SIGNED"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">INT</span><span class="p">,</span> -</span><span id="DuckDB-241"><a href="#DuckDB-241"><span class="linenos">241</span></a> <span class="s2">"STRING"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TEXT</span><span class="p">,</span> -</span><span id="DuckDB-242"><a href="#DuckDB-242"><span class="linenos">242</span></a> <span class="s2">"UBIGINT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">UBIGINT</span><span class="p">,</span> -</span><span id="DuckDB-243"><a href="#DuckDB-243"><span class="linenos">243</span></a> <span class="s2">"UINTEGER"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">UINT</span><span class="p">,</span> -</span><span id="DuckDB-244"><a href="#DuckDB-244"><span class="linenos">244</span></a> <span class="s2">"USMALLINT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">USMALLINT</span><span class="p">,</span> -</span><span id="DuckDB-245"><a href="#DuckDB-245"><span class="linenos">245</span></a> <span class="s2">"UTINYINT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">UTINYINT</span><span class="p">,</span> -</span><span id="DuckDB-246"><a href="#DuckDB-246"><span class="linenos">246</span></a> <span class="s2">"TIMESTAMP_S"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TIMESTAMP_S</span><span class="p">,</span> -</span><span id="DuckDB-247"><a href="#DuckDB-247"><span class="linenos">247</span></a> <span class="s2">"TIMESTAMP_MS"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TIMESTAMP_MS</span><span class="p">,</span> -</span><span id="DuckDB-248"><a href="#DuckDB-248"><span class="linenos">248</span></a> <span class="s2">"TIMESTAMP_NS"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TIMESTAMP_NS</span><span class="p">,</span> -</span><span id="DuckDB-249"><a href="#DuckDB-249"><span class="linenos">249</span></a> <span class="s2">"TIMESTAMP_US"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TIMESTAMP</span><span class="p">,</span> -</span><span id="DuckDB-250"><a href="#DuckDB-250"><span class="linenos">250</span></a> <span class="s2">"VARCHAR"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TEXT</span><span class="p">,</span> -</span><span id="DuckDB-251"><a href="#DuckDB-251"><span class="linenos">251</span></a> <span class="p">}</span> -</span><span id="DuckDB-252"><a href="#DuckDB-252"><span class="linenos">252</span></a> <span class="n">KEYWORDS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">"/*+"</span><span class="p">)</span> -</span><span id="DuckDB-253"><a href="#DuckDB-253"><span class="linenos">253</span></a> -</span><span id="DuckDB-254"><a href="#DuckDB-254"><span class="linenos">254</span></a> <span class="n">SINGLE_TOKENS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="DuckDB-255"><a href="#DuckDB-255"><span class="linenos">255</span></a> <span class="o">**</span><span class="n">tokens</span><span class="o">.</span><span class="n">Tokenizer</span><span class="o">.</span><span class="n">SINGLE_TOKENS</span><span class="p">,</span> -</span><span id="DuckDB-256"><a href="#DuckDB-256"><span class="linenos">256</span></a> <span class="s2">"$"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PARAMETER</span><span class="p">,</span> +</span><span id="DuckDB-223"><a href="#DuckDB-223"><span class="linenos">223</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">to_json_path</span><span class="p">(</span><span class="n">path</span><span class="p">)</span> +</span><span id="DuckDB-224"><a href="#DuckDB-224"><span class="linenos">224</span></a> +</span><span id="DuckDB-225"><a href="#DuckDB-225"><span class="linenos">225</span></a> <span class="k">class</span> <span class="nc">Tokenizer</span><span class="p">(</span><span class="n">tokens</span><span class="o">.</span><span class="n">Tokenizer</span><span class="p">):</span> +</span><span id="DuckDB-226"><a href="#DuckDB-226"><span class="linenos">226</span></a> <span class="n">HEREDOC_STRINGS</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"$"</span><span class="p">]</span> +</span><span id="DuckDB-227"><a href="#DuckDB-227"><span class="linenos">227</span></a> +</span><span id="DuckDB-228"><a href="#DuckDB-228"><span class="linenos">228</span></a> <span class="n">HEREDOC_TAG_IS_IDENTIFIER</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="DuckDB-229"><a href="#DuckDB-229"><span class="linenos">229</span></a> <span class="n">HEREDOC_STRING_ALTERNATIVE</span> <span class="o">=</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PARAMETER</span> +</span><span id="DuckDB-230"><a href="#DuckDB-230"><span class="linenos">230</span></a> +</span><span id="DuckDB-231"><a href="#DuckDB-231"><span class="linenos">231</span></a> <span class="n">KEYWORDS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="DuckDB-232"><a href="#DuckDB-232"><span class="linenos">232</span></a> <span class="o">**</span><span class="n">tokens</span><span class="o">.</span><span class="n">Tokenizer</span><span class="o">.</span><span class="n">KEYWORDS</span><span class="p">,</span> +</span><span id="DuckDB-233"><a href="#DuckDB-233"><span class="linenos">233</span></a> <span class="s2">"//"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DIV</span><span class="p">,</span> +</span><span id="DuckDB-234"><a href="#DuckDB-234"><span class="linenos">234</span></a> <span class="s2">"ATTACH"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">COMMAND</span><span class="p">,</span> +</span><span id="DuckDB-235"><a href="#DuckDB-235"><span class="linenos">235</span></a> <span class="s2">"BINARY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VARBINARY</span><span class="p">,</span> +</span><span id="DuckDB-236"><a href="#DuckDB-236"><span class="linenos">236</span></a> <span class="s2">"BITSTRING"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BIT</span><span class="p">,</span> +</span><span id="DuckDB-237"><a href="#DuckDB-237"><span class="linenos">237</span></a> <span class="s2">"BPCHAR"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TEXT</span><span class="p">,</span> +</span><span id="DuckDB-238"><a href="#DuckDB-238"><span class="linenos">238</span></a> <span class="s2">"CHAR"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TEXT</span><span class="p">,</span> +</span><span id="DuckDB-239"><a href="#DuckDB-239"><span class="linenos">239</span></a> <span class="s2">"CHARACTER VARYING"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TEXT</span><span class="p">,</span> +</span><span id="DuckDB-240"><a href="#DuckDB-240"><span class="linenos">240</span></a> <span class="s2">"EXCLUDE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">EXCEPT</span><span class="p">,</span> +</span><span id="DuckDB-241"><a href="#DuckDB-241"><span class="linenos">241</span></a> <span class="s2">"LOGICAL"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BOOLEAN</span><span class="p">,</span> +</span><span id="DuckDB-242"><a href="#DuckDB-242"><span class="linenos">242</span></a> <span class="s2">"ONLY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ONLY</span><span class="p">,</span> +</span><span id="DuckDB-243"><a href="#DuckDB-243"><span class="linenos">243</span></a> <span class="s2">"PIVOT_WIDER"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PIVOT</span><span class="p">,</span> +</span><span id="DuckDB-244"><a href="#DuckDB-244"><span class="linenos">244</span></a> <span class="s2">"POSITIONAL"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">POSITIONAL</span><span class="p">,</span> +</span><span id="DuckDB-245"><a href="#DuckDB-245"><span class="linenos">245</span></a> <span class="s2">"SIGNED"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">INT</span><span class="p">,</span> +</span><span id="DuckDB-246"><a href="#DuckDB-246"><span class="linenos">246</span></a> <span class="s2">"STRING"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TEXT</span><span class="p">,</span> +</span><span id="DuckDB-247"><a href="#DuckDB-247"><span class="linenos">247</span></a> <span class="s2">"SUMMARIZE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SUMMARIZE</span><span class="p">,</span> +</span><span id="DuckDB-248"><a href="#DuckDB-248"><span class="linenos">248</span></a> <span class="s2">"TIMESTAMP_S"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TIMESTAMP_S</span><span class="p">,</span> +</span><span id="DuckDB-249"><a href="#DuckDB-249"><span class="linenos">249</span></a> <span class="s2">"TIMESTAMP_MS"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TIMESTAMP_MS</span><span class="p">,</span> +</span><span id="DuckDB-250"><a href="#DuckDB-250"><span class="linenos">250</span></a> <span class="s2">"TIMESTAMP_NS"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TIMESTAMP_NS</span><span class="p">,</span> +</span><span id="DuckDB-251"><a href="#DuckDB-251"><span class="linenos">251</span></a> <span class="s2">"TIMESTAMP_US"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TIMESTAMP</span><span class="p">,</span> +</span><span id="DuckDB-252"><a href="#DuckDB-252"><span class="linenos">252</span></a> <span class="s2">"UBIGINT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">UBIGINT</span><span class="p">,</span> +</span><span id="DuckDB-253"><a href="#DuckDB-253"><span class="linenos">253</span></a> <span class="s2">"UINTEGER"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">UINT</span><span class="p">,</span> +</span><span id="DuckDB-254"><a href="#DuckDB-254"><span class="linenos">254</span></a> <span class="s2">"USMALLINT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">USMALLINT</span><span class="p">,</span> +</span><span id="DuckDB-255"><a href="#DuckDB-255"><span class="linenos">255</span></a> <span class="s2">"UTINYINT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">UTINYINT</span><span class="p">,</span> +</span><span id="DuckDB-256"><a href="#DuckDB-256"><span class="linenos">256</span></a> <span class="s2">"VARCHAR"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TEXT</span><span class="p">,</span> </span><span id="DuckDB-257"><a href="#DuckDB-257"><span class="linenos">257</span></a> <span class="p">}</span> -</span><span id="DuckDB-258"><a href="#DuckDB-258"><span class="linenos">258</span></a> -</span><span id="DuckDB-259"><a href="#DuckDB-259"><span class="linenos">259</span></a> <span class="k">class</span> <span class="nc">Parser</span><span class="p">(</span><span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="p">):</span> -</span><span id="DuckDB-260"><a href="#DuckDB-260"><span class="linenos">260</span></a> <span class="n">BITWISE</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="DuckDB-261"><a href="#DuckDB-261"><span class="linenos">261</span></a> <span class="o">**</span><span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">BITWISE</span><span class="p">,</span> -</span><span id="DuckDB-262"><a href="#DuckDB-262"><span class="linenos">262</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">TILDA</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpLike</span><span class="p">,</span> +</span><span id="DuckDB-258"><a href="#DuckDB-258"><span class="linenos">258</span></a> <span class="n">KEYWORDS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">"/*+"</span><span class="p">)</span> +</span><span id="DuckDB-259"><a href="#DuckDB-259"><span class="linenos">259</span></a> +</span><span id="DuckDB-260"><a href="#DuckDB-260"><span class="linenos">260</span></a> <span class="n">SINGLE_TOKENS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="DuckDB-261"><a href="#DuckDB-261"><span class="linenos">261</span></a> <span class="o">**</span><span class="n">tokens</span><span class="o">.</span><span class="n">Tokenizer</span><span class="o">.</span><span class="n">SINGLE_TOKENS</span><span class="p">,</span> +</span><span id="DuckDB-262"><a href="#DuckDB-262"><span class="linenos">262</span></a> <span class="s2">"$"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PARAMETER</span><span class="p">,</span> </span><span id="DuckDB-263"><a href="#DuckDB-263"><span class="linenos">263</span></a> <span class="p">}</span> </span><span id="DuckDB-264"><a href="#DuckDB-264"><span class="linenos">264</span></a> -</span><span id="DuckDB-265"><a href="#DuckDB-265"><span class="linenos">265</span></a> <span class="n">FUNCTIONS_WITH_ALIASED_ARGS</span> <span class="o">=</span> <span class="p">{</span><span class="o">*</span><span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">FUNCTIONS_WITH_ALIASED_ARGS</span><span class="p">,</span> <span class="s2">"STRUCT_PACK"</span><span class="p">}</span> -</span><span id="DuckDB-266"><a href="#DuckDB-266"><span class="linenos">266</span></a> -</span><span id="DuckDB-267"><a href="#DuckDB-267"><span class="linenos">267</span></a> <span class="n">FUNCTIONS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="DuckDB-268"><a href="#DuckDB-268"><span class="linenos">268</span></a> <span class="o">**</span><span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">FUNCTIONS</span><span class="p">,</span> -</span><span id="DuckDB-269"><a href="#DuckDB-269"><span class="linenos">269</span></a> <span class="s2">"ARRAY_REVERSE_SORT"</span><span class="p">:</span> <span class="n">_build_sort_array_desc</span><span class="p">,</span> -</span><span id="DuckDB-270"><a href="#DuckDB-270"><span class="linenos">270</span></a> <span class="s2">"ARRAY_SORT"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SortArray</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="DuckDB-271"><a href="#DuckDB-271"><span class="linenos">271</span></a> <span class="s2">"DATEDIFF"</span><span class="p">:</span> <span class="n">_build_date_diff</span><span class="p">,</span> -</span><span id="DuckDB-272"><a href="#DuckDB-272"><span class="linenos">272</span></a> <span class="s2">"DATE_DIFF"</span><span class="p">:</span> <span class="n">_build_date_diff</span><span class="p">,</span> -</span><span id="DuckDB-273"><a href="#DuckDB-273"><span class="linenos">273</span></a> <span class="s2">"DATE_TRUNC"</span><span class="p">:</span> <span class="n">date_trunc_to_time</span><span class="p">,</span> -</span><span id="DuckDB-274"><a href="#DuckDB-274"><span class="linenos">274</span></a> <span class="s2">"DATETRUNC"</span><span class="p">:</span> <span class="n">date_trunc_to_time</span><span class="p">,</span> -</span><span id="DuckDB-275"><a href="#DuckDB-275"><span class="linenos">275</span></a> <span class="s2">"DECODE"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Decode</span><span class="p">(</span> -</span><span id="DuckDB-276"><a href="#DuckDB-276"><span class="linenos">276</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">charset</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">string</span><span class="p">(</span><span class="s2">"utf-8"</span><span class="p">)</span> -</span><span id="DuckDB-277"><a href="#DuckDB-277"><span class="linenos">277</span></a> <span class="p">),</span> -</span><span id="DuckDB-278"><a href="#DuckDB-278"><span class="linenos">278</span></a> <span class="s2">"ENCODE"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Encode</span><span class="p">(</span> -</span><span id="DuckDB-279"><a href="#DuckDB-279"><span class="linenos">279</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">charset</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">string</span><span class="p">(</span><span class="s2">"utf-8"</span><span class="p">)</span> -</span><span id="DuckDB-280"><a href="#DuckDB-280"><span class="linenos">280</span></a> <span class="p">),</span> -</span><span id="DuckDB-281"><a href="#DuckDB-281"><span class="linenos">281</span></a> <span class="s2">"EPOCH"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TimeToUnix</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="DuckDB-282"><a href="#DuckDB-282"><span class="linenos">282</span></a> <span class="s2">"EPOCH_MS"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToTime</span><span class="p">(</span> -</span><span id="DuckDB-283"><a href="#DuckDB-283"><span class="linenos">283</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">scale</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">UnixToTime</span><span class="o">.</span><span class="n">MILLIS</span> -</span><span id="DuckDB-284"><a href="#DuckDB-284"><span class="linenos">284</span></a> <span class="p">),</span> -</span><span id="DuckDB-285"><a href="#DuckDB-285"><span class="linenos">285</span></a> <span class="s2">"JSON"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ParseJSON</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="DuckDB-286"><a href="#DuckDB-286"><span class="linenos">286</span></a> <span class="s2">"JSON_EXTRACT_PATH"</span><span class="p">:</span> <span class="n">parser</span><span class="o">.</span><span class="n">build_extract_json_with_path</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">JSONExtract</span><span class="p">),</span> -</span><span id="DuckDB-287"><a href="#DuckDB-287"><span class="linenos">287</span></a> <span class="s2">"JSON_EXTRACT_STRING"</span><span class="p">:</span> <span class="n">parser</span><span class="o">.</span><span class="n">build_extract_json_with_path</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">JSONExtractScalar</span><span class="p">),</span> -</span><span id="DuckDB-288"><a href="#DuckDB-288"><span class="linenos">288</span></a> <span class="s2">"LIST_HAS"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayContains</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="DuckDB-289"><a href="#DuckDB-289"><span class="linenos">289</span></a> <span class="s2">"LIST_REVERSE_SORT"</span><span class="p">:</span> <span class="n">_build_sort_array_desc</span><span class="p">,</span> -</span><span id="DuckDB-290"><a href="#DuckDB-290"><span class="linenos">290</span></a> <span class="s2">"LIST_SORT"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SortArray</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="DuckDB-291"><a href="#DuckDB-291"><span class="linenos">291</span></a> <span class="s2">"LIST_VALUE"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Array</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="DuckDB-292"><a href="#DuckDB-292"><span class="linenos">292</span></a> <span class="s2">"MAKE_TIME"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TimeFromParts</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="DuckDB-293"><a href="#DuckDB-293"><span class="linenos">293</span></a> <span class="s2">"MAKE_TIMESTAMP"</span><span class="p">:</span> <span class="n">_build_make_timestamp</span><span class="p">,</span> -</span><span id="DuckDB-294"><a href="#DuckDB-294"><span class="linenos">294</span></a> <span class="s2">"MEDIAN"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">PercentileCont</span><span class="p">(</span> -</span><span id="DuckDB-295"><a href="#DuckDB-295"><span class="linenos">295</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">number</span><span class="p">(</span><span class="mf">0.5</span><span class="p">)</span> -</span><span id="DuckDB-296"><a href="#DuckDB-296"><span class="linenos">296</span></a> <span class="p">),</span> -</span><span id="DuckDB-297"><a href="#DuckDB-297"><span class="linenos">297</span></a> <span class="s2">"QUANTILE_CONT"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">PercentileCont</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="DuckDB-298"><a href="#DuckDB-298"><span class="linenos">298</span></a> <span class="s2">"QUANTILE_DISC"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">PercentileDisc</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="DuckDB-299"><a href="#DuckDB-299"><span class="linenos">299</span></a> <span class="s2">"REGEXP_EXTRACT"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpExtract</span><span class="p">(</span> -</span><span id="DuckDB-300"><a href="#DuckDB-300"><span class="linenos">300</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">expression</span><span class="o">=</span><span class="n">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 class="n">group</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">2</span><span class="p">)</span> -</span><span id="DuckDB-301"><a href="#DuckDB-301"><span class="linenos">301</span></a> <span class="p">),</span> -</span><span id="DuckDB-302"><a href="#DuckDB-302"><span class="linenos">302</span></a> <span class="s2">"REGEXP_MATCHES"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpLike</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="DuckDB-303"><a href="#DuckDB-303"><span class="linenos">303</span></a> <span class="s2">"REGEXP_REPLACE"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpReplace</span><span class="p">(</span> -</span><span id="DuckDB-304"><a href="#DuckDB-304"><span class="linenos">304</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> -</span><span id="DuckDB-305"><a href="#DuckDB-305"><span class="linenos">305</span></a> <span class="n">expression</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-306"><a href="#DuckDB-306"><span class="linenos">306</span></a> <span class="n">replacement</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">2</span><span class="p">),</span> -</span><span id="DuckDB-307"><a href="#DuckDB-307"><span class="linenos">307</span></a> <span class="n">modifiers</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">3</span><span class="p">),</span> -</span><span id="DuckDB-308"><a href="#DuckDB-308"><span class="linenos">308</span></a> <span class="p">),</span> -</span><span id="DuckDB-309"><a href="#DuckDB-309"><span class="linenos">309</span></a> <span class="s2">"STRFTIME"</span><span class="p">:</span> <span class="n">build_formatted_time</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">TimeToStr</span><span class="p">,</span> <span class="s2">"duckdb"</span><span class="p">),</span> -</span><span id="DuckDB-310"><a href="#DuckDB-310"><span class="linenos">310</span></a> <span class="s2">"STRING_SPLIT"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Split</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="DuckDB-311"><a href="#DuckDB-311"><span class="linenos">311</span></a> <span class="s2">"STRING_SPLIT_REGEX"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpSplit</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="DuckDB-312"><a href="#DuckDB-312"><span class="linenos">312</span></a> <span class="s2">"STRING_TO_ARRAY"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Split</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="DuckDB-313"><a href="#DuckDB-313"><span class="linenos">313</span></a> <span class="s2">"STRPTIME"</span><span class="p">:</span> <span class="n">build_formatted_time</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">StrToTime</span><span class="p">,</span> <span class="s2">"duckdb"</span><span class="p">),</span> -</span><span id="DuckDB-314"><a href="#DuckDB-314"><span class="linenos">314</span></a> <span class="s2">"STRUCT_PACK"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Struct</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="DuckDB-315"><a href="#DuckDB-315"><span class="linenos">315</span></a> <span class="s2">"STR_SPLIT"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Split</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="DuckDB-316"><a href="#DuckDB-316"><span class="linenos">316</span></a> <span class="s2">"STR_SPLIT_REGEX"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpSplit</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="DuckDB-317"><a href="#DuckDB-317"><span class="linenos">317</span></a> <span class="s2">"TO_TIMESTAMP"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToTime</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="DuckDB-318"><a href="#DuckDB-318"><span class="linenos">318</span></a> <span class="s2">"UNNEST"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Explode</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="DuckDB-319"><a href="#DuckDB-319"><span class="linenos">319</span></a> <span class="s2">"XOR"</span><span class="p">:</span> <span class="n">binary_from_function</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">BitwiseXor</span><span class="p">),</span> -</span><span id="DuckDB-320"><a href="#DuckDB-320"><span class="linenos">320</span></a> <span class="s2">"GENERATE_SERIES"</span><span class="p">:</span> <span class="n">_build_generate_series</span><span class="p">(),</span> -</span><span id="DuckDB-321"><a href="#DuckDB-321"><span class="linenos">321</span></a> <span class="s2">"RANGE"</span><span class="p">:</span> <span class="n">_build_generate_series</span><span class="p">(</span><span class="n">end_exclusive</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> -</span><span id="DuckDB-322"><a href="#DuckDB-322"><span class="linenos">322</span></a> <span class="p">}</span> -</span><span id="DuckDB-323"><a href="#DuckDB-323"><span class="linenos">323</span></a> -</span><span id="DuckDB-324"><a href="#DuckDB-324"><span class="linenos">324</span></a> <span class="n">FUNCTIONS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">"DATE_SUB"</span><span class="p">)</span> -</span><span id="DuckDB-325"><a href="#DuckDB-325"><span class="linenos">325</span></a> -</span><span id="DuckDB-326"><a href="#DuckDB-326"><span class="linenos">326</span></a> <span class="n">FUNCTION_PARSERS</span> <span class="o">=</span> <span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">FUNCTION_PARSERS</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> -</span><span id="DuckDB-327"><a href="#DuckDB-327"><span class="linenos">327</span></a> <span class="n">FUNCTION_PARSERS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">"DECODE"</span><span class="p">)</span> -</span><span id="DuckDB-328"><a href="#DuckDB-328"><span class="linenos">328</span></a> -</span><span id="DuckDB-329"><a href="#DuckDB-329"><span class="linenos">329</span></a> <span class="n">NO_PAREN_FUNCTION_PARSERS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="DuckDB-330"><a href="#DuckDB-330"><span class="linenos">330</span></a> <span class="o">**</span><span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">NO_PAREN_FUNCTION_PARSERS</span><span class="p">,</span> -</span><span id="DuckDB-331"><a href="#DuckDB-331"><span class="linenos">331</span></a> <span class="s2">"MAP"</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_map</span><span class="p">(),</span> -</span><span id="DuckDB-332"><a href="#DuckDB-332"><span class="linenos">332</span></a> <span class="p">}</span> -</span><span id="DuckDB-333"><a href="#DuckDB-333"><span class="linenos">333</span></a> -</span><span id="DuckDB-334"><a href="#DuckDB-334"><span class="linenos">334</span></a> <span class="n">TABLE_ALIAS_TOKENS</span> <span class="o">=</span> <span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">TABLE_ALIAS_TOKENS</span> <span class="o">-</span> <span class="p">{</span> -</span><span id="DuckDB-335"><a href="#DuckDB-335"><span class="linenos">335</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">SEMI</span><span class="p">,</span> -</span><span id="DuckDB-336"><a href="#DuckDB-336"><span class="linenos">336</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">ANTI</span><span class="p">,</span> -</span><span id="DuckDB-337"><a href="#DuckDB-337"><span class="linenos">337</span></a> <span class="p">}</span> -</span><span id="DuckDB-338"><a href="#DuckDB-338"><span class="linenos">338</span></a> -</span><span id="DuckDB-339"><a href="#DuckDB-339"><span class="linenos">339</span></a> <span class="n">PLACEHOLDER_PARSERS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="DuckDB-340"><a href="#DuckDB-340"><span class="linenos">340</span></a> <span class="o">**</span><span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">PLACEHOLDER_PARSERS</span><span class="p">,</span> -</span><span id="DuckDB-341"><a href="#DuckDB-341"><span class="linenos">341</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">PARAMETER</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">:</span> <span class="p">(</span> -</span><span id="DuckDB-342"><a href="#DuckDB-342"><span class="linenos">342</span></a> <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">Placeholder</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">_prev</span><span class="o">.</span><span class="n">text</span><span class="p">)</span> -</span><span id="DuckDB-343"><a href="#DuckDB-343"><span class="linenos">343</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">NUMBER</span><span class="p">)</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_set</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">ID_VAR_TOKENS</span><span class="p">)</span> -</span><span id="DuckDB-344"><a href="#DuckDB-344"><span class="linenos">344</span></a> <span class="k">else</span> <span class="kc">None</span> -</span><span id="DuckDB-345"><a href="#DuckDB-345"><span class="linenos">345</span></a> <span class="p">),</span> -</span><span id="DuckDB-346"><a href="#DuckDB-346"><span class="linenos">346</span></a> <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="n">TYPE_CONVERTERS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="DuckDB-349"><a href="#DuckDB-349"><span class="linenos">349</span></a> <span class="c1"># https://duckdb.org/docs/sql/data_types/numeric</span> -</span><span id="DuckDB-350"><a href="#DuckDB-350"><span class="linenos">350</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">DECIMAL</span><span class="p">:</span> <span class="n">build_default_decimal_type</span><span class="p">(</span><span class="n">precision</span><span class="o">=</span><span class="mi">18</span><span class="p">,</span> <span class="n">scale</span><span class="o">=</span><span class="mi">3</span><span class="p">),</span> -</span><span id="DuckDB-351"><a href="#DuckDB-351"><span class="linenos">351</span></a> <span class="c1"># https://duckdb.org/docs/sql/data_types/text</span> -</span><span id="DuckDB-352"><a href="#DuckDB-352"><span class="linenos">352</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">TEXT</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">dtype</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">build</span><span class="p">(</span><span class="s2">"TEXT"</span><span class="p">),</span> -</span><span id="DuckDB-353"><a href="#DuckDB-353"><span class="linenos">353</span></a> <span class="p">}</span> -</span><span id="DuckDB-354"><a href="#DuckDB-354"><span class="linenos">354</span></a> -</span><span id="DuckDB-355"><a href="#DuckDB-355"><span class="linenos">355</span></a> <span class="k">def</span> <span class="nf">_parse_table_sample</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">as_modifier</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">TableSample</span><span class="p">]:</span> -</span><span id="DuckDB-356"><a href="#DuckDB-356"><span class="linenos">356</span></a> <span class="c1"># https://duckdb.org/docs/sql/samples.html</span> -</span><span id="DuckDB-357"><a href="#DuckDB-357"><span class="linenos">357</span></a> <span class="n">sample</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_parse_table_sample</span><span class="p">(</span><span class="n">as_modifier</span><span class="o">=</span><span class="n">as_modifier</span><span class="p">)</span> -</span><span id="DuckDB-358"><a href="#DuckDB-358"><span class="linenos">358</span></a> <span class="k">if</span> <span class="n">sample</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">sample</span><span 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-359"><a href="#DuckDB-359"><span class="linenos">359</span></a> <span class="k">if</span> <span class="n">sample</span><span 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-360"><a href="#DuckDB-360"><span class="linenos">360</span></a> <span class="n">sample</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-361"><a href="#DuckDB-361"><span class="linenos">361</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="DuckDB-362"><a href="#DuckDB-362"><span class="linenos">362</span></a> <span class="n">sample</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">"SYSTEM"</span><span class="p">))</span> -</span><span id="DuckDB-363"><a href="#DuckDB-363"><span class="linenos">363</span></a> -</span><span id="DuckDB-364"><a href="#DuckDB-364"><span class="linenos">364</span></a> <span class="k">return</span> <span class="n">sample</span> -</span><span id="DuckDB-365"><a href="#DuckDB-365"><span class="linenos">365</span></a> -</span><span id="DuckDB-366"><a href="#DuckDB-366"><span class="linenos">366</span></a> <span class="k">def</span> <span class="nf">_parse_bracket</span><span class="p">(</span> -</span><span id="DuckDB-367"><a href="#DuckDB-367"><span class="linenos">367</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">this</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="DuckDB-368"><a href="#DuckDB-368"><span class="linenos">368</span></a> <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> -</span><span id="DuckDB-369"><a href="#DuckDB-369"><span class="linenos">369</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">_parse_bracket</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> -</span><span id="DuckDB-370"><a href="#DuckDB-370"><span class="linenos">370</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">bracket</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Bracket</span><span class="p">):</span> -</span><span id="DuckDB-371"><a href="#DuckDB-371"><span class="linenos">371</span></a> <span class="n">bracket</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"returns_list_for_maps"</span><span class="p">,</span> <span class="kc">True</span><span class="p">)</span> -</span><span id="DuckDB-372"><a href="#DuckDB-372"><span class="linenos">372</span></a> -</span><span id="DuckDB-373"><a href="#DuckDB-373"><span class="linenos">373</span></a> <span class="k">return</span> <span class="n">bracket</span> -</span><span id="DuckDB-374"><a href="#DuckDB-374"><span class="linenos">374</span></a> -</span><span id="DuckDB-375"><a href="#DuckDB-375"><span class="linenos">375</span></a> <span class="k">def</span> <span class="nf">_parse_map</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">ToMap</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Map</span><span class="p">:</span> -</span><span id="DuckDB-376"><a href="#DuckDB-376"><span class="linenos">376</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-377"><a href="#DuckDB-377"><span class="linenos">377</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-265"><a href="#DuckDB-265"><span class="linenos">265</span></a> <span class="k">class</span> <span class="nc">Parser</span><span class="p">(</span><span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="p">):</span> +</span><span id="DuckDB-266"><a href="#DuckDB-266"><span class="linenos">266</span></a> <span class="n">BITWISE</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="DuckDB-267"><a href="#DuckDB-267"><span class="linenos">267</span></a> <span class="o">**</span><span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">BITWISE</span><span class="p">,</span> +</span><span id="DuckDB-268"><a href="#DuckDB-268"><span class="linenos">268</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">TILDA</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpLike</span><span class="p">,</span> +</span><span id="DuckDB-269"><a href="#DuckDB-269"><span class="linenos">269</span></a> <span class="p">}</span> +</span><span id="DuckDB-270"><a href="#DuckDB-270"><span class="linenos">270</span></a> +</span><span id="DuckDB-271"><a href="#DuckDB-271"><span class="linenos">271</span></a> <span class="n">FUNCTIONS_WITH_ALIASED_ARGS</span> <span class="o">=</span> <span class="p">{</span><span class="o">*</span><span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">FUNCTIONS_WITH_ALIASED_ARGS</span><span class="p">,</span> <span class="s2">"STRUCT_PACK"</span><span class="p">}</span> +</span><span id="DuckDB-272"><a href="#DuckDB-272"><span class="linenos">272</span></a> +</span><span id="DuckDB-273"><a href="#DuckDB-273"><span class="linenos">273</span></a> <span class="n">FUNCTIONS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="DuckDB-274"><a href="#DuckDB-274"><span class="linenos">274</span></a> <span class="o">**</span><span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">FUNCTIONS</span><span class="p">,</span> +</span><span id="DuckDB-275"><a href="#DuckDB-275"><span class="linenos">275</span></a> <span class="s2">"ARRAY_REVERSE_SORT"</span><span class="p">:</span> <span class="n">_build_sort_array_desc</span><span class="p">,</span> +</span><span id="DuckDB-276"><a href="#DuckDB-276"><span class="linenos">276</span></a> <span class="s2">"ARRAY_SORT"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SortArray</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="DuckDB-277"><a href="#DuckDB-277"><span class="linenos">277</span></a> <span class="s2">"DATEDIFF"</span><span class="p">:</span> <span class="n">_build_date_diff</span><span class="p">,</span> +</span><span id="DuckDB-278"><a href="#DuckDB-278"><span class="linenos">278</span></a> <span class="s2">"DATE_DIFF"</span><span class="p">:</span> <span class="n">_build_date_diff</span><span class="p">,</span> +</span><span id="DuckDB-279"><a href="#DuckDB-279"><span class="linenos">279</span></a> <span class="s2">"DATE_TRUNC"</span><span class="p">:</span> <span class="n">date_trunc_to_time</span><span class="p">,</span> +</span><span id="DuckDB-280"><a href="#DuckDB-280"><span class="linenos">280</span></a> <span class="s2">"DATETRUNC"</span><span class="p">:</span> <span class="n">date_trunc_to_time</span><span class="p">,</span> +</span><span id="DuckDB-281"><a href="#DuckDB-281"><span class="linenos">281</span></a> <span class="s2">"DECODE"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Decode</span><span class="p">(</span> +</span><span id="DuckDB-282"><a href="#DuckDB-282"><span class="linenos">282</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">charset</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">string</span><span class="p">(</span><span class="s2">"utf-8"</span><span class="p">)</span> +</span><span id="DuckDB-283"><a href="#DuckDB-283"><span class="linenos">283</span></a> <span class="p">),</span> +</span><span id="DuckDB-284"><a href="#DuckDB-284"><span class="linenos">284</span></a> <span class="s2">"ENCODE"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Encode</span><span class="p">(</span> +</span><span id="DuckDB-285"><a href="#DuckDB-285"><span class="linenos">285</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">charset</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">string</span><span class="p">(</span><span class="s2">"utf-8"</span><span class="p">)</span> +</span><span id="DuckDB-286"><a href="#DuckDB-286"><span class="linenos">286</span></a> <span class="p">),</span> +</span><span id="DuckDB-287"><a href="#DuckDB-287"><span class="linenos">287</span></a> <span class="s2">"EPOCH"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TimeToUnix</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="DuckDB-288"><a href="#DuckDB-288"><span class="linenos">288</span></a> <span class="s2">"EPOCH_MS"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToTime</span><span class="p">(</span> +</span><span id="DuckDB-289"><a href="#DuckDB-289"><span class="linenos">289</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">scale</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">UnixToTime</span><span class="o">.</span><span class="n">MILLIS</span> +</span><span id="DuckDB-290"><a href="#DuckDB-290"><span class="linenos">290</span></a> <span class="p">),</span> +</span><span id="DuckDB-291"><a href="#DuckDB-291"><span class="linenos">291</span></a> <span class="s2">"JSON"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ParseJSON</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="DuckDB-292"><a href="#DuckDB-292"><span class="linenos">292</span></a> <span class="s2">"JSON_EXTRACT_PATH"</span><span class="p">:</span> <span class="n">parser</span><span class="o">.</span><span class="n">build_extract_json_with_path</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">JSONExtract</span><span class="p">),</span> +</span><span id="DuckDB-293"><a href="#DuckDB-293"><span class="linenos">293</span></a> <span class="s2">"JSON_EXTRACT_STRING"</span><span class="p">:</span> <span class="n">parser</span><span class="o">.</span><span class="n">build_extract_json_with_path</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">JSONExtractScalar</span><span class="p">),</span> +</span><span id="DuckDB-294"><a href="#DuckDB-294"><span class="linenos">294</span></a> <span class="s2">"LIST_HAS"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayContains</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="DuckDB-295"><a href="#DuckDB-295"><span class="linenos">295</span></a> <span class="s2">"LIST_REVERSE_SORT"</span><span class="p">:</span> <span class="n">_build_sort_array_desc</span><span class="p">,</span> +</span><span id="DuckDB-296"><a href="#DuckDB-296"><span class="linenos">296</span></a> <span class="s2">"LIST_SORT"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SortArray</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="DuckDB-297"><a href="#DuckDB-297"><span class="linenos">297</span></a> <span class="s2">"LIST_VALUE"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Array</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="DuckDB-298"><a href="#DuckDB-298"><span class="linenos">298</span></a> <span class="s2">"MAKE_TIME"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TimeFromParts</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="DuckDB-299"><a href="#DuckDB-299"><span class="linenos">299</span></a> <span class="s2">"MAKE_TIMESTAMP"</span><span class="p">:</span> <span class="n">_build_make_timestamp</span><span class="p">,</span> +</span><span id="DuckDB-300"><a href="#DuckDB-300"><span class="linenos">300</span></a> <span class="s2">"MEDIAN"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">PercentileCont</span><span class="p">(</span> +</span><span id="DuckDB-301"><a href="#DuckDB-301"><span class="linenos">301</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">number</span><span class="p">(</span><span class="mf">0.5</span><span class="p">)</span> +</span><span id="DuckDB-302"><a href="#DuckDB-302"><span class="linenos">302</span></a> <span class="p">),</span> +</span><span id="DuckDB-303"><a href="#DuckDB-303"><span class="linenos">303</span></a> <span class="s2">"QUANTILE_CONT"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">PercentileCont</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="DuckDB-304"><a href="#DuckDB-304"><span class="linenos">304</span></a> <span class="s2">"QUANTILE_DISC"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">PercentileDisc</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="DuckDB-305"><a href="#DuckDB-305"><span class="linenos">305</span></a> <span class="s2">"REGEXP_EXTRACT"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpExtract</span><span class="p">(</span> +</span><span id="DuckDB-306"><a href="#DuckDB-306"><span class="linenos">306</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">expression</span><span class="o">=</span><span class="n">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 class="n">group</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">2</span><span class="p">)</span> +</span><span id="DuckDB-307"><a href="#DuckDB-307"><span class="linenos">307</span></a> <span class="p">),</span> +</span><span id="DuckDB-308"><a href="#DuckDB-308"><span class="linenos">308</span></a> <span class="s2">"REGEXP_MATCHES"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpLike</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="DuckDB-309"><a href="#DuckDB-309"><span class="linenos">309</span></a> <span class="s2">"REGEXP_REPLACE"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpReplace</span><span class="p">(</span> +</span><span id="DuckDB-310"><a href="#DuckDB-310"><span class="linenos">310</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> +</span><span id="DuckDB-311"><a href="#DuckDB-311"><span class="linenos">311</span></a> <span class="n">expression</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-312"><a href="#DuckDB-312"><span class="linenos">312</span></a> <span class="n">replacement</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">2</span><span class="p">),</span> +</span><span id="DuckDB-313"><a href="#DuckDB-313"><span class="linenos">313</span></a> <span class="n">modifiers</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">3</span><span class="p">),</span> +</span><span id="DuckDB-314"><a href="#DuckDB-314"><span class="linenos">314</span></a> <span class="p">),</span> +</span><span id="DuckDB-315"><a href="#DuckDB-315"><span class="linenos">315</span></a> <span class="s2">"STRFTIME"</span><span class="p">:</span> <span class="n">build_formatted_time</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">TimeToStr</span><span class="p">,</span> <span class="s2">"duckdb"</span><span class="p">),</span> +</span><span id="DuckDB-316"><a href="#DuckDB-316"><span class="linenos">316</span></a> <span class="s2">"STRING_SPLIT"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Split</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="DuckDB-317"><a href="#DuckDB-317"><span class="linenos">317</span></a> <span class="s2">"STRING_SPLIT_REGEX"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpSplit</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="DuckDB-318"><a href="#DuckDB-318"><span class="linenos">318</span></a> <span class="s2">"STRING_TO_ARRAY"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Split</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="DuckDB-319"><a href="#DuckDB-319"><span class="linenos">319</span></a> <span class="s2">"STRPTIME"</span><span class="p">:</span> <span class="n">build_formatted_time</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">StrToTime</span><span class="p">,</span> <span class="s2">"duckdb"</span><span class="p">),</span> +</span><span id="DuckDB-320"><a href="#DuckDB-320"><span class="linenos">320</span></a> <span class="s2">"STRUCT_PACK"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Struct</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="DuckDB-321"><a href="#DuckDB-321"><span class="linenos">321</span></a> <span class="s2">"STR_SPLIT"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Split</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="DuckDB-322"><a href="#DuckDB-322"><span class="linenos">322</span></a> <span class="s2">"STR_SPLIT_REGEX"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpSplit</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="DuckDB-323"><a href="#DuckDB-323"><span class="linenos">323</span></a> <span class="s2">"TO_TIMESTAMP"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToTime</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="DuckDB-324"><a href="#DuckDB-324"><span class="linenos">324</span></a> <span class="s2">"UNNEST"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Explode</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="DuckDB-325"><a href="#DuckDB-325"><span class="linenos">325</span></a> <span class="s2">"XOR"</span><span class="p">:</span> <span class="n">binary_from_function</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">BitwiseXor</span><span class="p">),</span> +</span><span id="DuckDB-326"><a href="#DuckDB-326"><span class="linenos">326</span></a> <span class="s2">"GENERATE_SERIES"</span><span class="p">:</span> <span class="n">_build_generate_series</span><span class="p">(),</span> +</span><span id="DuckDB-327"><a href="#DuckDB-327"><span class="linenos">327</span></a> <span class="s2">"RANGE"</span><span class="p">:</span> <span class="n">_build_generate_series</span><span class="p">(</span><span class="n">end_exclusive</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> +</span><span id="DuckDB-328"><a href="#DuckDB-328"><span class="linenos">328</span></a> <span class="p">}</span> +</span><span id="DuckDB-329"><a href="#DuckDB-329"><span class="linenos">329</span></a> +</span><span id="DuckDB-330"><a href="#DuckDB-330"><span class="linenos">330</span></a> <span class="n">FUNCTIONS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">"DATE_SUB"</span><span class="p">)</span> +</span><span id="DuckDB-331"><a href="#DuckDB-331"><span class="linenos">331</span></a> +</span><span id="DuckDB-332"><a href="#DuckDB-332"><span class="linenos">332</span></a> <span class="n">FUNCTION_PARSERS</span> <span class="o">=</span> <span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">FUNCTION_PARSERS</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> +</span><span id="DuckDB-333"><a href="#DuckDB-333"><span class="linenos">333</span></a> <span class="n">FUNCTION_PARSERS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">"DECODE"</span><span class="p">)</span> +</span><span id="DuckDB-334"><a href="#DuckDB-334"><span class="linenos">334</span></a> +</span><span id="DuckDB-335"><a href="#DuckDB-335"><span class="linenos">335</span></a> <span class="n">NO_PAREN_FUNCTION_PARSERS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="DuckDB-336"><a href="#DuckDB-336"><span class="linenos">336</span></a> <span class="o">**</span><span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">NO_PAREN_FUNCTION_PARSERS</span><span class="p">,</span> +</span><span id="DuckDB-337"><a href="#DuckDB-337"><span class="linenos">337</span></a> <span class="s2">"MAP"</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_map</span><span class="p">(),</span> +</span><span id="DuckDB-338"><a href="#DuckDB-338"><span class="linenos">338</span></a> <span class="p">}</span> +</span><span id="DuckDB-339"><a href="#DuckDB-339"><span class="linenos">339</span></a> +</span><span id="DuckDB-340"><a href="#DuckDB-340"><span class="linenos">340</span></a> <span class="n">TABLE_ALIAS_TOKENS</span> <span class="o">=</span> <span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">TABLE_ALIAS_TOKENS</span> <span class="o">-</span> <span class="p">{</span> +</span><span id="DuckDB-341"><a href="#DuckDB-341"><span class="linenos">341</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">SEMI</span><span class="p">,</span> +</span><span id="DuckDB-342"><a href="#DuckDB-342"><span class="linenos">342</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">ANTI</span><span class="p">,</span> +</span><span id="DuckDB-343"><a href="#DuckDB-343"><span class="linenos">343</span></a> <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">PLACEHOLDER_PARSERS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="DuckDB-346"><a href="#DuckDB-346"><span class="linenos">346</span></a> <span class="o">**</span><span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">PLACEHOLDER_PARSERS</span><span class="p">,</span> +</span><span id="DuckDB-347"><a href="#DuckDB-347"><span class="linenos">347</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">PARAMETER</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">:</span> <span class="p">(</span> +</span><span id="DuckDB-348"><a href="#DuckDB-348"><span class="linenos">348</span></a> <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">Placeholder</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">_prev</span><span class="o">.</span><span class="n">text</span><span class="p">)</span> +</span><span id="DuckDB-349"><a href="#DuckDB-349"><span class="linenos">349</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">NUMBER</span><span class="p">)</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_set</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">ID_VAR_TOKENS</span><span class="p">)</span> +</span><span id="DuckDB-350"><a href="#DuckDB-350"><span class="linenos">350</span></a> <span class="k">else</span> <span class="kc">None</span> +</span><span id="DuckDB-351"><a href="#DuckDB-351"><span class="linenos">351</span></a> <span class="p">),</span> +</span><span id="DuckDB-352"><a href="#DuckDB-352"><span class="linenos">352</span></a> <span class="p">}</span> +</span><span id="DuckDB-353"><a href="#DuckDB-353"><span class="linenos">353</span></a> +</span><span id="DuckDB-354"><a href="#DuckDB-354"><span class="linenos">354</span></a> <span class="n">TYPE_CONVERTERS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="DuckDB-355"><a href="#DuckDB-355"><span class="linenos">355</span></a> <span class="c1"># https://duckdb.org/docs/sql/data_types/numeric</span> +</span><span id="DuckDB-356"><a href="#DuckDB-356"><span class="linenos">356</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">DECIMAL</span><span class="p">:</span> <span class="n">build_default_decimal_type</span><span class="p">(</span><span class="n">precision</span><span class="o">=</span><span class="mi">18</span><span class="p">,</span> <span class="n">scale</span><span class="o">=</span><span class="mi">3</span><span class="p">),</span> +</span><span id="DuckDB-357"><a href="#DuckDB-357"><span class="linenos">357</span></a> <span class="c1"># https://duckdb.org/docs/sql/data_types/text</span> +</span><span id="DuckDB-358"><a href="#DuckDB-358"><span class="linenos">358</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">TEXT</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">dtype</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">build</span><span class="p">(</span><span class="s2">"TEXT"</span><span class="p">),</span> +</span><span id="DuckDB-359"><a href="#DuckDB-359"><span class="linenos">359</span></a> <span class="p">}</span> +</span><span id="DuckDB-360"><a href="#DuckDB-360"><span class="linenos">360</span></a> +</span><span id="DuckDB-361"><a href="#DuckDB-361"><span class="linenos">361</span></a> <span class="k">def</span> <span class="nf">_parse_table_sample</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">as_modifier</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">TableSample</span><span class="p">]:</span> +</span><span id="DuckDB-362"><a href="#DuckDB-362"><span class="linenos">362</span></a> <span class="c1"># https://duckdb.org/docs/sql/samples.html</span> +</span><span id="DuckDB-363"><a href="#DuckDB-363"><span class="linenos">363</span></a> <span class="n">sample</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_parse_table_sample</span><span class="p">(</span><span class="n">as_modifier</span><span class="o">=</span><span class="n">as_modifier</span><span class="p">)</span> +</span><span id="DuckDB-364"><a href="#DuckDB-364"><span class="linenos">364</span></a> <span class="k">if</span> <span class="n">sample</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">sample</span><span 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-365"><a href="#DuckDB-365"><span class="linenos">365</span></a> <span class="k">if</span> <span class="n">sample</span><span 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-366"><a href="#DuckDB-366"><span class="linenos">366</span></a> <span class="n">sample</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-367"><a href="#DuckDB-367"><span class="linenos">367</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="DuckDB-368"><a href="#DuckDB-368"><span class="linenos">368</span></a> <span class="n">sample</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">"SYSTEM"</span><span class="p">))</span> +</span><span id="DuckDB-369"><a href="#DuckDB-369"><span class="linenos">369</span></a> +</span><span id="DuckDB-370"><a href="#DuckDB-370"><span class="linenos">370</span></a> <span class="k">return</span> <span class="n">sample</span> +</span><span id="DuckDB-371"><a href="#DuckDB-371"><span class="linenos">371</span></a> +</span><span id="DuckDB-372"><a href="#DuckDB-372"><span class="linenos">372</span></a> <span class="k">def</span> <span class="nf">_parse_bracket</span><span class="p">(</span> +</span><span id="DuckDB-373"><a href="#DuckDB-373"><span class="linenos">373</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">this</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="DuckDB-374"><a href="#DuckDB-374"><span class="linenos">374</span></a> <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> +</span><span id="DuckDB-375"><a href="#DuckDB-375"><span class="linenos">375</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">_parse_bracket</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> +</span><span id="DuckDB-376"><a href="#DuckDB-376"><span class="linenos">376</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">bracket</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Bracket</span><span class="p">):</span> +</span><span id="DuckDB-377"><a href="#DuckDB-377"><span class="linenos">377</span></a> <span class="n">bracket</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"returns_list_for_maps"</span><span class="p">,</span> <span class="kc">True</span><span class="p">)</span> </span><span id="DuckDB-378"><a href="#DuckDB-378"><span class="linenos">378</span></a> -</span><span id="DuckDB-379"><a href="#DuckDB-379"><span class="linenos">379</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-380"><a href="#DuckDB-380"><span class="linenos">380</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-381"><a href="#DuckDB-381"><span class="linenos">381</span></a> -</span><span id="DuckDB-382"><a href="#DuckDB-382"><span class="linenos">382</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> -</span><span id="DuckDB-383"><a href="#DuckDB-383"><span class="linenos">383</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_field_def</span><span class="p">()</span> +</span><span id="DuckDB-379"><a href="#DuckDB-379"><span class="linenos">379</span></a> <span class="k">return</span> <span class="n">bracket</span> +</span><span id="DuckDB-380"><a href="#DuckDB-380"><span class="linenos">380</span></a> +</span><span id="DuckDB-381"><a href="#DuckDB-381"><span class="linenos">381</span></a> <span class="k">def</span> <span class="nf">_parse_map</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">ToMap</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Map</span><span class="p">:</span> +</span><span id="DuckDB-382"><a href="#DuckDB-382"><span class="linenos">382</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-383"><a href="#DuckDB-383"><span class="linenos">383</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-384"><a href="#DuckDB-384"><span class="linenos">384</span></a> -</span><span id="DuckDB-385"><a href="#DuckDB-385"><span class="linenos">385</span></a> <span class="k">def</span> <span class="nf">_pivot_column_names</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">aggregations</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">])</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> -</span><span id="DuckDB-386"><a href="#DuckDB-386"><span class="linenos">386</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">aggregations</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> -</span><span id="DuckDB-387"><a href="#DuckDB-387"><span class="linenos">387</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_pivot_column_names</span><span class="p">(</span><span class="n">aggregations</span><span class="p">)</span> -</span><span id="DuckDB-388"><a href="#DuckDB-388"><span class="linenos">388</span></a> <span class="k">return</span> <span class="n">pivot_column_names</span><span class="p">(</span><span class="n">aggregations</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="s2">"duckdb"</span><span class="p">)</span> -</span><span id="DuckDB-389"><a href="#DuckDB-389"><span class="linenos">389</span></a> -</span><span id="DuckDB-390"><a href="#DuckDB-390"><span class="linenos">390</span></a> <span class="k">class</span> <span class="nc">Generator</span><span class="p">(</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="p">):</span> -</span><span id="DuckDB-391"><a href="#DuckDB-391"><span class="linenos">391</span></a> <span class="n">PARAMETER_TOKEN</span> <span class="o">=</span> <span class="s2">"$"</span> -</span><span id="DuckDB-392"><a href="#DuckDB-392"><span class="linenos">392</span></a> <span class="n">NAMED_PLACEHOLDER_TOKEN</span> <span class="o">=</span> <span class="s2">"$"</span> -</span><span id="DuckDB-393"><a href="#DuckDB-393"><span class="linenos">393</span></a> <span class="n">JOIN_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="DuckDB-394"><a href="#DuckDB-394"><span class="linenos">394</span></a> <span class="n">TABLE_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="DuckDB-395"><a href="#DuckDB-395"><span class="linenos">395</span></a> <span class="n">QUERY_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="DuckDB-396"><a href="#DuckDB-396"><span class="linenos">396</span></a> <span class="n">LIMIT_FETCH</span> <span class="o">=</span> <span class="s2">"LIMIT"</span> -</span><span id="DuckDB-397"><a href="#DuckDB-397"><span class="linenos">397</span></a> <span class="n">STRUCT_DELIMITER</span> <span class="o">=</span> <span class="p">(</span><span class="s2">"("</span><span class="p">,</span> <span class="s2">")"</span><span class="p">)</span> -</span><span id="DuckDB-398"><a href="#DuckDB-398"><span class="linenos">398</span></a> <span class="n">RENAME_TABLE_WITH_DB</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="DuckDB-399"><a href="#DuckDB-399"><span class="linenos">399</span></a> <span class="n">NVL2_SUPPORTED</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="DuckDB-400"><a href="#DuckDB-400"><span class="linenos">400</span></a> <span class="n">SEMI_ANTI_JOIN_WITH_SIDE</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="DuckDB-401"><a href="#DuckDB-401"><span class="linenos">401</span></a> <span class="n">TABLESAMPLE_KEYWORDS</span> <span class="o">=</span> <span class="s2">"USING SAMPLE"</span> -</span><span id="DuckDB-402"><a href="#DuckDB-402"><span class="linenos">402</span></a> <span class="n">TABLESAMPLE_SEED_KEYWORD</span> <span class="o">=</span> <span class="s2">"REPEATABLE"</span> -</span><span id="DuckDB-403"><a href="#DuckDB-403"><span class="linenos">403</span></a> <span class="n">LAST_DAY_SUPPORTS_DATE_PART</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="DuckDB-404"><a href="#DuckDB-404"><span class="linenos">404</span></a> <span class="n">JSON_KEY_VALUE_PAIR_SEP</span> <span class="o">=</span> <span class="s2">","</span> -</span><span id="DuckDB-405"><a href="#DuckDB-405"><span class="linenos">405</span></a> <span class="n">IGNORE_NULLS_IN_FUNC</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="DuckDB-406"><a href="#DuckDB-406"><span class="linenos">406</span></a> <span class="n">JSON_PATH_BRACKETED_KEY_SUPPORTED</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="DuckDB-407"><a href="#DuckDB-407"><span class="linenos">407</span></a> <span class="n">SUPPORTS_CREATE_TABLE_LIKE</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="DuckDB-408"><a href="#DuckDB-408"><span class="linenos">408</span></a> <span class="n">MULTI_ARG_DISTINCT</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="DuckDB-409"><a href="#DuckDB-409"><span class="linenos">409</span></a> <span class="n">CAN_IMPLEMENT_ARRAY_ANY</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="DuckDB-410"><a href="#DuckDB-410"><span class="linenos">410</span></a> <span class="n">SUPPORTS_TO_NUMBER</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="DuckDB-411"><a href="#DuckDB-411"><span class="linenos">411</span></a> <span class="n">COPY_HAS_INTO_KEYWORD</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="DuckDB-412"><a href="#DuckDB-412"><span class="linenos">412</span></a> <span class="n">STAR_EXCEPT</span> <span class="o">=</span> <span class="s2">"EXCLUDE"</span> -</span><span id="DuckDB-413"><a href="#DuckDB-413"><span class="linenos">413</span></a> <span class="n">PAD_FILL_PATTERN_IS_REQUIRED</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="DuckDB-414"><a href="#DuckDB-414"><span class="linenos">414</span></a> -</span><span id="DuckDB-415"><a href="#DuckDB-415"><span class="linenos">415</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="DuckDB-416"><a href="#DuckDB-416"><span class="linenos">416</span></a> <span class="o">**</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">TRANSFORMS</span><span class="p">,</span> -</span><span id="DuckDB-417"><a href="#DuckDB-417"><span class="linenos">417</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxDistinct</span><span class="p">:</span> <span class="n">approx_count_distinct_sql</span><span class="p">,</span> -</span><span id="DuckDB-418"><a href="#DuckDB-418"><span class="linenos">418</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Array</span><span class="p">:</span> <span class="n">inline_array_unless_query</span><span class="p">,</span> -</span><span id="DuckDB-419"><a href="#DuckDB-419"><span class="linenos">419</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayContainsAll</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"ARRAY_HAS_ALL"</span><span class="p">),</span> -</span><span id="DuckDB-420"><a href="#DuckDB-420"><span class="linenos">420</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayFilter</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"LIST_FILTER"</span><span class="p">),</span> -</span><span id="DuckDB-421"><a href="#DuckDB-421"><span class="linenos">421</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArraySize</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"ARRAY_LENGTH"</span><span class="p">),</span> -</span><span id="DuckDB-422"><a href="#DuckDB-422"><span class="linenos">422</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArgMax</span><span class="p">:</span> <span class="n">arg_max_or_min_no_count</span><span class="p">(</span><span class="s2">"ARG_MAX"</span><span class="p">),</span> -</span><span id="DuckDB-423"><a href="#DuckDB-423"><span class="linenos">423</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArgMin</span><span class="p">:</span> <span class="n">arg_max_or_min_no_count</span><span class="p">(</span><span class="s2">"ARG_MIN"</span><span class="p">),</span> -</span><span id="DuckDB-424"><a href="#DuckDB-424"><span class="linenos">424</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArraySort</span><span class="p">:</span> <span class="n">_array_sort_sql</span><span class="p">,</span> -</span><span id="DuckDB-425"><a href="#DuckDB-425"><span class="linenos">425</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArraySum</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"LIST_SUM"</span><span class="p">),</span> -</span><span id="DuckDB-426"><a href="#DuckDB-426"><span class="linenos">426</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseXor</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"XOR"</span><span class="p">),</span> -</span><span id="DuckDB-427"><a href="#DuckDB-427"><span class="linenos">427</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CommentColumnConstraint</span><span class="p">:</span> <span class="n">no_comment_column_constraint_sql</span><span class="p">,</span> -</span><span id="DuckDB-428"><a href="#DuckDB-428"><span class="linenos">428</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CurrentDate</span><span class="p">:</span> <span class="k">lambda</span> <span class="o">*</span><span class="n">_</span><span class="p">:</span> <span class="s2">"CURRENT_DATE"</span><span class="p">,</span> -</span><span id="DuckDB-429"><a href="#DuckDB-429"><span class="linenos">429</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CurrentTime</span><span class="p">:</span> <span class="k">lambda</span> <span class="o">*</span><span class="n">_</span><span class="p">:</span> <span class="s2">"CURRENT_TIME"</span><span class="p">,</span> -</span><span id="DuckDB-430"><a href="#DuckDB-430"><span class="linenos">430</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CurrentTimestamp</span><span class="p">:</span> <span class="k">lambda</span> <span class="o">*</span><span class="n">_</span><span class="p">:</span> <span class="s2">"CURRENT_TIMESTAMP"</span><span class="p">,</span> -</span><span id="DuckDB-431"><a href="#DuckDB-431"><span class="linenos">431</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DayOfMonth</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"DAYOFMONTH"</span><span class="p">),</span> -</span><span id="DuckDB-432"><a href="#DuckDB-432"><span class="linenos">432</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DayOfWeek</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"DAYOFWEEK"</span><span class="p">),</span> -</span><span id="DuckDB-433"><a href="#DuckDB-433"><span class="linenos">433</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DayOfYear</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"DAYOFYEAR"</span><span class="p">),</span> -</span><span id="DuckDB-434"><a href="#DuckDB-434"><span class="linenos">434</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">:</span> <span class="n">_datatype_sql</span><span class="p">,</span> -</span><span id="DuckDB-435"><a href="#DuckDB-435"><span class="linenos">435</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Date</span><span class="p">:</span> <span class="n">_date_sql</span><span class="p">,</span> -</span><span id="DuckDB-436"><a href="#DuckDB-436"><span class="linenos">436</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</span><span class="p">:</span> <span class="n">_date_delta_sql</span><span class="p">,</span> -</span><span id="DuckDB-437"><a href="#DuckDB-437"><span class="linenos">437</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateFromParts</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"MAKE_DATE"</span><span class="p">),</span> -</span><span id="DuckDB-438"><a href="#DuckDB-438"><span class="linenos">438</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateSub</span><span class="p">:</span> <span class="n">_date_delta_sql</span><span class="p">,</span> -</span><span id="DuckDB-439"><a href="#DuckDB-439"><span class="linenos">439</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateDiff</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="DuckDB-440"><a href="#DuckDB-440"><span class="linenos">440</span></a> <span class="s2">"DATE_DIFF"</span><span class="p">,</span> <span class="sa">f</span><span class="s2">"'</span><span class="si">{</span><span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'unit'</span><span class="p">)</span><span class="w"> </span><span class="ow">or</span><span class="w"> </span><span class="s1">'DAY'</span><span class="si">}</span><span class="s2">'"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span> -</span><span id="DuckDB-441"><a href="#DuckDB-441"><span class="linenos">441</span></a> <span class="p">),</span> -</span><span id="DuckDB-442"><a href="#DuckDB-442"><span class="linenos">442</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateStrToDate</span><span class="p">:</span> <span class="n">datestrtodate_sql</span><span class="p">,</span> -</span><span id="DuckDB-443"><a href="#DuckDB-443"><span class="linenos">443</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Datetime</span><span class="p">:</span> <span class="n">no_datetime_sql</span><span class="p">,</span> -</span><span id="DuckDB-444"><a href="#DuckDB-444"><span class="linenos">444</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DatetimeSub</span><span class="p">:</span> <span class="n">_date_delta_sql</span><span class="p">,</span> -</span><span id="DuckDB-445"><a href="#DuckDB-445"><span class="linenos">445</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DatetimeAdd</span><span class="p">:</span> <span class="n">_date_delta_sql</span><span class="p">,</span> -</span><span id="DuckDB-446"><a href="#DuckDB-446"><span class="linenos">446</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateToDi</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> -</span><span id="DuckDB-447"><a href="#DuckDB-447"><span class="linenos">447</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"CAST(STRFTIME(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="n">DuckDB</span><span class="o">.</span><span class="n">DATEINT_FORMAT</span><span class="si">}</span><span class="s2">) AS INT)"</span><span class="p">,</span> -</span><span id="DuckDB-448"><a href="#DuckDB-448"><span class="linenos">448</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Decode</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="n">encode_decode_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">,</span> <span class="s2">"DECODE"</span><span class="p">,</span> <span class="n">replace</span><span class="o">=</span><span class="kc">False</span><span class="p">),</span> -</span><span id="DuckDB-449"><a href="#DuckDB-449"><span class="linenos">449</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DiToDate</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> -</span><span id="DuckDB-450"><a href="#DuckDB-450"><span class="linenos">450</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"CAST(STRPTIME(CAST(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS TEXT), </span><span class="si">{</span><span class="n">DuckDB</span><span class="o">.</span><span class="n">DATEINT_FORMAT</span><span class="si">}</span><span class="s2">) AS DATE)"</span><span class="p">,</span> -</span><span id="DuckDB-451"><a href="#DuckDB-451"><span class="linenos">451</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Encode</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="n">encode_decode_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">,</span> <span class="s2">"ENCODE"</span><span class="p">,</span> <span class="n">replace</span><span class="o">=</span><span class="kc">False</span><span class="p">),</span> -</span><span id="DuckDB-452"><a href="#DuckDB-452"><span class="linenos">452</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Explode</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"UNNEST"</span><span class="p">),</span> -</span><span id="DuckDB-453"><a href="#DuckDB-453"><span class="linenos">453</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">IntDiv</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="s2">"//"</span><span class="p">),</span> -</span><span id="DuckDB-454"><a href="#DuckDB-454"><span class="linenos">454</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">IsInf</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"ISINF"</span><span class="p">),</span> -</span><span id="DuckDB-455"><a href="#DuckDB-455"><span class="linenos">455</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">IsNan</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"ISNAN"</span><span class="p">),</span> -</span><span id="DuckDB-456"><a href="#DuckDB-456"><span class="linenos">456</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtract</span><span class="p">:</span> <span class="n">_arrow_json_extract_sql</span><span class="p">,</span> -</span><span id="DuckDB-457"><a href="#DuckDB-457"><span class="linenos">457</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtractScalar</span><span class="p">:</span> <span class="n">_arrow_json_extract_sql</span><span class="p">,</span> -</span><span id="DuckDB-458"><a href="#DuckDB-458"><span class="linenos">458</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONFormat</span><span class="p">:</span> <span class="n">_json_format_sql</span><span class="p">,</span> -</span><span id="DuckDB-459"><a href="#DuckDB-459"><span class="linenos">459</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LogicalOr</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"BOOL_OR"</span><span class="p">),</span> -</span><span id="DuckDB-460"><a href="#DuckDB-460"><span class="linenos">460</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LogicalAnd</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"BOOL_AND"</span><span class="p">),</span> -</span><span id="DuckDB-461"><a href="#DuckDB-461"><span class="linenos">461</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MD5Digest</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"UNHEX"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"MD5"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">)),</span> -</span><span id="DuckDB-462"><a href="#DuckDB-462"><span class="linenos">462</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MonthsBetween</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="DuckDB-463"><a href="#DuckDB-463"><span class="linenos">463</span></a> <span class="s2">"DATEDIFF"</span><span class="p">,</span> -</span><span id="DuckDB-464"><a href="#DuckDB-464"><span class="linenos">464</span></a> <span class="s2">"'month'"</span><span class="p">,</span> -</span><span id="DuckDB-465"><a href="#DuckDB-465"><span class="linenos">465</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMP</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> -</span><span id="DuckDB-466"><a href="#DuckDB-466"><span class="linenos">466</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMP</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> -</span><span id="DuckDB-467"><a href="#DuckDB-467"><span class="linenos">467</span></a> <span class="p">),</span> -</span><span id="DuckDB-468"><a href="#DuckDB-468"><span class="linenos">468</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PercentileCont</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"QUANTILE_CONT"</span><span class="p">),</span> -</span><span id="DuckDB-469"><a href="#DuckDB-469"><span class="linenos">469</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PercentileDisc</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"QUANTILE_DISC"</span><span class="p">),</span> -</span><span id="DuckDB-470"><a href="#DuckDB-470"><span class="linenos">470</span></a> <span class="c1"># DuckDB doesn't allow qualified columns inside of PIVOT expressions.</span> -</span><span id="DuckDB-471"><a href="#DuckDB-471"><span class="linenos">471</span></a> <span class="c1"># See: https://github.com/duckdb/duckdb/blob/671faf92411182f81dce42ac43de8bfb05d9909e/src/planner/binder/tableref/bind_pivot.cpp#L61-L62</span> -</span><span id="DuckDB-472"><a href="#DuckDB-472"><span class="linenos">472</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Pivot</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">([</span><span class="n">transforms</span><span class="o">.</span><span class="n">unqualify_columns</span><span class="p">]),</span> -</span><span id="DuckDB-473"><a href="#DuckDB-473"><span class="linenos">473</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpExtract</span><span class="p">:</span> <span class="n">regexp_extract_sql</span><span class="p">,</span> -</span><span id="DuckDB-474"><a href="#DuckDB-474"><span class="linenos">474</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpReplace</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="DuckDB-475"><a href="#DuckDB-475"><span class="linenos">475</span></a> <span class="s2">"REGEXP_REPLACE"</span><span class="p">,</span> -</span><span id="DuckDB-476"><a href="#DuckDB-476"><span class="linenos">476</span></a> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> -</span><span id="DuckDB-477"><a href="#DuckDB-477"><span class="linenos">477</span></a> <span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> -</span><span id="DuckDB-478"><a href="#DuckDB-478"><span class="linenos">478</span></a> <span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"replacement"</span><span class="p">),</span> -</span><span id="DuckDB-479"><a href="#DuckDB-479"><span class="linenos">479</span></a> <span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"modifiers"</span><span class="p">),</span> -</span><span id="DuckDB-480"><a href="#DuckDB-480"><span class="linenos">480</span></a> <span class="p">),</span> -</span><span id="DuckDB-481"><a href="#DuckDB-481"><span class="linenos">481</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpLike</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"REGEXP_MATCHES"</span><span class="p">),</span> -</span><span id="DuckDB-482"><a href="#DuckDB-482"><span class="linenos">482</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpSplit</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"STR_SPLIT_REGEX"</span><span class="p">),</span> -</span><span id="DuckDB-483"><a href="#DuckDB-483"><span class="linenos">483</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Return</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">),</span> -</span><span id="DuckDB-484"><a href="#DuckDB-484"><span class="linenos">484</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ReturnsProperty</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="s2">"TABLE"</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">e</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">Schema</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span><span class="p">,</span> -</span><span id="DuckDB-485"><a href="#DuckDB-485"><span class="linenos">485</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Rand</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"RANDOM"</span><span class="p">),</span> -</span><span id="DuckDB-486"><a href="#DuckDB-486"><span class="linenos">486</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SafeDivide</span><span class="p">:</span> <span class="n">no_safe_divide_sql</span><span class="p">,</span> -</span><span id="DuckDB-487"><a href="#DuckDB-487"><span class="linenos">487</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Split</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"STR_SPLIT"</span><span class="p">),</span> -</span><span id="DuckDB-488"><a href="#DuckDB-488"><span class="linenos">488</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SortArray</span><span class="p">:</span> <span class="n">_sort_array_sql</span><span class="p">,</span> -</span><span id="DuckDB-489"><a href="#DuckDB-489"><span class="linenos">489</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrPosition</span><span class="p">:</span> <span class="n">str_position_sql</span><span class="p">,</span> -</span><span id="DuckDB-490"><a href="#DuckDB-490"><span class="linenos">490</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToUnix</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="DuckDB-491"><a href="#DuckDB-491"><span class="linenos">491</span></a> <span class="s2">"EPOCH"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"STRPTIME"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span><span class="n">e</span><span class="p">))</span> -</span><span id="DuckDB-492"><a href="#DuckDB-492"><span class="linenos">492</span></a> <span class="p">),</span> -</span><span id="DuckDB-493"><a href="#DuckDB-493"><span class="linenos">493</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Struct</span><span class="p">:</span> <span class="n">_struct_sql</span><span class="p">,</span> -</span><span id="DuckDB-494"><a href="#DuckDB-494"><span class="linenos">494</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeAdd</span><span class="p">:</span> <span class="n">_date_delta_sql</span><span class="p">,</span> -</span><span id="DuckDB-495"><a href="#DuckDB-495"><span class="linenos">495</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Time</span><span class="p">:</span> <span class="n">no_time_sql</span><span class="p">,</span> -</span><span id="DuckDB-496"><a href="#DuckDB-496"><span class="linenos">496</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Timestamp</span><span class="p">:</span> <span class="n">no_timestamp_sql</span><span class="p">,</span> -</span><span id="DuckDB-497"><a href="#DuckDB-497"><span class="linenos">497</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimestampDiff</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="DuckDB-498"><a href="#DuckDB-498"><span class="linenos">498</span></a> <span class="s2">"DATE_DIFF"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">unit</span><span class="p">),</span> <span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span> -</span><span id="DuckDB-499"><a href="#DuckDB-499"><span class="linenos">499</span></a> <span class="p">),</span> -</span><span id="DuckDB-500"><a href="#DuckDB-500"><span class="linenos">500</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimestampTrunc</span><span class="p">:</span> <span class="n">timestamptrunc_sql</span><span class="p">(),</span> -</span><span id="DuckDB-501"><a href="#DuckDB-501"><span class="linenos">501</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeStrToDate</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">e</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">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">DATE</span><span class="p">)),</span> -</span><span id="DuckDB-502"><a href="#DuckDB-502"><span class="linenos">502</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeStrToTime</span><span class="p">:</span> <span class="n">timestrtotime_sql</span><span class="p">,</span> -</span><span id="DuckDB-503"><a href="#DuckDB-503"><span class="linenos">503</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeStrToUnix</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="DuckDB-504"><a href="#DuckDB-504"><span class="linenos">504</span></a> <span class="s2">"EPOCH"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMP</span><span class="p">)</span> +</span><span id="DuckDB-385"><a href="#DuckDB-385"><span class="linenos">385</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-386"><a href="#DuckDB-386"><span class="linenos">386</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-387"><a href="#DuckDB-387"><span class="linenos">387</span></a> +</span><span id="DuckDB-388"><a href="#DuckDB-388"><span class="linenos">388</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> +</span><span id="DuckDB-389"><a href="#DuckDB-389"><span class="linenos">389</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_field_def</span><span class="p">()</span> +</span><span id="DuckDB-390"><a href="#DuckDB-390"><span class="linenos">390</span></a> +</span><span id="DuckDB-391"><a href="#DuckDB-391"><span class="linenos">391</span></a> <span class="k">def</span> <span class="nf">_pivot_column_names</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">aggregations</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">])</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> +</span><span id="DuckDB-392"><a href="#DuckDB-392"><span class="linenos">392</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">aggregations</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> +</span><span id="DuckDB-393"><a href="#DuckDB-393"><span class="linenos">393</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_pivot_column_names</span><span class="p">(</span><span class="n">aggregations</span><span class="p">)</span> +</span><span id="DuckDB-394"><a href="#DuckDB-394"><span class="linenos">394</span></a> <span class="k">return</span> <span class="n">pivot_column_names</span><span class="p">(</span><span class="n">aggregations</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="s2">"duckdb"</span><span class="p">)</span> +</span><span id="DuckDB-395"><a href="#DuckDB-395"><span class="linenos">395</span></a> +</span><span id="DuckDB-396"><a href="#DuckDB-396"><span class="linenos">396</span></a> <span class="k">class</span> <span class="nc">Generator</span><span class="p">(</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="p">):</span> +</span><span id="DuckDB-397"><a href="#DuckDB-397"><span class="linenos">397</span></a> <span class="n">PARAMETER_TOKEN</span> <span class="o">=</span> <span class="s2">"$"</span> +</span><span id="DuckDB-398"><a href="#DuckDB-398"><span class="linenos">398</span></a> <span class="n">NAMED_PLACEHOLDER_TOKEN</span> <span class="o">=</span> <span class="s2">"$"</span> +</span><span id="DuckDB-399"><a href="#DuckDB-399"><span class="linenos">399</span></a> <span class="n">JOIN_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="DuckDB-400"><a href="#DuckDB-400"><span class="linenos">400</span></a> <span class="n">TABLE_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="DuckDB-401"><a href="#DuckDB-401"><span class="linenos">401</span></a> <span class="n">QUERY_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="DuckDB-402"><a href="#DuckDB-402"><span class="linenos">402</span></a> <span class="n">LIMIT_FETCH</span> <span class="o">=</span> <span class="s2">"LIMIT"</span> +</span><span id="DuckDB-403"><a href="#DuckDB-403"><span class="linenos">403</span></a> <span class="n">STRUCT_DELIMITER</span> <span class="o">=</span> <span class="p">(</span><span class="s2">"("</span><span class="p">,</span> <span class="s2">")"</span><span class="p">)</span> +</span><span id="DuckDB-404"><a href="#DuckDB-404"><span class="linenos">404</span></a> <span class="n">RENAME_TABLE_WITH_DB</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="DuckDB-405"><a href="#DuckDB-405"><span class="linenos">405</span></a> <span class="n">NVL2_SUPPORTED</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="DuckDB-406"><a href="#DuckDB-406"><span class="linenos">406</span></a> <span class="n">SEMI_ANTI_JOIN_WITH_SIDE</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="DuckDB-407"><a href="#DuckDB-407"><span class="linenos">407</span></a> <span class="n">TABLESAMPLE_KEYWORDS</span> <span class="o">=</span> <span class="s2">"USING SAMPLE"</span> +</span><span id="DuckDB-408"><a href="#DuckDB-408"><span class="linenos">408</span></a> <span class="n">TABLESAMPLE_SEED_KEYWORD</span> <span class="o">=</span> <span class="s2">"REPEATABLE"</span> +</span><span id="DuckDB-409"><a href="#DuckDB-409"><span class="linenos">409</span></a> <span class="n">LAST_DAY_SUPPORTS_DATE_PART</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="DuckDB-410"><a href="#DuckDB-410"><span class="linenos">410</span></a> <span class="n">JSON_KEY_VALUE_PAIR_SEP</span> <span class="o">=</span> <span class="s2">","</span> +</span><span id="DuckDB-411"><a href="#DuckDB-411"><span class="linenos">411</span></a> <span class="n">IGNORE_NULLS_IN_FUNC</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="DuckDB-412"><a href="#DuckDB-412"><span class="linenos">412</span></a> <span class="n">JSON_PATH_BRACKETED_KEY_SUPPORTED</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="DuckDB-413"><a href="#DuckDB-413"><span class="linenos">413</span></a> <span class="n">SUPPORTS_CREATE_TABLE_LIKE</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="DuckDB-414"><a href="#DuckDB-414"><span class="linenos">414</span></a> <span class="n">MULTI_ARG_DISTINCT</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="DuckDB-415"><a href="#DuckDB-415"><span class="linenos">415</span></a> <span class="n">CAN_IMPLEMENT_ARRAY_ANY</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="DuckDB-416"><a href="#DuckDB-416"><span class="linenos">416</span></a> <span class="n">SUPPORTS_TO_NUMBER</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="DuckDB-417"><a href="#DuckDB-417"><span class="linenos">417</span></a> <span class="n">COPY_HAS_INTO_KEYWORD</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="DuckDB-418"><a href="#DuckDB-418"><span class="linenos">418</span></a> <span class="n">STAR_EXCEPT</span> <span class="o">=</span> <span class="s2">"EXCLUDE"</span> +</span><span id="DuckDB-419"><a href="#DuckDB-419"><span class="linenos">419</span></a> <span class="n">PAD_FILL_PATTERN_IS_REQUIRED</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="DuckDB-420"><a href="#DuckDB-420"><span class="linenos">420</span></a> +</span><span id="DuckDB-421"><a href="#DuckDB-421"><span class="linenos">421</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="DuckDB-422"><a href="#DuckDB-422"><span class="linenos">422</span></a> <span class="o">**</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">TRANSFORMS</span><span class="p">,</span> +</span><span id="DuckDB-423"><a href="#DuckDB-423"><span class="linenos">423</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxDistinct</span><span class="p">:</span> <span class="n">approx_count_distinct_sql</span><span class="p">,</span> +</span><span id="DuckDB-424"><a href="#DuckDB-424"><span class="linenos">424</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Array</span><span class="p">:</span> <span class="n">inline_array_unless_query</span><span class="p">,</span> +</span><span id="DuckDB-425"><a href="#DuckDB-425"><span class="linenos">425</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayContainsAll</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"ARRAY_HAS_ALL"</span><span class="p">),</span> +</span><span id="DuckDB-426"><a href="#DuckDB-426"><span class="linenos">426</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayFilter</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"LIST_FILTER"</span><span class="p">),</span> +</span><span id="DuckDB-427"><a href="#DuckDB-427"><span class="linenos">427</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArraySize</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"ARRAY_LENGTH"</span><span class="p">),</span> +</span><span id="DuckDB-428"><a href="#DuckDB-428"><span class="linenos">428</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArgMax</span><span class="p">:</span> <span class="n">arg_max_or_min_no_count</span><span class="p">(</span><span class="s2">"ARG_MAX"</span><span class="p">),</span> +</span><span id="DuckDB-429"><a href="#DuckDB-429"><span class="linenos">429</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArgMin</span><span class="p">:</span> <span class="n">arg_max_or_min_no_count</span><span class="p">(</span><span class="s2">"ARG_MIN"</span><span class="p">),</span> +</span><span id="DuckDB-430"><a href="#DuckDB-430"><span class="linenos">430</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArraySort</span><span class="p">:</span> <span class="n">_array_sort_sql</span><span class="p">,</span> +</span><span id="DuckDB-431"><a href="#DuckDB-431"><span class="linenos">431</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArraySum</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"LIST_SUM"</span><span class="p">),</span> +</span><span id="DuckDB-432"><a href="#DuckDB-432"><span class="linenos">432</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseXor</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"XOR"</span><span class="p">),</span> +</span><span id="DuckDB-433"><a href="#DuckDB-433"><span class="linenos">433</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CommentColumnConstraint</span><span class="p">:</span> <span class="n">no_comment_column_constraint_sql</span><span class="p">,</span> +</span><span id="DuckDB-434"><a href="#DuckDB-434"><span class="linenos">434</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CurrentDate</span><span class="p">:</span> <span class="k">lambda</span> <span class="o">*</span><span class="n">_</span><span class="p">:</span> <span class="s2">"CURRENT_DATE"</span><span class="p">,</span> +</span><span id="DuckDB-435"><a href="#DuckDB-435"><span class="linenos">435</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CurrentTime</span><span class="p">:</span> <span class="k">lambda</span> <span class="o">*</span><span class="n">_</span><span class="p">:</span> <span class="s2">"CURRENT_TIME"</span><span class="p">,</span> +</span><span id="DuckDB-436"><a href="#DuckDB-436"><span class="linenos">436</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CurrentTimestamp</span><span class="p">:</span> <span class="k">lambda</span> <span class="o">*</span><span class="n">_</span><span class="p">:</span> <span class="s2">"CURRENT_TIMESTAMP"</span><span class="p">,</span> +</span><span id="DuckDB-437"><a href="#DuckDB-437"><span class="linenos">437</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DayOfMonth</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"DAYOFMONTH"</span><span class="p">),</span> +</span><span id="DuckDB-438"><a href="#DuckDB-438"><span class="linenos">438</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DayOfWeek</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"DAYOFWEEK"</span><span class="p">),</span> +</span><span id="DuckDB-439"><a href="#DuckDB-439"><span class="linenos">439</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DayOfYear</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"DAYOFYEAR"</span><span class="p">),</span> +</span><span id="DuckDB-440"><a href="#DuckDB-440"><span class="linenos">440</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">:</span> <span class="n">_datatype_sql</span><span class="p">,</span> +</span><span id="DuckDB-441"><a href="#DuckDB-441"><span class="linenos">441</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Date</span><span class="p">:</span> <span class="n">_date_sql</span><span class="p">,</span> +</span><span id="DuckDB-442"><a href="#DuckDB-442"><span class="linenos">442</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</span><span class="p">:</span> <span class="n">_date_delta_sql</span><span class="p">,</span> +</span><span id="DuckDB-443"><a href="#DuckDB-443"><span class="linenos">443</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateFromParts</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"MAKE_DATE"</span><span class="p">),</span> +</span><span id="DuckDB-444"><a href="#DuckDB-444"><span class="linenos">444</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateSub</span><span class="p">:</span> <span class="n">_date_delta_sql</span><span class="p">,</span> +</span><span id="DuckDB-445"><a href="#DuckDB-445"><span class="linenos">445</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateDiff</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> +</span><span id="DuckDB-446"><a href="#DuckDB-446"><span class="linenos">446</span></a> <span class="s2">"DATE_DIFF"</span><span class="p">,</span> <span class="sa">f</span><span class="s2">"'</span><span class="si">{</span><span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'unit'</span><span class="p">)</span><span class="w"> </span><span class="ow">or</span><span class="w"> </span><span class="s1">'DAY'</span><span class="si">}</span><span class="s2">'"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span> +</span><span id="DuckDB-447"><a href="#DuckDB-447"><span class="linenos">447</span></a> <span class="p">),</span> +</span><span id="DuckDB-448"><a href="#DuckDB-448"><span class="linenos">448</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateStrToDate</span><span class="p">:</span> <span class="n">datestrtodate_sql</span><span class="p">,</span> +</span><span id="DuckDB-449"><a href="#DuckDB-449"><span class="linenos">449</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Datetime</span><span class="p">:</span> <span class="n">no_datetime_sql</span><span class="p">,</span> +</span><span id="DuckDB-450"><a href="#DuckDB-450"><span class="linenos">450</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DatetimeSub</span><span class="p">:</span> <span class="n">_date_delta_sql</span><span class="p">,</span> +</span><span id="DuckDB-451"><a href="#DuckDB-451"><span class="linenos">451</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DatetimeAdd</span><span class="p">:</span> <span class="n">_date_delta_sql</span><span class="p">,</span> +</span><span id="DuckDB-452"><a href="#DuckDB-452"><span class="linenos">452</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateToDi</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> +</span><span id="DuckDB-453"><a href="#DuckDB-453"><span class="linenos">453</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"CAST(STRFTIME(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="n">DuckDB</span><span class="o">.</span><span class="n">DATEINT_FORMAT</span><span class="si">}</span><span class="s2">) AS INT)"</span><span class="p">,</span> +</span><span id="DuckDB-454"><a href="#DuckDB-454"><span class="linenos">454</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Decode</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="n">encode_decode_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">,</span> <span class="s2">"DECODE"</span><span class="p">,</span> <span class="n">replace</span><span class="o">=</span><span class="kc">False</span><span class="p">),</span> +</span><span id="DuckDB-455"><a href="#DuckDB-455"><span class="linenos">455</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DiToDate</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> +</span><span id="DuckDB-456"><a href="#DuckDB-456"><span class="linenos">456</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"CAST(STRPTIME(CAST(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS TEXT), </span><span class="si">{</span><span class="n">DuckDB</span><span class="o">.</span><span class="n">DATEINT_FORMAT</span><span class="si">}</span><span class="s2">) AS DATE)"</span><span class="p">,</span> +</span><span id="DuckDB-457"><a href="#DuckDB-457"><span class="linenos">457</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Encode</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="n">encode_decode_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">,</span> <span class="s2">"ENCODE"</span><span class="p">,</span> <span class="n">replace</span><span class="o">=</span><span class="kc">False</span><span class="p">),</span> +</span><span id="DuckDB-458"><a href="#DuckDB-458"><span class="linenos">458</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Explode</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"UNNEST"</span><span class="p">),</span> +</span><span id="DuckDB-459"><a href="#DuckDB-459"><span class="linenos">459</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">IntDiv</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="s2">"//"</span><span class="p">),</span> +</span><span id="DuckDB-460"><a href="#DuckDB-460"><span class="linenos">460</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">IsInf</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"ISINF"</span><span class="p">),</span> +</span><span id="DuckDB-461"><a href="#DuckDB-461"><span class="linenos">461</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">IsNan</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"ISNAN"</span><span class="p">),</span> +</span><span id="DuckDB-462"><a href="#DuckDB-462"><span class="linenos">462</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtract</span><span class="p">:</span> <span class="n">_arrow_json_extract_sql</span><span class="p">,</span> +</span><span id="DuckDB-463"><a href="#DuckDB-463"><span class="linenos">463</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtractScalar</span><span class="p">:</span> <span class="n">_arrow_json_extract_sql</span><span class="p">,</span> +</span><span id="DuckDB-464"><a href="#DuckDB-464"><span class="linenos">464</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONFormat</span><span class="p">:</span> <span class="n">_json_format_sql</span><span class="p">,</span> +</span><span id="DuckDB-465"><a href="#DuckDB-465"><span class="linenos">465</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LogicalOr</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"BOOL_OR"</span><span class="p">),</span> +</span><span id="DuckDB-466"><a href="#DuckDB-466"><span class="linenos">466</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LogicalAnd</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"BOOL_AND"</span><span class="p">),</span> +</span><span id="DuckDB-467"><a href="#DuckDB-467"><span class="linenos">467</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MD5Digest</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"UNHEX"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"MD5"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">)),</span> +</span><span id="DuckDB-468"><a href="#DuckDB-468"><span class="linenos">468</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MonthsBetween</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> +</span><span id="DuckDB-469"><a href="#DuckDB-469"><span class="linenos">469</span></a> <span class="s2">"DATEDIFF"</span><span class="p">,</span> +</span><span id="DuckDB-470"><a href="#DuckDB-470"><span class="linenos">470</span></a> <span class="s2">"'month'"</span><span class="p">,</span> +</span><span id="DuckDB-471"><a href="#DuckDB-471"><span class="linenos">471</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMP</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> +</span><span id="DuckDB-472"><a href="#DuckDB-472"><span class="linenos">472</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMP</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> +</span><span id="DuckDB-473"><a href="#DuckDB-473"><span class="linenos">473</span></a> <span class="p">),</span> +</span><span id="DuckDB-474"><a href="#DuckDB-474"><span class="linenos">474</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PercentileCont</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"QUANTILE_CONT"</span><span class="p">),</span> +</span><span id="DuckDB-475"><a href="#DuckDB-475"><span class="linenos">475</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PercentileDisc</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"QUANTILE_DISC"</span><span class="p">),</span> +</span><span id="DuckDB-476"><a href="#DuckDB-476"><span class="linenos">476</span></a> <span class="c1"># DuckDB doesn't allow qualified columns inside of PIVOT expressions.</span> +</span><span id="DuckDB-477"><a href="#DuckDB-477"><span class="linenos">477</span></a> <span class="c1"># See: https://github.com/duckdb/duckdb/blob/671faf92411182f81dce42ac43de8bfb05d9909e/src/planner/binder/tableref/bind_pivot.cpp#L61-L62</span> +</span><span id="DuckDB-478"><a href="#DuckDB-478"><span class="linenos">478</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Pivot</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">([</span><span class="n">transforms</span><span class="o">.</span><span class="n">unqualify_columns</span><span class="p">]),</span> +</span><span id="DuckDB-479"><a href="#DuckDB-479"><span class="linenos">479</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpExtract</span><span class="p">:</span> <span class="n">regexp_extract_sql</span><span class="p">,</span> +</span><span id="DuckDB-480"><a href="#DuckDB-480"><span class="linenos">480</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpReplace</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> +</span><span id="DuckDB-481"><a href="#DuckDB-481"><span class="linenos">481</span></a> <span class="s2">"REGEXP_REPLACE"</span><span class="p">,</span> +</span><span id="DuckDB-482"><a href="#DuckDB-482"><span class="linenos">482</span></a> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> +</span><span id="DuckDB-483"><a href="#DuckDB-483"><span class="linenos">483</span></a> <span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> +</span><span id="DuckDB-484"><a href="#DuckDB-484"><span class="linenos">484</span></a> <span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"replacement"</span><span class="p">),</span> +</span><span id="DuckDB-485"><a href="#DuckDB-485"><span class="linenos">485</span></a> <span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"modifiers"</span><span class="p">),</span> +</span><span id="DuckDB-486"><a href="#DuckDB-486"><span class="linenos">486</span></a> <span class="p">),</span> +</span><span id="DuckDB-487"><a href="#DuckDB-487"><span class="linenos">487</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpLike</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"REGEXP_MATCHES"</span><span class="p">),</span> +</span><span id="DuckDB-488"><a href="#DuckDB-488"><span class="linenos">488</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpSplit</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"STR_SPLIT_REGEX"</span><span class="p">),</span> +</span><span id="DuckDB-489"><a href="#DuckDB-489"><span class="linenos">489</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Return</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">),</span> +</span><span id="DuckDB-490"><a href="#DuckDB-490"><span class="linenos">490</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ReturnsProperty</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="s2">"TABLE"</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">e</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">Schema</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span><span class="p">,</span> +</span><span id="DuckDB-491"><a href="#DuckDB-491"><span class="linenos">491</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Rand</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"RANDOM"</span><span class="p">),</span> +</span><span id="DuckDB-492"><a href="#DuckDB-492"><span class="linenos">492</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SafeDivide</span><span class="p">:</span> <span class="n">no_safe_divide_sql</span><span class="p">,</span> +</span><span id="DuckDB-493"><a href="#DuckDB-493"><span class="linenos">493</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Split</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"STR_SPLIT"</span><span class="p">),</span> +</span><span id="DuckDB-494"><a href="#DuckDB-494"><span class="linenos">494</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SortArray</span><span class="p">:</span> <span class="n">_sort_array_sql</span><span class="p">,</span> +</span><span id="DuckDB-495"><a href="#DuckDB-495"><span class="linenos">495</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrPosition</span><span class="p">:</span> <span class="n">str_position_sql</span><span class="p">,</span> +</span><span id="DuckDB-496"><a href="#DuckDB-496"><span class="linenos">496</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToUnix</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> +</span><span id="DuckDB-497"><a href="#DuckDB-497"><span class="linenos">497</span></a> <span class="s2">"EPOCH"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"STRPTIME"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span><span class="n">e</span><span class="p">))</span> +</span><span id="DuckDB-498"><a href="#DuckDB-498"><span class="linenos">498</span></a> <span class="p">),</span> +</span><span id="DuckDB-499"><a href="#DuckDB-499"><span class="linenos">499</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Struct</span><span class="p">:</span> <span class="n">_struct_sql</span><span class="p">,</span> +</span><span id="DuckDB-500"><a href="#DuckDB-500"><span class="linenos">500</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeAdd</span><span class="p">:</span> <span class="n">_date_delta_sql</span><span class="p">,</span> +</span><span id="DuckDB-501"><a href="#DuckDB-501"><span class="linenos">501</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Time</span><span class="p">:</span> <span class="n">no_time_sql</span><span class="p">,</span> +</span><span id="DuckDB-502"><a href="#DuckDB-502"><span class="linenos">502</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Timestamp</span><span class="p">:</span> <span class="n">no_timestamp_sql</span><span class="p">,</span> +</span><span id="DuckDB-503"><a href="#DuckDB-503"><span class="linenos">503</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimestampDiff</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> +</span><span id="DuckDB-504"><a href="#DuckDB-504"><span class="linenos">504</span></a> <span class="s2">"DATE_DIFF"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">unit</span><span class="p">),</span> <span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span> </span><span id="DuckDB-505"><a href="#DuckDB-505"><span class="linenos">505</span></a> <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">TimeToStr</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"STRFTIME"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span><span class="n">e</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">TimeToUnix</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"EPOCH"</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">TsOrDiToDi</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> -</span><span id="DuckDB-509"><a href="#DuckDB-509"><span class="linenos">509</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"CAST(SUBSTR(REPLACE(CAST(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS TEXT), '-', ''), 1, 8) AS INT)"</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">TsOrDsAdd</span><span class="p">:</span> <span class="n">_date_delta_sql</span><span class="p">,</span> -</span><span id="DuckDB-511"><a href="#DuckDB-511"><span class="linenos">511</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsDiff</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="DuckDB-512"><a href="#DuckDB-512"><span class="linenos">512</span></a> <span class="s2">"DATE_DIFF"</span><span class="p">,</span> -</span><span id="DuckDB-513"><a href="#DuckDB-513"><span class="linenos">513</span></a> <span class="sa">f</span><span class="s2">"'</span><span class="si">{</span><span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'unit'</span><span class="p">)</span><span class="w"> </span><span class="ow">or</span><span class="w"> </span><span class="s1">'DAY'</span><span class="si">}</span><span class="s2">'"</span><span class="p">,</span> -</span><span id="DuckDB-514"><a href="#DuckDB-514"><span class="linenos">514</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMP</span><span class="p">),</span> -</span><span id="DuckDB-515"><a href="#DuckDB-515"><span class="linenos">515</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMP</span><span class="p">),</span> -</span><span id="DuckDB-516"><a href="#DuckDB-516"><span class="linenos">516</span></a> <span class="p">),</span> -</span><span id="DuckDB-517"><a href="#DuckDB-517"><span class="linenos">517</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToStr</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="DuckDB-518"><a href="#DuckDB-518"><span class="linenos">518</span></a> <span class="s2">"STRFTIME"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"TO_TIMESTAMP"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">),</span> <span class="bp">self</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span><span class="n">e</span><span class="p">)</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 class="n">exp</span><span class="o">.</span><span class="n">UnixToTime</span><span class="p">:</span> <span class="n">_unix_to_time_sql</span><span class="p">,</span> -</span><span id="DuckDB-521"><a href="#DuckDB-521"><span class="linenos">521</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToTimeStr</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"CAST(TO_TIMESTAMP(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">) AS TEXT)"</span><span class="p">,</span> -</span><span id="DuckDB-522"><a href="#DuckDB-522"><span class="linenos">522</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VariancePop</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"VAR_POP"</span><span class="p">),</span> -</span><span id="DuckDB-523"><a href="#DuckDB-523"><span class="linenos">523</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">WeekOfYear</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"WEEKOFYEAR"</span><span class="p">),</span> -</span><span id="DuckDB-524"><a href="#DuckDB-524"><span class="linenos">524</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Xor</span><span class="p">:</span> <span class="n">bool_xor_sql</span><span class="p">,</span> -</span><span id="DuckDB-525"><a href="#DuckDB-525"><span class="linenos">525</span></a> <span class="p">}</span> -</span><span id="DuckDB-526"><a href="#DuckDB-526"><span class="linenos">526</span></a> -</span><span id="DuckDB-527"><a href="#DuckDB-527"><span class="linenos">527</span></a> <span class="n">SUPPORTED_JSON_PATH_PARTS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="DuckDB-528"><a href="#DuckDB-528"><span class="linenos">528</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONPathKey</span><span class="p">,</span> -</span><span id="DuckDB-529"><a href="#DuckDB-529"><span class="linenos">529</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONPathRoot</span><span class="p">,</span> -</span><span id="DuckDB-530"><a href="#DuckDB-530"><span class="linenos">530</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONPathSubscript</span><span class="p">,</span> -</span><span id="DuckDB-531"><a href="#DuckDB-531"><span class="linenos">531</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONPathWildcard</span><span class="p">,</span> -</span><span id="DuckDB-532"><a href="#DuckDB-532"><span class="linenos">532</span></a> <span class="p">}</span> -</span><span id="DuckDB-533"><a href="#DuckDB-533"><span class="linenos">533</span></a> -</span><span id="DuckDB-534"><a href="#DuckDB-534"><span class="linenos">534</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="DuckDB-535"><a href="#DuckDB-535"><span class="linenos">535</span></a> <span class="o">**</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">TYPE_MAPPING</span><span class="p">,</span> -</span><span id="DuckDB-536"><a href="#DuckDB-536"><span class="linenos">536</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">BINARY</span><span class="p">:</span> <span class="s2">"BLOB"</span><span class="p">,</span> -</span><span id="DuckDB-537"><a href="#DuckDB-537"><span class="linenos">537</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">BPCHAR</span><span class="p">:</span> <span class="s2">"TEXT"</span><span class="p">,</span> -</span><span id="DuckDB-538"><a href="#DuckDB-538"><span class="linenos">538</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">CHAR</span><span class="p">:</span> <span class="s2">"TEXT"</span><span class="p">,</span> -</span><span id="DuckDB-539"><a href="#DuckDB-539"><span class="linenos">539</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">FLOAT</span><span class="p">:</span> <span class="s2">"REAL"</span><span class="p">,</span> -</span><span id="DuckDB-540"><a href="#DuckDB-540"><span class="linenos">540</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">NCHAR</span><span class="p">:</span> <span class="s2">"TEXT"</span><span class="p">,</span> -</span><span id="DuckDB-541"><a href="#DuckDB-541"><span class="linenos">541</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">NVARCHAR</span><span class="p">:</span> <span class="s2">"TEXT"</span><span class="p">,</span> -</span><span id="DuckDB-542"><a href="#DuckDB-542"><span class="linenos">542</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">UINT</span><span class="p">:</span> <span class="s2">"UINTEGER"</span><span class="p">,</span> -</span><span id="DuckDB-543"><a href="#DuckDB-543"><span class="linenos">543</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-544"><a href="#DuckDB-544"><span class="linenos">544</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-545"><a href="#DuckDB-545"><span class="linenos">545</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-546"><a href="#DuckDB-546"><span class="linenos">546</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-547"><a href="#DuckDB-547"><span class="linenos">547</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-548"><a href="#DuckDB-548"><span class="linenos">548</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-549"><a href="#DuckDB-549"><span class="linenos">549</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-550"><a href="#DuckDB-550"><span class="linenos">550</span></a> <span class="p">}</span> -</span><span id="DuckDB-551"><a href="#DuckDB-551"><span class="linenos">551</span></a> -</span><span id="DuckDB-552"><a href="#DuckDB-552"><span class="linenos">552</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-553"><a href="#DuckDB-553"><span class="linenos">553</span></a> <span class="n">RESERVED_KEYWORDS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="DuckDB-554"><a href="#DuckDB-554"><span class="linenos">554</span></a> <span class="s2">"array"</span><span class="p">,</span> -</span><span id="DuckDB-555"><a href="#DuckDB-555"><span class="linenos">555</span></a> <span class="s2">"analyse"</span><span class="p">,</span> -</span><span id="DuckDB-556"><a href="#DuckDB-556"><span class="linenos">556</span></a> <span class="s2">"union"</span><span class="p">,</span> -</span><span id="DuckDB-557"><a href="#DuckDB-557"><span class="linenos">557</span></a> <span class="s2">"all"</span><span class="p">,</span> -</span><span id="DuckDB-558"><a href="#DuckDB-558"><span class="linenos">558</span></a> <span class="s2">"when"</span><span class="p">,</span> -</span><span id="DuckDB-559"><a href="#DuckDB-559"><span class="linenos">559</span></a> <span class="s2">"in_p"</span><span class="p">,</span> -</span><span id="DuckDB-560"><a href="#DuckDB-560"><span class="linenos">560</span></a> <span class="s2">"default"</span><span class="p">,</span> -</span><span id="DuckDB-561"><a href="#DuckDB-561"><span class="linenos">561</span></a> <span class="s2">"create_p"</span><span class="p">,</span> -</span><span id="DuckDB-562"><a href="#DuckDB-562"><span class="linenos">562</span></a> <span class="s2">"window"</span><span class="p">,</span> -</span><span id="DuckDB-563"><a href="#DuckDB-563"><span class="linenos">563</span></a> <span class="s2">"asymmetric"</span><span class="p">,</span> -</span><span id="DuckDB-564"><a href="#DuckDB-564"><span class="linenos">564</span></a> <span class="s2">"to"</span><span class="p">,</span> -</span><span id="DuckDB-565"><a href="#DuckDB-565"><span class="linenos">565</span></a> <span class="s2">"else"</span><span class="p">,</span> -</span><span id="DuckDB-566"><a href="#DuckDB-566"><span class="linenos">566</span></a> <span class="s2">"localtime"</span><span class="p">,</span> -</span><span id="DuckDB-567"><a href="#DuckDB-567"><span class="linenos">567</span></a> <span class="s2">"from"</span><span class="p">,</span> -</span><span id="DuckDB-568"><a href="#DuckDB-568"><span class="linenos">568</span></a> <span class="s2">"end_p"</span><span class="p">,</span> -</span><span id="DuckDB-569"><a href="#DuckDB-569"><span class="linenos">569</span></a> <span class="s2">"select"</span><span class="p">,</span> -</span><span id="DuckDB-570"><a href="#DuckDB-570"><span class="linenos">570</span></a> <span class="s2">"current_date"</span><span class="p">,</span> -</span><span id="DuckDB-571"><a href="#DuckDB-571"><span class="linenos">571</span></a> <span class="s2">"foreign"</span><span class="p">,</span> -</span><span id="DuckDB-572"><a href="#DuckDB-572"><span class="linenos">572</span></a> <span class="s2">"with"</span><span class="p">,</span> -</span><span id="DuckDB-573"><a href="#DuckDB-573"><span class="linenos">573</span></a> <span class="s2">"grant"</span><span class="p">,</span> -</span><span id="DuckDB-574"><a href="#DuckDB-574"><span class="linenos">574</span></a> <span class="s2">"session_user"</span><span class="p">,</span> -</span><span id="DuckDB-575"><a href="#DuckDB-575"><span class="linenos">575</span></a> <span class="s2">"or"</span><span class="p">,</span> -</span><span id="DuckDB-576"><a href="#DuckDB-576"><span class="linenos">576</span></a> <span class="s2">"except"</span><span class="p">,</span> -</span><span id="DuckDB-577"><a href="#DuckDB-577"><span class="linenos">577</span></a> <span class="s2">"references"</span><span class="p">,</span> -</span><span id="DuckDB-578"><a href="#DuckDB-578"><span class="linenos">578</span></a> <span class="s2">"fetch"</span><span class="p">,</span> -</span><span id="DuckDB-579"><a href="#DuckDB-579"><span class="linenos">579</span></a> <span class="s2">"limit"</span><span class="p">,</span> -</span><span id="DuckDB-580"><a href="#DuckDB-580"><span class="linenos">580</span></a> <span class="s2">"group_p"</span><span class="p">,</span> -</span><span id="DuckDB-581"><a href="#DuckDB-581"><span class="linenos">581</span></a> <span class="s2">"leading"</span><span class="p">,</span> -</span><span id="DuckDB-582"><a href="#DuckDB-582"><span class="linenos">582</span></a> <span class="s2">"into"</span><span class="p">,</span> -</span><span id="DuckDB-583"><a href="#DuckDB-583"><span class="linenos">583</span></a> <span class="s2">"collate"</span><span class="p">,</span> -</span><span id="DuckDB-584"><a href="#DuckDB-584"><span class="linenos">584</span></a> <span class="s2">"offset"</span><span class="p">,</span> -</span><span id="DuckDB-585"><a href="#DuckDB-585"><span class="linenos">585</span></a> <span class="s2">"do"</span><span class="p">,</span> -</span><span id="DuckDB-586"><a href="#DuckDB-586"><span class="linenos">586</span></a> <span class="s2">"then"</span><span class="p">,</span> -</span><span id="DuckDB-587"><a href="#DuckDB-587"><span class="linenos">587</span></a> <span class="s2">"localtimestamp"</span><span class="p">,</span> -</span><span id="DuckDB-588"><a href="#DuckDB-588"><span class="linenos">588</span></a> <span class="s2">"check_p"</span><span class="p">,</span> -</span><span id="DuckDB-589"><a href="#DuckDB-589"><span class="linenos">589</span></a> <span class="s2">"lateral_p"</span><span class="p">,</span> -</span><span id="DuckDB-590"><a href="#DuckDB-590"><span class="linenos">590</span></a> <span class="s2">"current_role"</span><span class="p">,</span> -</span><span id="DuckDB-591"><a href="#DuckDB-591"><span class="linenos">591</span></a> <span class="s2">"where"</span><span class="p">,</span> -</span><span id="DuckDB-592"><a href="#DuckDB-592"><span class="linenos">592</span></a> <span class="s2">"asc_p"</span><span class="p">,</span> -</span><span id="DuckDB-593"><a href="#DuckDB-593"><span class="linenos">593</span></a> <span class="s2">"placing"</span><span class="p">,</span> -</span><span id="DuckDB-594"><a href="#DuckDB-594"><span class="linenos">594</span></a> <span class="s2">"desc_p"</span><span class="p">,</span> -</span><span id="DuckDB-595"><a href="#DuckDB-595"><span class="linenos">595</span></a> <span class="s2">"user"</span><span class="p">,</span> -</span><span id="DuckDB-596"><a href="#DuckDB-596"><span class="linenos">596</span></a> <span class="s2">"unique"</span><span class="p">,</span> -</span><span id="DuckDB-597"><a href="#DuckDB-597"><span class="linenos">597</span></a> <span class="s2">"initially"</span><span class="p">,</span> -</span><span id="DuckDB-598"><a href="#DuckDB-598"><span class="linenos">598</span></a> <span class="s2">"column"</span><span class="p">,</span> -</span><span id="DuckDB-599"><a href="#DuckDB-599"><span class="linenos">599</span></a> <span class="s2">"both"</span><span class="p">,</span> -</span><span id="DuckDB-600"><a href="#DuckDB-600"><span class="linenos">600</span></a> <span class="s2">"some"</span><span class="p">,</span> -</span><span id="DuckDB-601"><a href="#DuckDB-601"><span class="linenos">601</span></a> <span class="s2">"as"</span><span class="p">,</span> -</span><span id="DuckDB-602"><a href="#DuckDB-602"><span class="linenos">602</span></a> <span class="s2">"any"</span><span class="p">,</span> -</span><span id="DuckDB-603"><a href="#DuckDB-603"><span class="linenos">603</span></a> <span class="s2">"only"</span><span class="p">,</span> -</span><span id="DuckDB-604"><a href="#DuckDB-604"><span class="linenos">604</span></a> <span class="s2">"deferrable"</span><span class="p">,</span> -</span><span id="DuckDB-605"><a href="#DuckDB-605"><span class="linenos">605</span></a> <span class="s2">"null_p"</span><span class="p">,</span> -</span><span id="DuckDB-606"><a href="#DuckDB-606"><span class="linenos">606</span></a> <span class="s2">"current_time"</span><span class="p">,</span> -</span><span id="DuckDB-607"><a href="#DuckDB-607"><span class="linenos">607</span></a> <span class="s2">"true_p"</span><span class="p">,</span> -</span><span id="DuckDB-608"><a href="#DuckDB-608"><span class="linenos">608</span></a> <span class="s2">"table"</span><span class="p">,</span> -</span><span id="DuckDB-609"><a href="#DuckDB-609"><span class="linenos">609</span></a> <span class="s2">"case"</span><span class="p">,</span> -</span><span id="DuckDB-610"><a href="#DuckDB-610"><span class="linenos">610</span></a> <span class="s2">"trailing"</span><span class="p">,</span> -</span><span id="DuckDB-611"><a href="#DuckDB-611"><span class="linenos">611</span></a> <span class="s2">"variadic"</span><span class="p">,</span> -</span><span id="DuckDB-612"><a href="#DuckDB-612"><span class="linenos">612</span></a> <span class="s2">"for"</span><span class="p">,</span> -</span><span id="DuckDB-613"><a href="#DuckDB-613"><span class="linenos">613</span></a> <span class="s2">"on"</span><span class="p">,</span> -</span><span id="DuckDB-614"><a href="#DuckDB-614"><span class="linenos">614</span></a> <span class="s2">"distinct"</span><span class="p">,</span> -</span><span id="DuckDB-615"><a href="#DuckDB-615"><span class="linenos">615</span></a> <span class="s2">"false_p"</span><span class="p">,</span> -</span><span id="DuckDB-616"><a href="#DuckDB-616"><span class="linenos">616</span></a> <span class="s2">"not"</span><span class="p">,</span> -</span><span id="DuckDB-617"><a href="#DuckDB-617"><span class="linenos">617</span></a> <span class="s2">"constraint"</span><span class="p">,</span> -</span><span id="DuckDB-618"><a href="#DuckDB-618"><span class="linenos">618</span></a> <span class="s2">"current_timestamp"</span><span class="p">,</span> -</span><span id="DuckDB-619"><a href="#DuckDB-619"><span class="linenos">619</span></a> <span class="s2">"returning"</span><span class="p">,</span> -</span><span id="DuckDB-620"><a href="#DuckDB-620"><span class="linenos">620</span></a> <span class="s2">"primary"</span><span class="p">,</span> -</span><span id="DuckDB-621"><a href="#DuckDB-621"><span class="linenos">621</span></a> <span class="s2">"intersect"</span><span class="p">,</span> -</span><span id="DuckDB-622"><a href="#DuckDB-622"><span class="linenos">622</span></a> <span class="s2">"having"</span><span class="p">,</span> -</span><span id="DuckDB-623"><a href="#DuckDB-623"><span class="linenos">623</span></a> <span class="s2">"analyze"</span><span class="p">,</span> -</span><span id="DuckDB-624"><a href="#DuckDB-624"><span class="linenos">624</span></a> <span class="s2">"current_user"</span><span class="p">,</span> -</span><span id="DuckDB-625"><a href="#DuckDB-625"><span class="linenos">625</span></a> <span class="s2">"and"</span><span class="p">,</span> -</span><span id="DuckDB-626"><a href="#DuckDB-626"><span class="linenos">626</span></a> <span class="s2">"cast"</span><span class="p">,</span> -</span><span id="DuckDB-627"><a href="#DuckDB-627"><span class="linenos">627</span></a> <span class="s2">"symmetric"</span><span class="p">,</span> -</span><span id="DuckDB-628"><a href="#DuckDB-628"><span class="linenos">628</span></a> <span class="s2">"using"</span><span class="p">,</span> -</span><span id="DuckDB-629"><a href="#DuckDB-629"><span class="linenos">629</span></a> <span class="s2">"order"</span><span class="p">,</span> -</span><span id="DuckDB-630"><a href="#DuckDB-630"><span class="linenos">630</span></a> <span class="s2">"current_catalog"</span><span class="p">,</span> -</span><span id="DuckDB-631"><a href="#DuckDB-631"><span class="linenos">631</span></a> <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="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-634"><a href="#DuckDB-634"><span class="linenos">634</span></a> -</span><span id="DuckDB-635"><a href="#DuckDB-635"><span class="linenos">635</span></a> <span class="c1"># DuckDB doesn't generally support CREATE TABLE .. properties</span> -</span><span id="DuckDB-636"><a href="#DuckDB-636"><span class="linenos">636</span></a> <span class="c1"># https://duckdb.org/docs/sql/statements/create_table.html</span> -</span><span id="DuckDB-637"><a href="#DuckDB-637"><span class="linenos">637</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="DuckDB-638"><a href="#DuckDB-638"><span class="linenos">638</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-639"><a href="#DuckDB-639"><span class="linenos">639</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-640"><a href="#DuckDB-640"><span class="linenos">640</span></a> <span class="p">}</span> -</span><span id="DuckDB-641"><a href="#DuckDB-641"><span class="linenos">641</span></a> -</span><span id="DuckDB-642"><a href="#DuckDB-642"><span class="linenos">642</span></a> <span class="c1"># There are a few exceptions (e.g. temporary tables) which are supported or</span> -</span><span id="DuckDB-643"><a href="#DuckDB-643"><span class="linenos">643</span></a> <span class="c1"># can be transpiled to DuckDB, so we explicitly override them accordingly</span> -</span><span id="DuckDB-644"><a href="#DuckDB-644"><span class="linenos">644</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-645"><a href="#DuckDB-645"><span class="linenos">645</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-646"><a href="#DuckDB-646"><span class="linenos">646</span></a> <span class="n">PROPERTIES_LOCATION</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">ReturnsProperty</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_ALIAS</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">TimestampTrunc</span><span class="p">:</span> <span class="n">timestamptrunc_sql</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">TimeStrToDate</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">e</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">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">DATE</span><span class="p">)),</span> +</span><span id="DuckDB-508"><a href="#DuckDB-508"><span class="linenos">508</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeStrToTime</span><span class="p">:</span> <span class="n">timestrtotime_sql</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">TimeStrToUnix</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> +</span><span id="DuckDB-510"><a href="#DuckDB-510"><span class="linenos">510</span></a> <span class="s2">"EPOCH"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMP</span><span class="p">)</span> +</span><span id="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 class="n">exp</span><span class="o">.</span><span class="n">TimeToStr</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"STRFTIME"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span><span class="n">e</span><span class="p">)),</span> +</span><span id="DuckDB-513"><a href="#DuckDB-513"><span class="linenos">513</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeToUnix</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"EPOCH"</span><span class="p">),</span> +</span><span id="DuckDB-514"><a href="#DuckDB-514"><span class="linenos">514</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDiToDi</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> +</span><span id="DuckDB-515"><a href="#DuckDB-515"><span class="linenos">515</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"CAST(SUBSTR(REPLACE(CAST(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS TEXT), '-', ''), 1, 8) AS INT)"</span><span class="p">,</span> +</span><span id="DuckDB-516"><a href="#DuckDB-516"><span class="linenos">516</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsAdd</span><span class="p">:</span> <span class="n">_date_delta_sql</span><span class="p">,</span> +</span><span id="DuckDB-517"><a href="#DuckDB-517"><span class="linenos">517</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsDiff</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> +</span><span id="DuckDB-518"><a href="#DuckDB-518"><span class="linenos">518</span></a> <span class="s2">"DATE_DIFF"</span><span class="p">,</span> +</span><span id="DuckDB-519"><a href="#DuckDB-519"><span class="linenos">519</span></a> <span class="sa">f</span><span class="s2">"'</span><span class="si">{</span><span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'unit'</span><span class="p">)</span><span class="w"> </span><span class="ow">or</span><span class="w"> </span><span class="s1">'DAY'</span><span class="si">}</span><span class="s2">'"</span><span class="p">,</span> +</span><span id="DuckDB-520"><a href="#DuckDB-520"><span class="linenos">520</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMP</span><span class="p">),</span> +</span><span id="DuckDB-521"><a href="#DuckDB-521"><span class="linenos">521</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMP</span><span class="p">),</span> +</span><span id="DuckDB-522"><a href="#DuckDB-522"><span class="linenos">522</span></a> <span class="p">),</span> +</span><span id="DuckDB-523"><a href="#DuckDB-523"><span class="linenos">523</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToStr</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> +</span><span id="DuckDB-524"><a href="#DuckDB-524"><span class="linenos">524</span></a> <span class="s2">"STRFTIME"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"TO_TIMESTAMP"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">),</span> <span class="bp">self</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> +</span><span id="DuckDB-525"><a href="#DuckDB-525"><span class="linenos">525</span></a> <span class="p">),</span> +</span><span id="DuckDB-526"><a href="#DuckDB-526"><span class="linenos">526</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToTime</span><span class="p">:</span> <span class="n">_unix_to_time_sql</span><span class="p">,</span> +</span><span id="DuckDB-527"><a href="#DuckDB-527"><span class="linenos">527</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToTimeStr</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"CAST(TO_TIMESTAMP(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">) AS TEXT)"</span><span class="p">,</span> +</span><span id="DuckDB-528"><a href="#DuckDB-528"><span class="linenos">528</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VariancePop</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"VAR_POP"</span><span class="p">),</span> +</span><span id="DuckDB-529"><a href="#DuckDB-529"><span class="linenos">529</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">WeekOfYear</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"WEEKOFYEAR"</span><span class="p">),</span> +</span><span id="DuckDB-530"><a href="#DuckDB-530"><span class="linenos">530</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Xor</span><span class="p">:</span> <span class="n">bool_xor_sql</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="n">SUPPORTED_JSON_PATH_PARTS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="DuckDB-534"><a href="#DuckDB-534"><span class="linenos">534</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONPathKey</span><span class="p">,</span> +</span><span id="DuckDB-535"><a href="#DuckDB-535"><span class="linenos">535</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONPathRoot</span><span class="p">,</span> +</span><span id="DuckDB-536"><a href="#DuckDB-536"><span class="linenos">536</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONPathSubscript</span><span class="p">,</span> +</span><span id="DuckDB-537"><a href="#DuckDB-537"><span class="linenos">537</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONPathWildcard</span><span class="p">,</span> +</span><span id="DuckDB-538"><a href="#DuckDB-538"><span class="linenos">538</span></a> <span class="p">}</span> +</span><span id="DuckDB-539"><a href="#DuckDB-539"><span class="linenos">539</span></a> +</span><span id="DuckDB-540"><a href="#DuckDB-540"><span class="linenos">540</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="DuckDB-541"><a href="#DuckDB-541"><span class="linenos">541</span></a> <span class="o">**</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">TYPE_MAPPING</span><span class="p">,</span> +</span><span id="DuckDB-542"><a href="#DuckDB-542"><span class="linenos">542</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">BINARY</span><span class="p">:</span> <span class="s2">"BLOB"</span><span class="p">,</span> +</span><span id="DuckDB-543"><a href="#DuckDB-543"><span class="linenos">543</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">BPCHAR</span><span class="p">:</span> <span class="s2">"TEXT"</span><span class="p">,</span> +</span><span id="DuckDB-544"><a href="#DuckDB-544"><span class="linenos">544</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">CHAR</span><span class="p">:</span> <span class="s2">"TEXT"</span><span class="p">,</span> +</span><span id="DuckDB-545"><a href="#DuckDB-545"><span class="linenos">545</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">FLOAT</span><span class="p">:</span> <span class="s2">"REAL"</span><span class="p">,</span> +</span><span id="DuckDB-546"><a href="#DuckDB-546"><span class="linenos">546</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">NCHAR</span><span class="p">:</span> <span class="s2">"TEXT"</span><span class="p">,</span> +</span><span id="DuckDB-547"><a href="#DuckDB-547"><span class="linenos">547</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">NVARCHAR</span><span class="p">:</span> <span class="s2">"TEXT"</span><span class="p">,</span> +</span><span id="DuckDB-548"><a href="#DuckDB-548"><span class="linenos">548</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">UINT</span><span class="p">:</span> <span class="s2">"UINTEGER"</span><span class="p">,</span> +</span><span id="DuckDB-549"><a href="#DuckDB-549"><span class="linenos">549</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-550"><a href="#DuckDB-550"><span class="linenos">550</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-551"><a href="#DuckDB-551"><span class="linenos">551</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-552"><a href="#DuckDB-552"><span class="linenos">552</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-553"><a href="#DuckDB-553"><span class="linenos">553</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-554"><a href="#DuckDB-554"><span class="linenos">554</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-555"><a href="#DuckDB-555"><span class="linenos">555</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-556"><a href="#DuckDB-556"><span class="linenos">556</span></a> <span class="p">}</span> +</span><span id="DuckDB-557"><a href="#DuckDB-557"><span class="linenos">557</span></a> +</span><span id="DuckDB-558"><a href="#DuckDB-558"><span class="linenos">558</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-559"><a href="#DuckDB-559"><span class="linenos">559</span></a> <span class="n">RESERVED_KEYWORDS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="DuckDB-560"><a href="#DuckDB-560"><span class="linenos">560</span></a> <span class="s2">"array"</span><span class="p">,</span> +</span><span id="DuckDB-561"><a href="#DuckDB-561"><span class="linenos">561</span></a> <span class="s2">"analyse"</span><span class="p">,</span> +</span><span id="DuckDB-562"><a href="#DuckDB-562"><span class="linenos">562</span></a> <span class="s2">"union"</span><span class="p">,</span> +</span><span id="DuckDB-563"><a href="#DuckDB-563"><span class="linenos">563</span></a> <span class="s2">"all"</span><span class="p">,</span> +</span><span id="DuckDB-564"><a href="#DuckDB-564"><span class="linenos">564</span></a> <span class="s2">"when"</span><span class="p">,</span> +</span><span id="DuckDB-565"><a href="#DuckDB-565"><span class="linenos">565</span></a> <span class="s2">"in_p"</span><span class="p">,</span> +</span><span id="DuckDB-566"><a href="#DuckDB-566"><span class="linenos">566</span></a> <span class="s2">"default"</span><span class="p">,</span> +</span><span id="DuckDB-567"><a href="#DuckDB-567"><span class="linenos">567</span></a> <span class="s2">"create_p"</span><span class="p">,</span> +</span><span id="DuckDB-568"><a href="#DuckDB-568"><span class="linenos">568</span></a> <span class="s2">"window"</span><span class="p">,</span> +</span><span id="DuckDB-569"><a href="#DuckDB-569"><span class="linenos">569</span></a> <span class="s2">"asymmetric"</span><span class="p">,</span> +</span><span id="DuckDB-570"><a href="#DuckDB-570"><span class="linenos">570</span></a> <span class="s2">"to"</span><span class="p">,</span> +</span><span id="DuckDB-571"><a href="#DuckDB-571"><span class="linenos">571</span></a> <span class="s2">"else"</span><span class="p">,</span> +</span><span id="DuckDB-572"><a href="#DuckDB-572"><span class="linenos">572</span></a> <span class="s2">"localtime"</span><span class="p">,</span> +</span><span id="DuckDB-573"><a href="#DuckDB-573"><span class="linenos">573</span></a> <span class="s2">"from"</span><span class="p">,</span> +</span><span id="DuckDB-574"><a href="#DuckDB-574"><span class="linenos">574</span></a> <span class="s2">"end_p"</span><span class="p">,</span> +</span><span id="DuckDB-575"><a href="#DuckDB-575"><span class="linenos">575</span></a> <span class="s2">"select"</span><span class="p">,</span> +</span><span id="DuckDB-576"><a href="#DuckDB-576"><span class="linenos">576</span></a> <span class="s2">"current_date"</span><span class="p">,</span> +</span><span id="DuckDB-577"><a href="#DuckDB-577"><span class="linenos">577</span></a> <span class="s2">"foreign"</span><span class="p">,</span> +</span><span id="DuckDB-578"><a href="#DuckDB-578"><span class="linenos">578</span></a> <span class="s2">"with"</span><span class="p">,</span> +</span><span id="DuckDB-579"><a href="#DuckDB-579"><span class="linenos">579</span></a> <span class="s2">"grant"</span><span class="p">,</span> +</span><span id="DuckDB-580"><a href="#DuckDB-580"><span class="linenos">580</span></a> <span class="s2">"session_user"</span><span class="p">,</span> +</span><span id="DuckDB-581"><a href="#DuckDB-581"><span class="linenos">581</span></a> <span class="s2">"or"</span><span class="p">,</span> +</span><span id="DuckDB-582"><a href="#DuckDB-582"><span class="linenos">582</span></a> <span class="s2">"except"</span><span class="p">,</span> +</span><span id="DuckDB-583"><a href="#DuckDB-583"><span class="linenos">583</span></a> <span class="s2">"references"</span><span class="p">,</span> +</span><span id="DuckDB-584"><a href="#DuckDB-584"><span class="linenos">584</span></a> <span class="s2">"fetch"</span><span class="p">,</span> +</span><span id="DuckDB-585"><a href="#DuckDB-585"><span class="linenos">585</span></a> <span class="s2">"limit"</span><span class="p">,</span> +</span><span id="DuckDB-586"><a href="#DuckDB-586"><span class="linenos">586</span></a> <span class="s2">"group_p"</span><span class="p">,</span> +</span><span id="DuckDB-587"><a href="#DuckDB-587"><span class="linenos">587</span></a> <span class="s2">"leading"</span><span class="p">,</span> +</span><span id="DuckDB-588"><a href="#DuckDB-588"><span class="linenos">588</span></a> <span class="s2">"into"</span><span class="p">,</span> +</span><span id="DuckDB-589"><a href="#DuckDB-589"><span class="linenos">589</span></a> <span class="s2">"collate"</span><span class="p">,</span> +</span><span id="DuckDB-590"><a href="#DuckDB-590"><span class="linenos">590</span></a> <span class="s2">"offset"</span><span class="p">,</span> +</span><span id="DuckDB-591"><a href="#DuckDB-591"><span class="linenos">591</span></a> <span class="s2">"do"</span><span class="p">,</span> +</span><span id="DuckDB-592"><a href="#DuckDB-592"><span class="linenos">592</span></a> <span class="s2">"then"</span><span class="p">,</span> +</span><span id="DuckDB-593"><a href="#DuckDB-593"><span class="linenos">593</span></a> <span class="s2">"localtimestamp"</span><span class="p">,</span> +</span><span id="DuckDB-594"><a href="#DuckDB-594"><span class="linenos">594</span></a> <span class="s2">"check_p"</span><span class="p">,</span> +</span><span id="DuckDB-595"><a href="#DuckDB-595"><span class="linenos">595</span></a> <span class="s2">"lateral_p"</span><span class="p">,</span> +</span><span id="DuckDB-596"><a href="#DuckDB-596"><span class="linenos">596</span></a> <span class="s2">"current_role"</span><span class="p">,</span> +</span><span id="DuckDB-597"><a href="#DuckDB-597"><span class="linenos">597</span></a> <span class="s2">"where"</span><span class="p">,</span> +</span><span id="DuckDB-598"><a href="#DuckDB-598"><span class="linenos">598</span></a> <span class="s2">"asc_p"</span><span class="p">,</span> +</span><span id="DuckDB-599"><a href="#DuckDB-599"><span class="linenos">599</span></a> <span class="s2">"placing"</span><span class="p">,</span> +</span><span id="DuckDB-600"><a href="#DuckDB-600"><span class="linenos">600</span></a> <span class="s2">"desc_p"</span><span class="p">,</span> +</span><span id="DuckDB-601"><a href="#DuckDB-601"><span class="linenos">601</span></a> <span class="s2">"user"</span><span class="p">,</span> +</span><span id="DuckDB-602"><a href="#DuckDB-602"><span class="linenos">602</span></a> <span class="s2">"unique"</span><span class="p">,</span> +</span><span id="DuckDB-603"><a href="#DuckDB-603"><span class="linenos">603</span></a> <span class="s2">"initially"</span><span class="p">,</span> +</span><span id="DuckDB-604"><a href="#DuckDB-604"><span class="linenos">604</span></a> <span class="s2">"column"</span><span class="p">,</span> +</span><span id="DuckDB-605"><a href="#DuckDB-605"><span class="linenos">605</span></a> <span class="s2">"both"</span><span class="p">,</span> +</span><span id="DuckDB-606"><a href="#DuckDB-606"><span class="linenos">606</span></a> <span class="s2">"some"</span><span class="p">,</span> +</span><span id="DuckDB-607"><a href="#DuckDB-607"><span class="linenos">607</span></a> <span class="s2">"as"</span><span class="p">,</span> +</span><span id="DuckDB-608"><a href="#DuckDB-608"><span class="linenos">608</span></a> <span class="s2">"any"</span><span class="p">,</span> +</span><span id="DuckDB-609"><a href="#DuckDB-609"><span class="linenos">609</span></a> <span class="s2">"only"</span><span class="p">,</span> +</span><span id="DuckDB-610"><a href="#DuckDB-610"><span class="linenos">610</span></a> <span class="s2">"deferrable"</span><span class="p">,</span> +</span><span id="DuckDB-611"><a href="#DuckDB-611"><span class="linenos">611</span></a> <span class="s2">"null_p"</span><span class="p">,</span> +</span><span id="DuckDB-612"><a href="#DuckDB-612"><span class="linenos">612</span></a> <span class="s2">"current_time"</span><span class="p">,</span> +</span><span id="DuckDB-613"><a href="#DuckDB-613"><span class="linenos">613</span></a> <span class="s2">"true_p"</span><span class="p">,</span> +</span><span id="DuckDB-614"><a href="#DuckDB-614"><span class="linenos">614</span></a> <span class="s2">"table"</span><span class="p">,</span> +</span><span id="DuckDB-615"><a href="#DuckDB-615"><span class="linenos">615</span></a> <span class="s2">"case"</span><span class="p">,</span> +</span><span id="DuckDB-616"><a href="#DuckDB-616"><span class="linenos">616</span></a> <span class="s2">"trailing"</span><span class="p">,</span> +</span><span id="DuckDB-617"><a href="#DuckDB-617"><span class="linenos">617</span></a> <span class="s2">"variadic"</span><span class="p">,</span> +</span><span id="DuckDB-618"><a href="#DuckDB-618"><span class="linenos">618</span></a> <span class="s2">"for"</span><span class="p">,</span> +</span><span id="DuckDB-619"><a href="#DuckDB-619"><span class="linenos">619</span></a> <span class="s2">"on"</span><span class="p">,</span> +</span><span id="DuckDB-620"><a href="#DuckDB-620"><span class="linenos">620</span></a> <span class="s2">"distinct"</span><span class="p">,</span> +</span><span id="DuckDB-621"><a href="#DuckDB-621"><span class="linenos">621</span></a> <span class="s2">"false_p"</span><span class="p">,</span> +</span><span id="DuckDB-622"><a href="#DuckDB-622"><span class="linenos">622</span></a> <span class="s2">"not"</span><span class="p">,</span> +</span><span id="DuckDB-623"><a href="#DuckDB-623"><span class="linenos">623</span></a> <span class="s2">"constraint"</span><span class="p">,</span> +</span><span id="DuckDB-624"><a href="#DuckDB-624"><span class="linenos">624</span></a> <span class="s2">"current_timestamp"</span><span class="p">,</span> +</span><span id="DuckDB-625"><a href="#DuckDB-625"><span class="linenos">625</span></a> <span class="s2">"returning"</span><span class="p">,</span> +</span><span id="DuckDB-626"><a href="#DuckDB-626"><span class="linenos">626</span></a> <span class="s2">"primary"</span><span class="p">,</span> +</span><span id="DuckDB-627"><a href="#DuckDB-627"><span class="linenos">627</span></a> <span class="s2">"intersect"</span><span class="p">,</span> +</span><span id="DuckDB-628"><a href="#DuckDB-628"><span class="linenos">628</span></a> <span class="s2">"having"</span><span class="p">,</span> +</span><span id="DuckDB-629"><a href="#DuckDB-629"><span class="linenos">629</span></a> <span class="s2">"analyze"</span><span class="p">,</span> +</span><span id="DuckDB-630"><a href="#DuckDB-630"><span class="linenos">630</span></a> <span class="s2">"current_user"</span><span class="p">,</span> +</span><span id="DuckDB-631"><a href="#DuckDB-631"><span class="linenos">631</span></a> <span class="s2">"and"</span><span class="p">,</span> +</span><span id="DuckDB-632"><a href="#DuckDB-632"><span class="linenos">632</span></a> <span class="s2">"cast"</span><span class="p">,</span> +</span><span id="DuckDB-633"><a href="#DuckDB-633"><span class="linenos">633</span></a> <span class="s2">"symmetric"</span><span class="p">,</span> +</span><span id="DuckDB-634"><a href="#DuckDB-634"><span class="linenos">634</span></a> <span class="s2">"using"</span><span class="p">,</span> +</span><span id="DuckDB-635"><a href="#DuckDB-635"><span class="linenos">635</span></a> <span class="s2">"order"</span><span class="p">,</span> +</span><span id="DuckDB-636"><a href="#DuckDB-636"><span class="linenos">636</span></a> <span class="s2">"current_catalog"</span><span class="p">,</span> +</span><span id="DuckDB-637"><a href="#DuckDB-637"><span class="linenos">637</span></a> <span class="p">}</span> +</span><span id="DuckDB-638"><a href="#DuckDB-638"><span class="linenos">638</span></a> +</span><span id="DuckDB-639"><a href="#DuckDB-639"><span class="linenos">639</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-640"><a href="#DuckDB-640"><span class="linenos">640</span></a> +</span><span id="DuckDB-641"><a href="#DuckDB-641"><span class="linenos">641</span></a> <span class="c1"># DuckDB doesn't generally support CREATE TABLE .. properties</span> +</span><span id="DuckDB-642"><a href="#DuckDB-642"><span class="linenos">642</span></a> <span class="c1"># https://duckdb.org/docs/sql/statements/create_table.html</span> +</span><span id="DuckDB-643"><a href="#DuckDB-643"><span class="linenos">643</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="DuckDB-644"><a href="#DuckDB-644"><span class="linenos">644</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-645"><a href="#DuckDB-645"><span class="linenos">645</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-646"><a href="#DuckDB-646"><span class="linenos">646</span></a> <span class="p">}</span> </span><span id="DuckDB-647"><a href="#DuckDB-647"><span class="linenos">647</span></a> -</span><span id="DuckDB-648"><a href="#DuckDB-648"><span class="linenos">648</span></a> <span class="k">def</span> <span class="nf">strtotime_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">StrToTime</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="DuckDB-649"><a href="#DuckDB-649"><span class="linenos">649</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">"safe"</span><span class="p">):</span> -</span><span id="DuckDB-650"><a href="#DuckDB-650"><span class="linenos">650</span></a> <span class="n">formatted_time</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="DuckDB-651"><a href="#DuckDB-651"><span class="linenos">651</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CAST(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s1">'TRY_STRPTIME'</span><span class="p">,</span><span class="w"> </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">formatted_time</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS TIMESTAMP)"</span> -</span><span id="DuckDB-652"><a href="#DuckDB-652"><span class="linenos">652</span></a> <span class="k">return</span> <span class="n">str_to_time_sql</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-648"><a href="#DuckDB-648"><span class="linenos">648</span></a> <span class="c1"># There are a few exceptions (e.g. temporary tables) which are supported or</span> +</span><span id="DuckDB-649"><a href="#DuckDB-649"><span class="linenos">649</span></a> <span class="c1"># can be transpiled to DuckDB, so we explicitly override them accordingly</span> +</span><span id="DuckDB-650"><a href="#DuckDB-650"><span class="linenos">650</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-651"><a href="#DuckDB-651"><span class="linenos">651</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-652"><a href="#DuckDB-652"><span class="linenos">652</span></a> <span class="n">PROPERTIES_LOCATION</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">ReturnsProperty</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_ALIAS</span> </span><span id="DuckDB-653"><a href="#DuckDB-653"><span class="linenos">653</span></a> -</span><span id="DuckDB-654"><a href="#DuckDB-654"><span class="linenos">654</span></a> <span class="k">def</span> <span class="nf">strtodate_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">StrToDate</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="DuckDB-654"><a href="#DuckDB-654"><span class="linenos">654</span></a> <span class="k">def</span> <span class="nf">strtotime_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">StrToTime</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> </span><span id="DuckDB-655"><a href="#DuckDB-655"><span class="linenos">655</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">"safe"</span><span class="p">):</span> </span><span id="DuckDB-656"><a href="#DuckDB-656"><span class="linenos">656</span></a> <span class="n">formatted_time</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="DuckDB-657"><a href="#DuckDB-657"><span class="linenos">657</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CAST(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s1">'TRY_STRPTIME'</span><span class="p">,</span><span class="w"> </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">formatted_time</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS DATE)"</span> -</span><span id="DuckDB-658"><a href="#DuckDB-658"><span class="linenos">658</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CAST(</span><span class="si">{</span><span class="n">str_to_time_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="w"> </span><span class="n">expression</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS DATE)"</span> +</span><span id="DuckDB-657"><a href="#DuckDB-657"><span class="linenos">657</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CAST(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s1">'TRY_STRPTIME'</span><span class="p">,</span><span class="w"> </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">formatted_time</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS TIMESTAMP)"</span> +</span><span id="DuckDB-658"><a href="#DuckDB-658"><span class="linenos">658</span></a> <span class="k">return</span> <span class="n">str_to_time_sql</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-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">def</span> <span class="nf">parsejson_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ParseJSON</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="DuckDB-661"><a href="#DuckDB-661"><span class="linenos">661</span></a> <span class="n">arg</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> -</span><span id="DuckDB-662"><a href="#DuckDB-662"><span class="linenos">662</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">"safe"</span><span class="p">):</span> -</span><span id="DuckDB-663"><a href="#DuckDB-663"><span class="linenos">663</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">case</span><span class="p">()</span><span class="o">.</span><span class="n">when</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"json_valid"</span><span class="p">,</span> <span class="n">arg</span><span class="p">),</span> <span class="n">arg</span><span class="p">)</span><span class="o">.</span><span class="n">else_</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">null</span><span class="p">()))</span> -</span><span id="DuckDB-664"><a href="#DuckDB-664"><span class="linenos">664</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"JSON"</span><span class="p">,</span> <span class="n">arg</span><span class="p">)</span> +</span><span id="DuckDB-660"><a href="#DuckDB-660"><span class="linenos">660</span></a> <span class="k">def</span> <span class="nf">strtodate_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">StrToDate</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="DuckDB-661"><a href="#DuckDB-661"><span class="linenos">661</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">"safe"</span><span class="p">):</span> +</span><span id="DuckDB-662"><a href="#DuckDB-662"><span class="linenos">662</span></a> <span class="n">formatted_time</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="DuckDB-663"><a href="#DuckDB-663"><span class="linenos">663</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CAST(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s1">'TRY_STRPTIME'</span><span class="p">,</span><span class="w"> </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">formatted_time</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS DATE)"</span> +</span><span id="DuckDB-664"><a href="#DuckDB-664"><span class="linenos">664</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CAST(</span><span class="si">{</span><span class="n">str_to_time_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="w"> </span><span class="n">expression</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS DATE)"</span> </span><span id="DuckDB-665"><a href="#DuckDB-665"><span class="linenos">665</span></a> -</span><span id="DuckDB-666"><a href="#DuckDB-666"><span class="linenos">666</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-667"><a href="#DuckDB-667"><span class="linenos">667</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-668"><a href="#DuckDB-668"><span class="linenos">668</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-669"><a href="#DuckDB-669"><span class="linenos">669</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> -</span><span id="DuckDB-670"><a href="#DuckDB-670"><span class="linenos">670</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-671"><a href="#DuckDB-671"><span class="linenos">671</span></a> <span class="p">)</span> -</span><span id="DuckDB-672"><a href="#DuckDB-672"><span class="linenos">672</span></a> -</span><span id="DuckDB-673"><a href="#DuckDB-673"><span class="linenos">673</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-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">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-676"><a href="#DuckDB-676"><span class="linenos">676</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-677"><a href="#DuckDB-677"><span class="linenos">677</span></a> -</span><span id="DuckDB-678"><a href="#DuckDB-678"><span class="linenos">678</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-679"><a href="#DuckDB-679"><span class="linenos">679</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-680"><a href="#DuckDB-680"><span class="linenos">680</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-681"><a href="#DuckDB-681"><span class="linenos">681</span></a> -</span><span id="DuckDB-682"><a href="#DuckDB-682"><span class="linenos">682</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-683"><a href="#DuckDB-683"><span class="linenos">683</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-684"><a href="#DuckDB-684"><span class="linenos">684</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-685"><a href="#DuckDB-685"><span class="linenos">685</span></a> -</span><span id="DuckDB-686"><a href="#DuckDB-686"><span class="linenos">686</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-687"><a href="#DuckDB-687"><span class="linenos">687</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-688"><a href="#DuckDB-688"><span class="linenos">688</span></a> -</span><span id="DuckDB-689"><a href="#DuckDB-689"><span class="linenos">689</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-690"><a href="#DuckDB-690"><span class="linenos">690</span></a> -</span><span id="DuckDB-691"><a href="#DuckDB-691"><span class="linenos">691</span></a> <span class="k">def</span> <span class="nf">tablesample_sql</span><span class="p">(</span> -</span><span id="DuckDB-692"><a href="#DuckDB-692"><span class="linenos">692</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="DuckDB-693"><a href="#DuckDB-693"><span class="linenos">693</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-694"><a href="#DuckDB-694"><span class="linenos">694</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-695"><a href="#DuckDB-695"><span class="linenos">695</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-696"><a href="#DuckDB-696"><span class="linenos">696</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="DuckDB-697"><a href="#DuckDB-697"><span class="linenos">697</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-698"><a href="#DuckDB-698"><span class="linenos">698</span></a> <span class="c1"># This sample clause only applies to a single source, not the entire resulting relation</span> -</span><span id="DuckDB-699"><a href="#DuckDB-699"><span class="linenos">699</span></a> <span class="n">tablesample_keyword</span> <span class="o">=</span> <span class="s2">"TABLESAMPLE"</span> -</span><span id="DuckDB-700"><a href="#DuckDB-700"><span class="linenos">700</span></a> -</span><span id="DuckDB-701"><a href="#DuckDB-701"><span class="linenos">701</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-702"><a href="#DuckDB-702"><span class="linenos">702</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-703"><a href="#DuckDB-703"><span class="linenos">703</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-704"><a href="#DuckDB-704"><span class="linenos">704</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span> -</span><span id="DuckDB-705"><a href="#DuckDB-705"><span class="linenos">705</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-706"><a href="#DuckDB-706"><span class="linenos">706</span></a> <span class="s2">"defaulting to reservoir sampling"</span> -</span><span id="DuckDB-707"><a href="#DuckDB-707"><span class="linenos">707</span></a> <span class="p">)</span> -</span><span id="DuckDB-708"><a href="#DuckDB-708"><span class="linenos">708</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-709"><a href="#DuckDB-709"><span class="linenos">709</span></a> -</span><span id="DuckDB-710"><a href="#DuckDB-710"><span class="linenos">710</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-711"><a href="#DuckDB-711"><span class="linenos">711</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-712"><a href="#DuckDB-712"><span class="linenos">712</span></a> <span class="p">)</span> -</span><span id="DuckDB-713"><a href="#DuckDB-713"><span class="linenos">713</span></a> -</span><span id="DuckDB-714"><a href="#DuckDB-714"><span class="linenos">714</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-715"><a href="#DuckDB-715"><span class="linenos">715</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-716"><a href="#DuckDB-716"><span class="linenos">716</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-717"><a href="#DuckDB-717"><span class="linenos">717</span></a> -</span><span id="DuckDB-718"><a href="#DuckDB-718"><span class="linenos">718</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-719"><a href="#DuckDB-719"><span class="linenos">719</span></a> <span class="n">multiplier</span> <span class="o">=</span> <span class="mi">7</span> -</span><span id="DuckDB-720"><a href="#DuckDB-720"><span class="linenos">720</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-721"><a href="#DuckDB-721"><span class="linenos">721</span></a> <span class="n">multiplier</span> <span class="o">=</span> <span class="mi">90</span> -</span><span id="DuckDB-722"><a href="#DuckDB-722"><span class="linenos">722</span></a> -</span><span id="DuckDB-723"><a href="#DuckDB-723"><span class="linenos">723</span></a> <span class="k">if</span> <span class="n">multiplier</span><span class="p">:</span> -</span><span id="DuckDB-724"><a href="#DuckDB-724"><span class="linenos">724</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-725"><a href="#DuckDB-725"><span class="linenos">725</span></a> -</span><span id="DuckDB-726"><a href="#DuckDB-726"><span class="linenos">726</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-727"><a href="#DuckDB-727"><span class="linenos">727</span></a> -</span><span id="DuckDB-728"><a href="#DuckDB-728"><span class="linenos">728</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-729"><a href="#DuckDB-729"><span class="linenos">729</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-730"><a href="#DuckDB-730"><span class="linenos">730</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-731"><a href="#DuckDB-731"><span class="linenos">731</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-732"><a href="#DuckDB-732"><span class="linenos">732</span></a> -</span><span id="DuckDB-733"><a href="#DuckDB-733"><span class="linenos">733</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-734"><a href="#DuckDB-734"><span class="linenos">734</span></a> <span class="k">if</span> <span class="p">(</span> -</span><span id="DuckDB-735"><a href="#DuckDB-735"><span class="linenos">735</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-736"><a href="#DuckDB-736"><span class="linenos">736</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-737"><a href="#DuckDB-737"><span class="linenos">737</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-738"><a href="#DuckDB-738"><span class="linenos">738</span></a> <span class="p">):</span> -</span><span id="DuckDB-739"><a href="#DuckDB-739"><span class="linenos">739</span></a> <span class="c1"># Some dialects support `LEFT JOIN UNNEST(...)` without an explicit ON clause</span> -</span><span id="DuckDB-740"><a href="#DuckDB-740"><span class="linenos">740</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-741"><a href="#DuckDB-741"><span class="linenos">741</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-742"><a href="#DuckDB-742"><span class="linenos">742</span></a> -</span><span id="DuckDB-743"><a href="#DuckDB-743"><span class="linenos">743</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-744"><a href="#DuckDB-744"><span class="linenos">744</span></a> -</span><span id="DuckDB-745"><a href="#DuckDB-745"><span class="linenos">745</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-746"><a href="#DuckDB-746"><span class="linenos">746</span></a> <span class="c1"># GENERATE_SERIES(a, b) -> [a, b], RANGE(a, b) -> [a, b)</span> -</span><span id="DuckDB-747"><a href="#DuckDB-747"><span class="linenos">747</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-748"><a href="#DuckDB-748"><span class="linenos">748</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-749"><a href="#DuckDB-749"><span class="linenos">749</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-666"><a href="#DuckDB-666"><span class="linenos">666</span></a> <span class="k">def</span> <span class="nf">parsejson_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ParseJSON</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="DuckDB-667"><a href="#DuckDB-667"><span class="linenos">667</span></a> <span class="n">arg</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> +</span><span id="DuckDB-668"><a href="#DuckDB-668"><span class="linenos">668</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">"safe"</span><span class="p">):</span> +</span><span id="DuckDB-669"><a href="#DuckDB-669"><span class="linenos">669</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">case</span><span class="p">()</span><span class="o">.</span><span class="n">when</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"json_valid"</span><span class="p">,</span> <span class="n">arg</span><span class="p">),</span> <span class="n">arg</span><span class="p">)</span><span class="o">.</span><span class="n">else_</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">null</span><span class="p">()))</span> +</span><span id="DuckDB-670"><a href="#DuckDB-670"><span class="linenos">670</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"JSON"</span><span class="p">,</span> <span class="n">arg</span><span class="p">)</span> +</span><span id="DuckDB-671"><a href="#DuckDB-671"><span class="linenos">671</span></a> +</span><span id="DuckDB-672"><a href="#DuckDB-672"><span class="linenos">672</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-673"><a href="#DuckDB-673"><span class="linenos">673</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-674"><a href="#DuckDB-674"><span class="linenos">674</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-675"><a href="#DuckDB-675"><span class="linenos">675</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> +</span><span id="DuckDB-676"><a href="#DuckDB-676"><span class="linenos">676</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-677"><a href="#DuckDB-677"><span class="linenos">677</span></a> <span class="p">)</span> +</span><span id="DuckDB-678"><a href="#DuckDB-678"><span class="linenos">678</span></a> +</span><span id="DuckDB-679"><a href="#DuckDB-679"><span class="linenos">679</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-680"><a href="#DuckDB-680"><span class="linenos">680</span></a> +</span><span id="DuckDB-681"><a href="#DuckDB-681"><span class="linenos">681</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-682"><a href="#DuckDB-682"><span class="linenos">682</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-683"><a href="#DuckDB-683"><span class="linenos">683</span></a> +</span><span id="DuckDB-684"><a href="#DuckDB-684"><span class="linenos">684</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-685"><a href="#DuckDB-685"><span class="linenos">685</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-686"><a href="#DuckDB-686"><span class="linenos">686</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-687"><a href="#DuckDB-687"><span class="linenos">687</span></a> +</span><span id="DuckDB-688"><a href="#DuckDB-688"><span class="linenos">688</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-689"><a href="#DuckDB-689"><span class="linenos">689</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-690"><a href="#DuckDB-690"><span class="linenos">690</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-691"><a href="#DuckDB-691"><span class="linenos">691</span></a> +</span><span id="DuckDB-692"><a href="#DuckDB-692"><span class="linenos">692</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-693"><a href="#DuckDB-693"><span class="linenos">693</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-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">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-696"><a href="#DuckDB-696"><span class="linenos">696</span></a> +</span><span id="DuckDB-697"><a href="#DuckDB-697"><span class="linenos">697</span></a> <span class="k">def</span> <span class="nf">tablesample_sql</span><span class="p">(</span> +</span><span id="DuckDB-698"><a href="#DuckDB-698"><span class="linenos">698</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="DuckDB-699"><a href="#DuckDB-699"><span class="linenos">699</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-700"><a href="#DuckDB-700"><span class="linenos">700</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-701"><a href="#DuckDB-701"><span class="linenos">701</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-702"><a href="#DuckDB-702"><span class="linenos">702</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</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="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-704"><a href="#DuckDB-704"><span class="linenos">704</span></a> <span class="c1"># This sample clause only applies to a single source, not the entire resulting relation</span> +</span><span id="DuckDB-705"><a href="#DuckDB-705"><span class="linenos">705</span></a> <span class="n">tablesample_keyword</span> <span class="o">=</span> <span class="s2">"TABLESAMPLE"</span> +</span><span id="DuckDB-706"><a href="#DuckDB-706"><span class="linenos">706</span></a> +</span><span id="DuckDB-707"><a href="#DuckDB-707"><span class="linenos">707</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-708"><a href="#DuckDB-708"><span class="linenos">708</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-709"><a href="#DuckDB-709"><span class="linenos">709</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-710"><a href="#DuckDB-710"><span class="linenos">710</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span> +</span><span id="DuckDB-711"><a href="#DuckDB-711"><span class="linenos">711</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-712"><a href="#DuckDB-712"><span class="linenos">712</span></a> <span class="s2">"defaulting to reservoir sampling"</span> +</span><span id="DuckDB-713"><a href="#DuckDB-713"><span class="linenos">713</span></a> <span class="p">)</span> +</span><span id="DuckDB-714"><a href="#DuckDB-714"><span class="linenos">714</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-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="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-717"><a href="#DuckDB-717"><span class="linenos">717</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-718"><a href="#DuckDB-718"><span class="linenos">718</span></a> <span class="p">)</span> +</span><span id="DuckDB-719"><a href="#DuckDB-719"><span class="linenos">719</span></a> +</span><span id="DuckDB-720"><a href="#DuckDB-720"><span class="linenos">720</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-721"><a href="#DuckDB-721"><span class="linenos">721</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-722"><a href="#DuckDB-722"><span class="linenos">722</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-723"><a href="#DuckDB-723"><span class="linenos">723</span></a> +</span><span id="DuckDB-724"><a href="#DuckDB-724"><span class="linenos">724</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-725"><a href="#DuckDB-725"><span class="linenos">725</span></a> <span class="n">multiplier</span> <span class="o">=</span> <span class="mi">7</span> +</span><span id="DuckDB-726"><a href="#DuckDB-726"><span class="linenos">726</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-727"><a href="#DuckDB-727"><span class="linenos">727</span></a> <span class="n">multiplier</span> <span class="o">=</span> <span class="mi">90</span> +</span><span id="DuckDB-728"><a href="#DuckDB-728"><span class="linenos">728</span></a> +</span><span id="DuckDB-729"><a href="#DuckDB-729"><span class="linenos">729</span></a> <span class="k">if</span> <span class="n">multiplier</span><span class="p">:</span> +</span><span id="DuckDB-730"><a href="#DuckDB-730"><span class="linenos">730</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-731"><a href="#DuckDB-731"><span class="linenos">731</span></a> +</span><span id="DuckDB-732"><a href="#DuckDB-732"><span class="linenos">732</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-733"><a href="#DuckDB-733"><span class="linenos">733</span></a> +</span><span id="DuckDB-734"><a href="#DuckDB-734"><span class="linenos">734</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-735"><a href="#DuckDB-735"><span class="linenos">735</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-736"><a href="#DuckDB-736"><span class="linenos">736</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-737"><a href="#DuckDB-737"><span class="linenos">737</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-738"><a href="#DuckDB-738"><span class="linenos">738</span></a> +</span><span id="DuckDB-739"><a href="#DuckDB-739"><span class="linenos">739</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-740"><a href="#DuckDB-740"><span class="linenos">740</span></a> <span class="k">if</span> <span class="p">(</span> +</span><span id="DuckDB-741"><a href="#DuckDB-741"><span class="linenos">741</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-742"><a href="#DuckDB-742"><span class="linenos">742</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-743"><a href="#DuckDB-743"><span class="linenos">743</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-744"><a href="#DuckDB-744"><span class="linenos">744</span></a> <span class="p">):</span> +</span><span id="DuckDB-745"><a href="#DuckDB-745"><span class="linenos">745</span></a> <span class="c1"># Some dialects support `LEFT JOIN UNNEST(...)` without an explicit ON clause</span> +</span><span id="DuckDB-746"><a href="#DuckDB-746"><span class="linenos">746</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-747"><a href="#DuckDB-747"><span class="linenos">747</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-748"><a href="#DuckDB-748"><span class="linenos">748</span></a> +</span><span id="DuckDB-749"><a href="#DuckDB-749"><span class="linenos">749</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-750"><a href="#DuckDB-750"><span class="linenos">750</span></a> -</span><span id="DuckDB-751"><a href="#DuckDB-751"><span class="linenos">751</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-752"><a href="#DuckDB-752"><span class="linenos">752</span></a> -</span><span id="DuckDB-753"><a href="#DuckDB-753"><span class="linenos">753</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-754"><a href="#DuckDB-754"><span class="linenos">754</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-755"><a href="#DuckDB-755"><span class="linenos">755</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-756"><a href="#DuckDB-756"><span class="linenos">756</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-751"><a href="#DuckDB-751"><span class="linenos">751</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-752"><a href="#DuckDB-752"><span class="linenos">752</span></a> <span class="c1"># GENERATE_SERIES(a, b) -> [a, b], RANGE(a, b) -> [a, b)</span> +</span><span id="DuckDB-753"><a href="#DuckDB-753"><span class="linenos">753</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-754"><a href="#DuckDB-754"><span class="linenos">754</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-755"><a href="#DuckDB-755"><span class="linenos">755</span></a> +</span><span id="DuckDB-756"><a href="#DuckDB-756"><span class="linenos">756</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">function_fallback_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> </span><span id="DuckDB-757"><a href="#DuckDB-757"><span class="linenos">757</span></a> -</span><span id="DuckDB-758"><a href="#DuckDB-758"><span class="linenos">758</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-759"><a href="#DuckDB-759"><span class="linenos">759</span></a> -</span><span id="DuckDB-760"><a href="#DuckDB-760"><span class="linenos">760</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-761"><a href="#DuckDB-761"><span class="linenos">761</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-762"><a href="#DuckDB-762"><span class="linenos">762</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-763"><a href="#DuckDB-763"><span class="linenos">763</span></a> -</span><span id="DuckDB-764"><a href="#DuckDB-764"><span class="linenos">764</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-765"><a href="#DuckDB-765"><span class="linenos">765</span></a> -</span><span id="DuckDB-766"><a href="#DuckDB-766"><span class="linenos">766</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-767"><a href="#DuckDB-767"><span class="linenos">767</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-758"><a href="#DuckDB-758"><span class="linenos">758</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-759"><a href="#DuckDB-759"><span class="linenos">759</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-760"><a href="#DuckDB-760"><span class="linenos">760</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-761"><a href="#DuckDB-761"><span class="linenos">761</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-762"><a href="#DuckDB-762"><span class="linenos">762</span></a> +</span><span id="DuckDB-763"><a href="#DuckDB-763"><span class="linenos">763</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-764"><a href="#DuckDB-764"><span class="linenos">764</span></a> +</span><span id="DuckDB-765"><a href="#DuckDB-765"><span class="linenos">765</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-766"><a href="#DuckDB-766"><span class="linenos">766</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-767"><a href="#DuckDB-767"><span class="linenos">767</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-768"><a href="#DuckDB-768"><span class="linenos">768</span></a> -</span><span id="DuckDB-769"><a href="#DuckDB-769"><span class="linenos">769</span></a> <span class="k">return</span> <span class="n">bracket</span> +</span><span id="DuckDB-769"><a href="#DuckDB-769"><span class="linenos">769</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-770"><a href="#DuckDB-770"><span class="linenos">770</span></a> -</span><span id="DuckDB-771"><a href="#DuckDB-771"><span class="linenos">771</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-772"><a href="#DuckDB-772"><span class="linenos">772</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-771"><a href="#DuckDB-771"><span class="linenos">771</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-772"><a href="#DuckDB-772"><span class="linenos">772</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-773"><a href="#DuckDB-773"><span class="linenos">773</span></a> -</span><span id="DuckDB-774"><a href="#DuckDB-774"><span class="linenos">774</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-775"><a href="#DuckDB-775"><span class="linenos">775</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-776"><a href="#DuckDB-776"><span class="linenos">776</span></a> <span class="c1"># Make the order key the first arg and slide the fraction to the right</span> -</span><span id="DuckDB-777"><a href="#DuckDB-777"><span class="linenos">777</span></a> <span class="c1"># https://duckdb.org/docs/sql/aggregates#ordered-set-aggregate-functions</span> -</span><span id="DuckDB-778"><a href="#DuckDB-778"><span class="linenos">778</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-779"><a href="#DuckDB-779"><span class="linenos">779</span></a> <span class="k">if</span> <span class="n">order_col</span><span class="p">:</span> -</span><span id="DuckDB-780"><a href="#DuckDB-780"><span class="linenos">780</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-781"><a href="#DuckDB-781"><span class="linenos">781</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-782"><a href="#DuckDB-782"><span class="linenos">782</span></a> -</span><span id="DuckDB-783"><a href="#DuckDB-783"><span class="linenos">783</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</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-784"><a href="#DuckDB-784"><span class="linenos">784</span></a> -</span><span id="DuckDB-785"><a href="#DuckDB-785"><span class="linenos">785</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-786"><a href="#DuckDB-786"><span class="linenos">786</span></a> -</span><span id="DuckDB-787"><a href="#DuckDB-787"><span class="linenos">787</span></a> <span class="k">def</span> <span class="nf">length_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Length</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="DuckDB-788"><a href="#DuckDB-788"><span class="linenos">788</span></a> <span class="n">arg</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> +</span><span id="DuckDB-774"><a href="#DuckDB-774"><span class="linenos">774</span></a> <span class="k">return</span> <span class="n">bracket</span> +</span><span id="DuckDB-775"><a href="#DuckDB-775"><span class="linenos">775</span></a> +</span><span id="DuckDB-776"><a href="#DuckDB-776"><span class="linenos">776</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-777"><a href="#DuckDB-777"><span class="linenos">777</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-778"><a href="#DuckDB-778"><span class="linenos">778</span></a> +</span><span id="DuckDB-779"><a href="#DuckDB-779"><span class="linenos">779</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-780"><a href="#DuckDB-780"><span class="linenos">780</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-781"><a href="#DuckDB-781"><span class="linenos">781</span></a> <span class="c1"># Make the order key the first arg and slide the fraction to the right</span> +</span><span id="DuckDB-782"><a href="#DuckDB-782"><span class="linenos">782</span></a> <span class="c1"># https://duckdb.org/docs/sql/aggregates#ordered-set-aggregate-functions</span> +</span><span id="DuckDB-783"><a href="#DuckDB-783"><span class="linenos">783</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-784"><a href="#DuckDB-784"><span class="linenos">784</span></a> <span class="k">if</span> <span class="n">order_col</span><span class="p">:</span> +</span><span id="DuckDB-785"><a href="#DuckDB-785"><span class="linenos">785</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-786"><a href="#DuckDB-786"><span class="linenos">786</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-787"><a href="#DuckDB-787"><span class="linenos">787</span></a> +</span><span id="DuckDB-788"><a href="#DuckDB-788"><span class="linenos">788</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</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-789"><a href="#DuckDB-789"><span class="linenos">789</span></a> -</span><span id="DuckDB-790"><a href="#DuckDB-790"><span class="linenos">790</span></a> <span class="c1"># Dialects like BQ and Snowflake also accept binary values as args, so</span> -</span><span id="DuckDB-791"><a href="#DuckDB-791"><span class="linenos">791</span></a> <span class="c1"># DDB will attempt to infer the type or resort to case/when resolution</span> -</span><span id="DuckDB-792"><a href="#DuckDB-792"><span class="linenos">792</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">"binary"</span><span class="p">)</span> <span class="ow">or</span> <span class="n">arg</span><span class="o">.</span><span class="n">is_string</span><span class="p">:</span> -</span><span id="DuckDB-793"><a href="#DuckDB-793"><span class="linenos">793</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"LENGTH"</span><span class="p">,</span> <span class="n">arg</span><span class="p">)</span> +</span><span id="DuckDB-790"><a href="#DuckDB-790"><span class="linenos">790</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-791"><a href="#DuckDB-791"><span class="linenos">791</span></a> +</span><span id="DuckDB-792"><a href="#DuckDB-792"><span class="linenos">792</span></a> <span class="k">def</span> <span class="nf">length_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Length</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="DuckDB-793"><a href="#DuckDB-793"><span class="linenos">793</span></a> <span class="n">arg</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> </span><span id="DuckDB-794"><a href="#DuckDB-794"><span class="linenos">794</span></a> -</span><span id="DuckDB-795"><a href="#DuckDB-795"><span class="linenos">795</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">arg</span><span class="o">.</span><span class="n">type</span><span class="p">:</span> -</span><span id="DuckDB-796"><a href="#DuckDB-796"><span class="linenos">796</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-797"><a href="#DuckDB-797"><span class="linenos">797</span></a> -</span><span id="DuckDB-798"><a href="#DuckDB-798"><span class="linenos">798</span></a> <span class="n">arg</span> <span class="o">=</span> <span class="n">annotate_types</span><span class="p">(</span><span class="n">arg</span><span class="p">)</span> +</span><span id="DuckDB-795"><a href="#DuckDB-795"><span class="linenos">795</span></a> <span class="c1"># Dialects like BQ and Snowflake also accept binary values as args, so</span> +</span><span id="DuckDB-796"><a href="#DuckDB-796"><span class="linenos">796</span></a> <span class="c1"># DDB will attempt to infer the type or resort to case/when resolution</span> +</span><span id="DuckDB-797"><a href="#DuckDB-797"><span class="linenos">797</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">"binary"</span><span class="p">)</span> <span class="ow">or</span> <span class="n">arg</span><span class="o">.</span><span class="n">is_string</span><span class="p">:</span> +</span><span id="DuckDB-798"><a href="#DuckDB-798"><span class="linenos">798</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"LENGTH"</span><span class="p">,</span> <span class="n">arg</span><span class="p">)</span> </span><span id="DuckDB-799"><a href="#DuckDB-799"><span class="linenos">799</span></a> -</span><span id="DuckDB-800"><a href="#DuckDB-800"><span class="linenos">800</span></a> <span class="k">if</span> <span class="n">arg</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="o">*</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">TEXT_TYPES</span><span class="p">):</span> -</span><span id="DuckDB-801"><a href="#DuckDB-801"><span class="linenos">801</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"LENGTH"</span><span class="p">,</span> <span class="n">arg</span><span class="p">)</span> +</span><span id="DuckDB-800"><a href="#DuckDB-800"><span class="linenos">800</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">arg</span><span class="o">.</span><span class="n">type</span><span class="p">:</span> +</span><span id="DuckDB-801"><a href="#DuckDB-801"><span class="linenos">801</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-802"><a href="#DuckDB-802"><span class="linenos">802</span></a> -</span><span id="DuckDB-803"><a href="#DuckDB-803"><span class="linenos">803</span></a> <span class="c1"># We need these casts to make duckdb's static type checker happy</span> -</span><span id="DuckDB-804"><a href="#DuckDB-804"><span class="linenos">804</span></a> <span class="n">blob</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">arg</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">VARBINARY</span><span class="p">)</span> -</span><span id="DuckDB-805"><a href="#DuckDB-805"><span class="linenos">805</span></a> <span class="n">varchar</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">arg</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">VARCHAR</span><span class="p">)</span> -</span><span id="DuckDB-806"><a href="#DuckDB-806"><span class="linenos">806</span></a> -</span><span id="DuckDB-807"><a href="#DuckDB-807"><span class="linenos">807</span></a> <span class="n">case</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="DuckDB-808"><a href="#DuckDB-808"><span class="linenos">808</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">case</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"TYPEOF"</span><span class="p">,</span> <span class="n">arg</span><span class="p">))</span> -</span><span id="DuckDB-809"><a href="#DuckDB-809"><span class="linenos">809</span></a> <span class="o">.</span><span class="n">when</span><span class="p">(</span> -</span><span id="DuckDB-810"><a href="#DuckDB-810"><span class="linenos">810</span></a> <span class="s2">"'VARCHAR'"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Anonymous</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="s2">"LENGTH"</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="n">varchar</span><span class="p">])</span> -</span><span id="DuckDB-811"><a href="#DuckDB-811"><span class="linenos">811</span></a> <span class="p">)</span> <span class="c1"># anonymous to break length_sql recursion</span> -</span><span id="DuckDB-812"><a href="#DuckDB-812"><span class="linenos">812</span></a> <span class="o">.</span><span class="n">when</span><span class="p">(</span><span class="s2">"'BLOB'"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"OCTET_LENGTH"</span><span class="p">,</span> <span class="n">blob</span><span class="p">))</span> -</span><span id="DuckDB-813"><a href="#DuckDB-813"><span class="linenos">813</span></a> <span class="p">)</span> -</span><span id="DuckDB-814"><a href="#DuckDB-814"><span class="linenos">814</span></a> -</span><span id="DuckDB-815"><a href="#DuckDB-815"><span class="linenos">815</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">case</span><span class="p">)</span> -</span><span id="DuckDB-816"><a href="#DuckDB-816"><span class="linenos">816</span></a> -</span><span id="DuckDB-817"><a href="#DuckDB-817"><span class="linenos">817</span></a> <span class="k">def</span> <span class="nf">objectinsert_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ObjectInsert</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="DuckDB-818"><a href="#DuckDB-818"><span class="linenos">818</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-819"><a href="#DuckDB-819"><span class="linenos">819</span></a> <span class="n">key</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"key"</span><span class="p">)</span> -</span><span id="DuckDB-820"><a href="#DuckDB-820"><span class="linenos">820</span></a> <span class="n">key_sql</span> <span class="o">=</span> <span class="n">key</span><span class="o">.</span><span class="n">name</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="DuckDB-821"><a href="#DuckDB-821"><span class="linenos">821</span></a> <span class="n">value_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">"value"</span><span class="p">)</span> -</span><span id="DuckDB-822"><a href="#DuckDB-822"><span class="linenos">822</span></a> -</span><span id="DuckDB-823"><a href="#DuckDB-823"><span class="linenos">823</span></a> <span class="n">kv_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">key_sql</span><span class="si">}</span><span class="s2"> := </span><span class="si">{</span><span class="n">value_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="DuckDB-824"><a href="#DuckDB-824"><span class="linenos">824</span></a> -</span><span id="DuckDB-825"><a href="#DuckDB-825"><span class="linenos">825</span></a> <span class="c1"># If the input struct is empty e.g. transpiling OBJECT_INSERT(OBJECT_CONSTRUCT(), key, value) from Snowflake</span> -</span><span id="DuckDB-826"><a href="#DuckDB-826"><span class="linenos">826</span></a> <span class="c1"># then we can generate STRUCT_PACK which will build it since STRUCT_INSERT({}, key := value) is not valid DuckDB</span> -</span><span id="DuckDB-827"><a href="#DuckDB-827"><span class="linenos">827</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">Struct</span><span class="p">)</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">this</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> -</span><span id="DuckDB-828"><a href="#DuckDB-828"><span class="linenos">828</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"STRUCT_PACK"</span><span class="p">,</span> <span class="n">kv_sql</span><span class="p">)</span> +</span><span id="DuckDB-803"><a href="#DuckDB-803"><span class="linenos">803</span></a> <span class="n">arg</span> <span class="o">=</span> <span class="n">annotate_types</span><span class="p">(</span><span class="n">arg</span><span class="p">)</span> +</span><span id="DuckDB-804"><a href="#DuckDB-804"><span class="linenos">804</span></a> +</span><span id="DuckDB-805"><a href="#DuckDB-805"><span class="linenos">805</span></a> <span class="k">if</span> <span class="n">arg</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="o">*</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">TEXT_TYPES</span><span class="p">):</span> +</span><span id="DuckDB-806"><a href="#DuckDB-806"><span class="linenos">806</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"LENGTH"</span><span class="p">,</span> <span class="n">arg</span><span class="p">)</span> +</span><span id="DuckDB-807"><a href="#DuckDB-807"><span class="linenos">807</span></a> +</span><span id="DuckDB-808"><a href="#DuckDB-808"><span class="linenos">808</span></a> <span class="c1"># We need these casts to make duckdb's static type checker happy</span> +</span><span id="DuckDB-809"><a href="#DuckDB-809"><span class="linenos">809</span></a> <span class="n">blob</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">arg</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">VARBINARY</span><span class="p">)</span> +</span><span id="DuckDB-810"><a href="#DuckDB-810"><span class="linenos">810</span></a> <span class="n">varchar</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">arg</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">VARCHAR</span><span class="p">)</span> +</span><span id="DuckDB-811"><a href="#DuckDB-811"><span class="linenos">811</span></a> +</span><span id="DuckDB-812"><a href="#DuckDB-812"><span class="linenos">812</span></a> <span class="n">case</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="DuckDB-813"><a href="#DuckDB-813"><span class="linenos">813</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">case</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"TYPEOF"</span><span class="p">,</span> <span class="n">arg</span><span class="p">))</span> +</span><span id="DuckDB-814"><a href="#DuckDB-814"><span class="linenos">814</span></a> <span class="o">.</span><span class="n">when</span><span class="p">(</span> +</span><span id="DuckDB-815"><a href="#DuckDB-815"><span class="linenos">815</span></a> <span class="s2">"'VARCHAR'"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Anonymous</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="s2">"LENGTH"</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="n">varchar</span><span class="p">])</span> +</span><span id="DuckDB-816"><a href="#DuckDB-816"><span class="linenos">816</span></a> <span class="p">)</span> <span class="c1"># anonymous to break length_sql recursion</span> +</span><span id="DuckDB-817"><a href="#DuckDB-817"><span class="linenos">817</span></a> <span class="o">.</span><span class="n">when</span><span class="p">(</span><span class="s2">"'BLOB'"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"OCTET_LENGTH"</span><span class="p">,</span> <span class="n">blob</span><span class="p">))</span> +</span><span id="DuckDB-818"><a href="#DuckDB-818"><span class="linenos">818</span></a> <span class="p">)</span> +</span><span id="DuckDB-819"><a href="#DuckDB-819"><span class="linenos">819</span></a> +</span><span id="DuckDB-820"><a href="#DuckDB-820"><span class="linenos">820</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">case</span><span class="p">)</span> +</span><span id="DuckDB-821"><a href="#DuckDB-821"><span class="linenos">821</span></a> +</span><span id="DuckDB-822"><a href="#DuckDB-822"><span class="linenos">822</span></a> <span class="k">def</span> <span class="nf">objectinsert_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ObjectInsert</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="DuckDB-823"><a href="#DuckDB-823"><span class="linenos">823</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-824"><a href="#DuckDB-824"><span class="linenos">824</span></a> <span class="n">key</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"key"</span><span class="p">)</span> +</span><span id="DuckDB-825"><a href="#DuckDB-825"><span class="linenos">825</span></a> <span class="n">key_sql</span> <span class="o">=</span> <span class="n">key</span><span class="o">.</span><span class="n">name</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="DuckDB-826"><a href="#DuckDB-826"><span class="linenos">826</span></a> <span class="n">value_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">"value"</span><span class="p">)</span> +</span><span id="DuckDB-827"><a href="#DuckDB-827"><span class="linenos">827</span></a> +</span><span id="DuckDB-828"><a href="#DuckDB-828"><span class="linenos">828</span></a> <span class="n">kv_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">key_sql</span><span class="si">}</span><span class="s2"> := </span><span class="si">{</span><span class="n">value_sql</span><span class="si">}</span><span class="s2">"</span> </span><span id="DuckDB-829"><a href="#DuckDB-829"><span class="linenos">829</span></a> -</span><span id="DuckDB-830"><a href="#DuckDB-830"><span class="linenos">830</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"STRUCT_INSERT"</span><span class="p">,</span> <span class="n">this</span><span class="p">,</span> <span class="n">kv_sql</span><span class="p">)</span> +</span><span id="DuckDB-830"><a href="#DuckDB-830"><span class="linenos">830</span></a> <span class="c1"># If the input struct is empty e.g. transpiling OBJECT_INSERT(OBJECT_CONSTRUCT(), key, value) from Snowflake</span> +</span><span id="DuckDB-831"><a href="#DuckDB-831"><span class="linenos">831</span></a> <span class="c1"># then we can generate STRUCT_PACK which will build it since STRUCT_INSERT({}, key := value) is not valid DuckDB</span> +</span><span id="DuckDB-832"><a href="#DuckDB-832"><span class="linenos">832</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">Struct</span><span class="p">)</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">this</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> +</span><span id="DuckDB-833"><a href="#DuckDB-833"><span class="linenos">833</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"STRUCT_PACK"</span><span class="p">,</span> <span class="n">kv_sql</span><span class="p">)</span> +</span><span id="DuckDB-834"><a href="#DuckDB-834"><span class="linenos">834</span></a> +</span><span id="DuckDB-835"><a href="#DuckDB-835"><span class="linenos">835</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"STRUCT_INSERT"</span><span class="p">,</span> <span class="n">this</span><span class="p">,</span> <span class="n">kv_sql</span><span class="p">)</span> </span></pre></div> @@ -1971,17 +1992,17 @@ Possible values: <code>"nulls_are_small"</code>, <code>"nulls_are_large"</code>, </div> <a class="headerlink" href="#DuckDB.to_json_path"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DuckDB.to_json_path-208"><a href="#DuckDB.to_json_path-208"><span class="linenos">208</span></a> <span class="k">def</span> <span class="nf">to_json_path</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">])</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]:</span> -</span><span id="DuckDB.to_json_path-209"><a href="#DuckDB.to_json_path-209"><span class="linenos">209</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">path</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="p">):</span> -</span><span id="DuckDB.to_json_path-210"><a href="#DuckDB.to_json_path-210"><span class="linenos">210</span></a> <span class="c1"># DuckDB also supports the JSON pointer syntax, where every path starts with a `/`.</span> -</span><span id="DuckDB.to_json_path-211"><a href="#DuckDB.to_json_path-211"><span class="linenos">211</span></a> <span class="c1"># Additionally, it allows accessing the back of lists using the `[#-i]` syntax.</span> -</span><span id="DuckDB.to_json_path-212"><a href="#DuckDB.to_json_path-212"><span class="linenos">212</span></a> <span class="c1"># This check ensures we'll avoid trying to parse these as JSON paths, which can</span> -</span><span id="DuckDB.to_json_path-213"><a href="#DuckDB.to_json_path-213"><span class="linenos">213</span></a> <span class="c1"># either result in a noisy warning or in an invalid representation of the path.</span> -</span><span id="DuckDB.to_json_path-214"><a href="#DuckDB.to_json_path-214"><span class="linenos">214</span></a> <span class="n">path_text</span> <span class="o">=</span> <span class="n">path</span><span class="o">.</span><span class="n">name</span> -</span><span id="DuckDB.to_json_path-215"><a href="#DuckDB.to_json_path-215"><span class="linenos">215</span></a> <span class="k">if</span> <span class="n">path_text</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"/"</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">"[#"</span> <span class="ow">in</span> <span class="n">path_text</span><span class="p">:</span> -</span><span id="DuckDB.to_json_path-216"><a href="#DuckDB.to_json_path-216"><span class="linenos">216</span></a> <span class="k">return</span> <span class="n">path</span> -</span><span id="DuckDB.to_json_path-217"><a href="#DuckDB.to_json_path-217"><span class="linenos">217</span></a> -</span><span id="DuckDB.to_json_path-218"><a href="#DuckDB.to_json_path-218"><span class="linenos">218</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">to_json_path</span><span class="p">(</span><span class="n">path</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DuckDB.to_json_path-213"><a href="#DuckDB.to_json_path-213"><span class="linenos">213</span></a> <span class="k">def</span> <span class="nf">to_json_path</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">])</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]:</span> +</span><span id="DuckDB.to_json_path-214"><a href="#DuckDB.to_json_path-214"><span class="linenos">214</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">path</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="p">):</span> +</span><span id="DuckDB.to_json_path-215"><a href="#DuckDB.to_json_path-215"><span class="linenos">215</span></a> <span class="c1"># DuckDB also supports the JSON pointer syntax, where every path starts with a `/`.</span> +</span><span id="DuckDB.to_json_path-216"><a href="#DuckDB.to_json_path-216"><span class="linenos">216</span></a> <span class="c1"># Additionally, it allows accessing the back of lists using the `[#-i]` syntax.</span> +</span><span id="DuckDB.to_json_path-217"><a href="#DuckDB.to_json_path-217"><span class="linenos">217</span></a> <span class="c1"># This check ensures we'll avoid trying to parse these as JSON paths, which can</span> +</span><span id="DuckDB.to_json_path-218"><a href="#DuckDB.to_json_path-218"><span class="linenos">218</span></a> <span class="c1"># either result in a noisy warning or in an invalid representation of the path.</span> +</span><span id="DuckDB.to_json_path-219"><a href="#DuckDB.to_json_path-219"><span class="linenos">219</span></a> <span class="n">path_text</span> <span class="o">=</span> <span class="n">path</span><span class="o">.</span><span class="n">name</span> +</span><span id="DuckDB.to_json_path-220"><a href="#DuckDB.to_json_path-220"><span class="linenos">220</span></a> <span class="k">if</span> <span class="n">path_text</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"/"</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">"[#"</span> <span class="ow">in</span> <span class="n">path_text</span><span class="p">:</span> +</span><span id="DuckDB.to_json_path-221"><a href="#DuckDB.to_json_path-221"><span class="linenos">221</span></a> <span class="k">return</span> <span class="n">path</span> +</span><span id="DuckDB.to_json_path-222"><a href="#DuckDB.to_json_path-222"><span class="linenos">222</span></a> +</span><span id="DuckDB.to_json_path-223"><a href="#DuckDB.to_json_path-223"><span class="linenos">223</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">to_json_path</span><span class="p">(</span><span class="n">path</span><span class="p">)</span> </span></pre></div> @@ -2341,44 +2362,45 @@ Possible values: <code>"nulls_are_small"</code>, <code>"nulls_are_large"</code>, </div> <a class="headerlink" href="#DuckDB.Tokenizer"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DuckDB.Tokenizer-220"><a href="#DuckDB.Tokenizer-220"><span class="linenos">220</span></a> <span class="k">class</span> <span class="nc">Tokenizer</span><span class="p">(</span><span class="n">tokens</span><span class="o">.</span><span class="n">Tokenizer</span><span class="p">):</span> -</span><span id="DuckDB.Tokenizer-221"><a href="#DuckDB.Tokenizer-221"><span class="linenos">221</span></a> <span class="n">HEREDOC_STRINGS</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"$"</span><span class="p">]</span> -</span><span id="DuckDB.Tokenizer-222"><a href="#DuckDB.Tokenizer-222"><span class="linenos">222</span></a> -</span><span id="DuckDB.Tokenizer-223"><a href="#DuckDB.Tokenizer-223"><span class="linenos">223</span></a> <span class="n">HEREDOC_TAG_IS_IDENTIFIER</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="DuckDB.Tokenizer-224"><a href="#DuckDB.Tokenizer-224"><span class="linenos">224</span></a> <span class="n">HEREDOC_STRING_ALTERNATIVE</span> <span class="o">=</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PARAMETER</span> -</span><span id="DuckDB.Tokenizer-225"><a href="#DuckDB.Tokenizer-225"><span class="linenos">225</span></a> -</span><span id="DuckDB.Tokenizer-226"><a href="#DuckDB.Tokenizer-226"><span class="linenos">226</span></a> <span class="n">KEYWORDS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="DuckDB.Tokenizer-227"><a href="#DuckDB.Tokenizer-227"><span class="linenos">227</span></a> <span class="o">**</span><span class="n">tokens</span><span class="o">.</span><span class="n">Tokenizer</span><span class="o">.</span><span class="n">KEYWORDS</span><span class="p">,</span> -</span><span id="DuckDB.Tokenizer-228"><a href="#DuckDB.Tokenizer-228"><span class="linenos">228</span></a> <span class="s2">"//"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DIV</span><span class="p">,</span> -</span><span id="DuckDB.Tokenizer-229"><a href="#DuckDB.Tokenizer-229"><span class="linenos">229</span></a> <span class="s2">"ATTACH"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">COMMAND</span><span class="p">,</span> -</span><span id="DuckDB.Tokenizer-230"><a href="#DuckDB.Tokenizer-230"><span class="linenos">230</span></a> <span class="s2">"BINARY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VARBINARY</span><span class="p">,</span> -</span><span id="DuckDB.Tokenizer-231"><a href="#DuckDB.Tokenizer-231"><span class="linenos">231</span></a> <span class="s2">"BITSTRING"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BIT</span><span class="p">,</span> -</span><span id="DuckDB.Tokenizer-232"><a href="#DuckDB.Tokenizer-232"><span class="linenos">232</span></a> <span class="s2">"BPCHAR"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TEXT</span><span class="p">,</span> -</span><span id="DuckDB.Tokenizer-233"><a href="#DuckDB.Tokenizer-233"><span class="linenos">233</span></a> <span class="s2">"CHAR"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TEXT</span><span class="p">,</span> -</span><span id="DuckDB.Tokenizer-234"><a href="#DuckDB.Tokenizer-234"><span class="linenos">234</span></a> <span class="s2">"CHARACTER VARYING"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TEXT</span><span class="p">,</span> -</span><span id="DuckDB.Tokenizer-235"><a href="#DuckDB.Tokenizer-235"><span class="linenos">235</span></a> <span class="s2">"EXCLUDE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">EXCEPT</span><span class="p">,</span> -</span><span id="DuckDB.Tokenizer-236"><a href="#DuckDB.Tokenizer-236"><span class="linenos">236</span></a> <span class="s2">"LOGICAL"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BOOLEAN</span><span class="p">,</span> -</span><span id="DuckDB.Tokenizer-237"><a href="#DuckDB.Tokenizer-237"><span class="linenos">237</span></a> <span class="s2">"ONLY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ONLY</span><span class="p">,</span> -</span><span id="DuckDB.Tokenizer-238"><a href="#DuckDB.Tokenizer-238"><span class="linenos">238</span></a> <span class="s2">"PIVOT_WIDER"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PIVOT</span><span class="p">,</span> -</span><span id="DuckDB.Tokenizer-239"><a href="#DuckDB.Tokenizer-239"><span class="linenos">239</span></a> <span class="s2">"POSITIONAL"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">POSITIONAL</span><span class="p">,</span> -</span><span id="DuckDB.Tokenizer-240"><a href="#DuckDB.Tokenizer-240"><span class="linenos">240</span></a> <span class="s2">"SIGNED"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">INT</span><span class="p">,</span> -</span><span id="DuckDB.Tokenizer-241"><a href="#DuckDB.Tokenizer-241"><span class="linenos">241</span></a> <span class="s2">"STRING"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TEXT</span><span class="p">,</span> -</span><span id="DuckDB.Tokenizer-242"><a href="#DuckDB.Tokenizer-242"><span class="linenos">242</span></a> <span class="s2">"UBIGINT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">UBIGINT</span><span class="p">,</span> -</span><span id="DuckDB.Tokenizer-243"><a href="#DuckDB.Tokenizer-243"><span class="linenos">243</span></a> <span class="s2">"UINTEGER"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">UINT</span><span class="p">,</span> -</span><span id="DuckDB.Tokenizer-244"><a href="#DuckDB.Tokenizer-244"><span class="linenos">244</span></a> <span class="s2">"USMALLINT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">USMALLINT</span><span class="p">,</span> -</span><span id="DuckDB.Tokenizer-245"><a href="#DuckDB.Tokenizer-245"><span class="linenos">245</span></a> <span class="s2">"UTINYINT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">UTINYINT</span><span class="p">,</span> -</span><span id="DuckDB.Tokenizer-246"><a href="#DuckDB.Tokenizer-246"><span class="linenos">246</span></a> <span class="s2">"TIMESTAMP_S"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TIMESTAMP_S</span><span class="p">,</span> -</span><span id="DuckDB.Tokenizer-247"><a href="#DuckDB.Tokenizer-247"><span class="linenos">247</span></a> <span class="s2">"TIMESTAMP_MS"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TIMESTAMP_MS</span><span class="p">,</span> -</span><span id="DuckDB.Tokenizer-248"><a href="#DuckDB.Tokenizer-248"><span class="linenos">248</span></a> <span class="s2">"TIMESTAMP_NS"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TIMESTAMP_NS</span><span class="p">,</span> -</span><span id="DuckDB.Tokenizer-249"><a href="#DuckDB.Tokenizer-249"><span class="linenos">249</span></a> <span class="s2">"TIMESTAMP_US"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TIMESTAMP</span><span class="p">,</span> -</span><span id="DuckDB.Tokenizer-250"><a href="#DuckDB.Tokenizer-250"><span class="linenos">250</span></a> <span class="s2">"VARCHAR"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TEXT</span><span class="p">,</span> -</span><span id="DuckDB.Tokenizer-251"><a href="#DuckDB.Tokenizer-251"><span class="linenos">251</span></a> <span class="p">}</span> -</span><span id="DuckDB.Tokenizer-252"><a href="#DuckDB.Tokenizer-252"><span class="linenos">252</span></a> <span class="n">KEYWORDS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">"/*+"</span><span class="p">)</span> -</span><span id="DuckDB.Tokenizer-253"><a href="#DuckDB.Tokenizer-253"><span class="linenos">253</span></a> -</span><span id="DuckDB.Tokenizer-254"><a href="#DuckDB.Tokenizer-254"><span class="linenos">254</span></a> <span class="n">SINGLE_TOKENS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="DuckDB.Tokenizer-255"><a href="#DuckDB.Tokenizer-255"><span class="linenos">255</span></a> <span class="o">**</span><span class="n">tokens</span><span class="o">.</span><span class="n">Tokenizer</span><span class="o">.</span><span class="n">SINGLE_TOKENS</span><span class="p">,</span> -</span><span id="DuckDB.Tokenizer-256"><a href="#DuckDB.Tokenizer-256"><span class="linenos">256</span></a> <span class="s2">"$"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PARAMETER</span><span class="p">,</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DuckDB.Tokenizer-225"><a href="#DuckDB.Tokenizer-225"><span class="linenos">225</span></a> <span class="k">class</span> <span class="nc">Tokenizer</span><span class="p">(</span><span class="n">tokens</span><span class="o">.</span><span class="n">Tokenizer</span><span class="p">):</span> +</span><span id="DuckDB.Tokenizer-226"><a href="#DuckDB.Tokenizer-226"><span class="linenos">226</span></a> <span class="n">HEREDOC_STRINGS</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"$"</span><span class="p">]</span> +</span><span id="DuckDB.Tokenizer-227"><a href="#DuckDB.Tokenizer-227"><span class="linenos">227</span></a> +</span><span id="DuckDB.Tokenizer-228"><a href="#DuckDB.Tokenizer-228"><span class="linenos">228</span></a> <span class="n">HEREDOC_TAG_IS_IDENTIFIER</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="DuckDB.Tokenizer-229"><a href="#DuckDB.Tokenizer-229"><span class="linenos">229</span></a> <span class="n">HEREDOC_STRING_ALTERNATIVE</span> <span class="o">=</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PARAMETER</span> +</span><span id="DuckDB.Tokenizer-230"><a href="#DuckDB.Tokenizer-230"><span class="linenos">230</span></a> +</span><span id="DuckDB.Tokenizer-231"><a href="#DuckDB.Tokenizer-231"><span class="linenos">231</span></a> <span class="n">KEYWORDS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="DuckDB.Tokenizer-232"><a href="#DuckDB.Tokenizer-232"><span class="linenos">232</span></a> <span class="o">**</span><span class="n">tokens</span><span class="o">.</span><span class="n">Tokenizer</span><span class="o">.</span><span class="n">KEYWORDS</span><span class="p">,</span> +</span><span id="DuckDB.Tokenizer-233"><a href="#DuckDB.Tokenizer-233"><span class="linenos">233</span></a> <span class="s2">"//"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DIV</span><span class="p">,</span> +</span><span id="DuckDB.Tokenizer-234"><a href="#DuckDB.Tokenizer-234"><span class="linenos">234</span></a> <span class="s2">"ATTACH"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">COMMAND</span><span class="p">,</span> +</span><span id="DuckDB.Tokenizer-235"><a href="#DuckDB.Tokenizer-235"><span class="linenos">235</span></a> <span class="s2">"BINARY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VARBINARY</span><span class="p">,</span> +</span><span id="DuckDB.Tokenizer-236"><a href="#DuckDB.Tokenizer-236"><span class="linenos">236</span></a> <span class="s2">"BITSTRING"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BIT</span><span class="p">,</span> +</span><span id="DuckDB.Tokenizer-237"><a href="#DuckDB.Tokenizer-237"><span class="linenos">237</span></a> <span class="s2">"BPCHAR"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TEXT</span><span class="p">,</span> +</span><span id="DuckDB.Tokenizer-238"><a href="#DuckDB.Tokenizer-238"><span class="linenos">238</span></a> <span class="s2">"CHAR"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TEXT</span><span class="p">,</span> +</span><span id="DuckDB.Tokenizer-239"><a href="#DuckDB.Tokenizer-239"><span class="linenos">239</span></a> <span class="s2">"CHARACTER VARYING"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TEXT</span><span class="p">,</span> +</span><span id="DuckDB.Tokenizer-240"><a href="#DuckDB.Tokenizer-240"><span class="linenos">240</span></a> <span class="s2">"EXCLUDE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">EXCEPT</span><span class="p">,</span> +</span><span id="DuckDB.Tokenizer-241"><a href="#DuckDB.Tokenizer-241"><span class="linenos">241</span></a> <span class="s2">"LOGICAL"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BOOLEAN</span><span class="p">,</span> +</span><span id="DuckDB.Tokenizer-242"><a href="#DuckDB.Tokenizer-242"><span class="linenos">242</span></a> <span class="s2">"ONLY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ONLY</span><span class="p">,</span> +</span><span id="DuckDB.Tokenizer-243"><a href="#DuckDB.Tokenizer-243"><span class="linenos">243</span></a> <span class="s2">"PIVOT_WIDER"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PIVOT</span><span class="p">,</span> +</span><span id="DuckDB.Tokenizer-244"><a href="#DuckDB.Tokenizer-244"><span class="linenos">244</span></a> <span class="s2">"POSITIONAL"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">POSITIONAL</span><span class="p">,</span> +</span><span id="DuckDB.Tokenizer-245"><a href="#DuckDB.Tokenizer-245"><span class="linenos">245</span></a> <span class="s2">"SIGNED"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">INT</span><span class="p">,</span> +</span><span id="DuckDB.Tokenizer-246"><a href="#DuckDB.Tokenizer-246"><span class="linenos">246</span></a> <span class="s2">"STRING"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TEXT</span><span class="p">,</span> +</span><span id="DuckDB.Tokenizer-247"><a href="#DuckDB.Tokenizer-247"><span class="linenos">247</span></a> <span class="s2">"SUMMARIZE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SUMMARIZE</span><span class="p">,</span> +</span><span id="DuckDB.Tokenizer-248"><a href="#DuckDB.Tokenizer-248"><span class="linenos">248</span></a> <span class="s2">"TIMESTAMP_S"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TIMESTAMP_S</span><span class="p">,</span> +</span><span id="DuckDB.Tokenizer-249"><a href="#DuckDB.Tokenizer-249"><span class="linenos">249</span></a> <span class="s2">"TIMESTAMP_MS"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TIMESTAMP_MS</span><span class="p">,</span> +</span><span id="DuckDB.Tokenizer-250"><a href="#DuckDB.Tokenizer-250"><span class="linenos">250</span></a> <span class="s2">"TIMESTAMP_NS"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TIMESTAMP_NS</span><span class="p">,</span> +</span><span id="DuckDB.Tokenizer-251"><a href="#DuckDB.Tokenizer-251"><span class="linenos">251</span></a> <span class="s2">"TIMESTAMP_US"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TIMESTAMP</span><span class="p">,</span> +</span><span id="DuckDB.Tokenizer-252"><a href="#DuckDB.Tokenizer-252"><span class="linenos">252</span></a> <span class="s2">"UBIGINT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">UBIGINT</span><span class="p">,</span> +</span><span id="DuckDB.Tokenizer-253"><a href="#DuckDB.Tokenizer-253"><span class="linenos">253</span></a> <span class="s2">"UINTEGER"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">UINT</span><span class="p">,</span> +</span><span id="DuckDB.Tokenizer-254"><a href="#DuckDB.Tokenizer-254"><span class="linenos">254</span></a> <span class="s2">"USMALLINT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">USMALLINT</span><span class="p">,</span> +</span><span id="DuckDB.Tokenizer-255"><a href="#DuckDB.Tokenizer-255"><span class="linenos">255</span></a> <span class="s2">"UTINYINT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">UTINYINT</span><span class="p">,</span> +</span><span id="DuckDB.Tokenizer-256"><a href="#DuckDB.Tokenizer-256"><span class="linenos">256</span></a> <span class="s2">"VARCHAR"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TEXT</span><span class="p">,</span> </span><span id="DuckDB.Tokenizer-257"><a href="#DuckDB.Tokenizer-257"><span class="linenos">257</span></a> <span class="p">}</span> +</span><span id="DuckDB.Tokenizer-258"><a href="#DuckDB.Tokenizer-258"><span class="linenos">258</span></a> <span class="n">KEYWORDS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">"/*+"</span><span class="p">)</span> +</span><span id="DuckDB.Tokenizer-259"><a href="#DuckDB.Tokenizer-259"><span class="linenos">259</span></a> +</span><span id="DuckDB.Tokenizer-260"><a href="#DuckDB.Tokenizer-260"><span class="linenos">260</span></a> <span class="n">SINGLE_TOKENS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="DuckDB.Tokenizer-261"><a href="#DuckDB.Tokenizer-261"><span class="linenos">261</span></a> <span class="o">**</span><span class="n">tokens</span><span class="o">.</span><span class="n">Tokenizer</span><span class="o">.</span><span class="n">SINGLE_TOKENS</span><span class="p">,</span> +</span><span id="DuckDB.Tokenizer-262"><a href="#DuckDB.Tokenizer-262"><span class="linenos">262</span></a> <span class="s2">"$"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PARAMETER</span><span class="p">,</span> +</span><span id="DuckDB.Tokenizer-263"><a href="#DuckDB.Tokenizer-263"><span class="linenos">263</span></a> <span class="p">}</span> </span></pre></div> @@ -2424,7 +2446,7 @@ Possible values: <code>"nulls_are_small"</code>, <code>"nulls_are_large"</code>, <div class="attr variable"> <span class="name">KEYWORDS</span> = <input id="DuckDB.Tokenizer.KEYWORDS-view-value" class="view-value-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1"> - <label class="view-value-button pdoc-button" for="DuckDB.Tokenizer.KEYWORDS-view-value"></label><span class="default_value">{'{%': <TokenType.BLOCK_START: 'BLOCK_START'>, '{%+': <TokenType.BLOCK_START: 'BLOCK_START'>, '{%-': <TokenType.BLOCK_START: 'BLOCK_START'>, '%}': <TokenType.BLOCK_END: 'BLOCK_END'>, '+%}': <TokenType.BLOCK_END: 'BLOCK_END'>, '-%}': <TokenType.BLOCK_END: 'BLOCK_END'>, '{{+': <TokenType.BLOCK_START: 'BLOCK_START'>, '{{-': <TokenType.BLOCK_START: 'BLOCK_START'>, '+}}': <TokenType.BLOCK_END: 'BLOCK_END'>, '-}}': <TokenType.BLOCK_END: 'BLOCK_END'>, '==': <TokenType.EQ: 'EQ'>, '::': <TokenType.DCOLON: 'DCOLON'>, '||': <TokenType.DPIPE: 'DPIPE'>, '>=': <TokenType.GTE: 'GTE'>, '<=': <TokenType.LTE: 'LTE'>, '<>': <TokenType.NEQ: 'NEQ'>, '!=': <TokenType.NEQ: 'NEQ'>, ':=': <TokenType.COLON_EQ: 'COLON_EQ'>, '<=>': <TokenType.NULLSAFE_EQ: 'NULLSAFE_EQ'>, '->': <TokenType.ARROW: 'ARROW'>, '->>': <TokenType.DARROW: 'DARROW'>, '=>': <TokenType.FARROW: 'FARROW'>, '#>': <TokenType.HASH_ARROW: 'HASH_ARROW'>, '#>>': <TokenType.DHASH_ARROW: 'DHASH_ARROW'>, '<->': <TokenType.LR_ARROW: 'LR_ARROW'>, '&&': <TokenType.DAMP: 'DAMP'>, '??': <TokenType.DQMARK: 'DQMARK'>, 'ALL': <TokenType.ALL: 'ALL'>, 'ALWAYS': <TokenType.ALWAYS: 'ALWAYS'>, 'AND': <TokenType.AND: 'AND'>, 'ANTI': <TokenType.ANTI: 'ANTI'>, 'ANY': <TokenType.ANY: 'ANY'>, 'ASC': <TokenType.ASC: 'ASC'>, 'AS': <TokenType.ALIAS: 'ALIAS'>, 'ASOF': <TokenType.ASOF: 'ASOF'>, 'AUTOINCREMENT': <TokenType.AUTO_INCREMENT: 'AUTO_INCREMENT'>, 'AUTO_INCREMENT': <TokenType.AUTO_INCREMENT: 'AUTO_INCREMENT'>, 'BEGIN': <TokenType.BEGIN: 'BEGIN'>, 'BETWEEN': <TokenType.BETWEEN: 'BETWEEN'>, 'CACHE': <TokenType.CACHE: 'CACHE'>, 'UNCACHE': <TokenType.UNCACHE: 'UNCACHE'>, 'CASE': <TokenType.CASE: 'CASE'>, 'CHARACTER SET': <TokenType.CHARACTER_SET: 'CHARACTER_SET'>, 'CLUSTER BY': <TokenType.CLUSTER_BY: 'CLUSTER_BY'>, 'COLLATE': <TokenType.COLLATE: 'COLLATE'>, 'COLUMN': <TokenType.COLUMN: 'COLUMN'>, 'COMMIT': <TokenType.COMMIT: 'COMMIT'>, 'CONNECT BY': <TokenType.CONNECT_BY: 'CONNECT_BY'>, 'CONSTRAINT': <TokenType.CONSTRAINT: 'CONSTRAINT'>, 'COPY': <TokenType.COPY: 'COPY'>, 'CREATE': <TokenType.CREATE: 'CREATE'>, 'CROSS': <TokenType.CROSS: 'CROSS'>, 'CUBE': <TokenType.CUBE: 'CUBE'>, 'CURRENT_DATE': <TokenType.CURRENT_DATE: 'CURRENT_DATE'>, 'CURRENT_TIME': <TokenType.CURRENT_TIME: 'CURRENT_TIME'>, 'CURRENT_TIMESTAMP': <TokenType.CURRENT_TIMESTAMP: 'CURRENT_TIMESTAMP'>, 'CURRENT_USER': <TokenType.CURRENT_USER: 'CURRENT_USER'>, 'DATABASE': <TokenType.DATABASE: 'DATABASE'>, 'DEFAULT': <TokenType.DEFAULT: 'DEFAULT'>, 'DELETE': <TokenType.DELETE: 'DELETE'>, 'DESC': <TokenType.DESC: 'DESC'>, 'DESCRIBE': <TokenType.DESCRIBE: 'DESCRIBE'>, 'DISTINCT': <TokenType.DISTINCT: 'DISTINCT'>, 'DISTRIBUTE BY': <TokenType.DISTRIBUTE_BY: 'DISTRIBUTE_BY'>, 'DIV': <TokenType.DIV: 'DIV'>, 'DROP': <TokenType.DROP: 'DROP'>, 'ELSE': <TokenType.ELSE: 'ELSE'>, 'END': <TokenType.END: 'END'>, 'ENUM': <TokenType.ENUM: 'ENUM'>, 'ESCAPE': <TokenType.ESCAPE: 'ESCAPE'>, 'EXCEPT': <TokenType.EXCEPT: 'EXCEPT'>, 'EXECUTE': <TokenType.EXECUTE: 'EXECUTE'>, 'EXISTS': <TokenType.EXISTS: 'EXISTS'>, 'FALSE': <TokenType.FALSE: 'FALSE'>, 'FETCH': <TokenType.FETCH: 'FETCH'>, 'FILTER': <TokenType.FILTER: 'FILTER'>, 'FIRST': <TokenType.FIRST: 'FIRST'>, 'FULL': <TokenType.FULL: 'FULL'>, 'FUNCTION': <TokenType.FUNCTION: 'FUNCTION'>, 'FOR': <TokenType.FOR: 'FOR'>, 'FOREIGN KEY': <TokenType.FOREIGN_KEY: 'FOREIGN_KEY'>, 'FORMAT': <TokenType.FORMAT: 'FORMAT'>, 'FROM': <TokenType.FROM: 'FROM'>, 'GEOGRAPHY': <TokenType.GEOGRAPHY: 'GEOGRAPHY'>, 'GEOMETRY': <TokenType.GEOMETRY: 'GEOMETRY'>, 'GLOB': <TokenType.GLOB: 'GLOB'>, 'GROUP BY': <TokenType.GROUP_BY: 'GROUP_BY'>, 'GROUPING SETS': <TokenType.GROUPING_SETS: 'GROUPING_SETS'>, 'HAVING': <TokenType.HAVING: 'HAVING'>, 'ILIKE': <TokenType.ILIKE: 'ILIKE'>, 'IN': <TokenType.IN: 'IN'>, 'INDEX': <TokenType.INDEX: 'INDEX'>, 'INET': <TokenType.INET: 'INET'>, 'INNER': <TokenType.INNER: 'INNER'>, 'INSERT': <TokenType.INSERT: 'INSERT'>, 'INTERVAL': <TokenType.INTERVAL: 'INTERVAL'>, 'INTERSECT': <TokenType.INTERSECT: 'INTERSECT'>, 'INTO': <TokenType.INTO: 'INTO'>, 'IS': <TokenType.IS: 'IS'>, 'ISNULL': <TokenType.ISNULL: 'ISNULL'>, 'JOIN': <TokenType.JOIN: 'JOIN'>, 'KEEP': <TokenType.KEEP: 'KEEP'>, 'KILL': <TokenType.KILL: 'KILL'>, 'LATERAL': <TokenType.LATERAL: 'LATERAL'>, 'LEFT': <TokenType.LEFT: 'LEFT'>, 'LIKE': <TokenType.LIKE: 'LIKE'>, 'LIMIT': <TokenType.LIMIT: 'LIMIT'>, 'LOAD': <TokenType.LOAD: 'LOAD'>, 'LOCK': <TokenType.LOCK: 'LOCK'>, 'MERGE': <TokenType.MERGE: 'MERGE'>, 'NATURAL': <TokenType.NATURAL: 'NATURAL'>, 'NEXT': <TokenType.NEXT: 'NEXT'>, 'NOT': <TokenType.NOT: 'NOT'>, 'NOTNULL': <TokenType.NOTNULL: 'NOTNULL'>, 'NULL': <TokenType.NULL: 'NULL'>, 'OBJECT': <TokenType.OBJECT: 'OBJECT'>, 'OFFSET': <TokenType.OFFSET: 'OFFSET'>, 'ON': <TokenType.ON: 'ON'>, 'OR': <TokenType.OR: 'OR'>, 'XOR': <TokenType.XOR: 'XOR'>, 'ORDER BY': <TokenType.ORDER_BY: 'ORDER_BY'>, 'ORDINALITY': <TokenType.ORDINALITY: 'ORDINALITY'>, 'OUTER': <TokenType.OUTER: 'OUTER'>, 'OVER': <TokenType.OVER: 'OVER'>, 'OVERLAPS': <TokenType.OVERLAPS: 'OVERLAPS'>, 'OVERWRITE': <TokenType.OVERWRITE: 'OVERWRITE'>, 'PARTITION': <TokenType.PARTITION: 'PARTITION'>, 'PARTITION BY': <TokenType.PARTITION_BY: 'PARTITION_BY'>, 'PARTITIONED BY': <TokenType.PARTITION_BY: 'PARTITION_BY'>, 'PARTITIONED_BY': <TokenType.PARTITION_BY: 'PARTITION_BY'>, 'PERCENT': <TokenType.PERCENT: 'PERCENT'>, 'PIVOT': <TokenType.PIVOT: 'PIVOT'>, 'PRAGMA': <TokenType.PRAGMA: 'PRAGMA'>, 'PRIMARY KEY': <TokenType.PRIMARY_KEY: 'PRIMARY_KEY'>, 'PROCEDURE': <TokenType.PROCEDURE: 'PROCEDURE'>, 'QUALIFY': <TokenType.QUALIFY: 'QUALIFY'>, 'RANGE': <TokenType.RANGE: 'RANGE'>, 'RECURSIVE': <TokenType.RECURSIVE: 'RECURSIVE'>, 'REGEXP': <TokenType.RLIKE: 'RLIKE'>, 'REPLACE': <TokenType.REPLACE: 'REPLACE'>, 'RETURNING': <TokenType.RETURNING: 'RETURNING'>, 'REFERENCES': <TokenType.REFERENCES: 'REFERENCES'>, 'RIGHT': <TokenType.RIGHT: 'RIGHT'>, 'RLIKE': <TokenType.RLIKE: 'RLIKE'>, 'ROLLBACK': <TokenType.ROLLBACK: 'ROLLBACK'>, 'ROLLUP': <TokenType.ROLLUP: 'ROLLUP'>, 'ROW': <TokenType.ROW: 'ROW'>, 'ROWS': <TokenType.ROWS: 'ROWS'>, 'SCHEMA': <TokenType.SCHEMA: 'SCHEMA'>, 'SELECT': <TokenType.SELECT: 'SELECT'>, 'SEMI': <TokenType.SEMI: 'SEMI'>, 'SET': <TokenType.SET: 'SET'>, 'SETTINGS': <TokenType.SETTINGS: 'SETTINGS'>, 'SHOW': <TokenType.SHOW: 'SHOW'>, 'SIMILAR TO': <TokenType.SIMILAR_TO: 'SIMILAR_TO'>, 'SOME': <TokenType.SOME: 'SOME'>, 'SORT BY': <TokenType.SORT_BY: 'SORT_BY'>, 'START WITH': <TokenType.START_WITH: 'START_WITH'>, 'STRAIGHT_JOIN': <TokenType.STRAIGHT_JOIN: 'STRAIGHT_JOIN'>, 'TABLE': <TokenType.TABLE: 'TABLE'>, 'TABLESAMPLE': <TokenType.TABLE_SAMPLE: 'TABLE_SAMPLE'>, 'TEMP': <TokenType.TEMPORARY: 'TEMPORARY'>, 'TEMPORARY': <TokenType.TEMPORARY: 'TEMPORARY'>, 'THEN': <TokenType.THEN: 'THEN'>, 'TRUE': <TokenType.TRUE: 'TRUE'>, 'TRUNCATE': <TokenType.TRUNCATE: 'TRUNCATE'>, 'UNION': <TokenType.UNION: 'UNION'>, 'UNKNOWN': <TokenType.UNKNOWN: 'UNKNOWN'>, 'UNNEST': <TokenType.UNNEST: 'UNNEST'>, 'UNPIVOT': <TokenType.UNPIVOT: 'UNPIVOT'>, 'UPDATE': <TokenType.UPDATE: 'UPDATE'>, 'USE': <TokenType.USE: 'USE'>, 'USING': <TokenType.USING: 'USING'>, 'UUID': <TokenType.UUID: 'UUID'>, 'VALUES': <TokenType.VALUES: 'VALUES'>, 'VIEW': <TokenType.VIEW: 'VIEW'>, 'VOLATILE': <TokenType.VOLATILE: 'VOLATILE'>, 'WHEN': <TokenType.WHEN: 'WHEN'>, 'WHERE': <TokenType.WHERE: 'WHERE'>, 'WINDOW': <TokenType.WINDOW: 'WINDOW'>, 'WITH': <TokenType.WITH: 'WITH'>, 'APPLY': <TokenType.APPLY: 'APPLY'>, 'ARRAY': <TokenType.ARRAY: 'ARRAY'>, 'BIT': <TokenType.BIT: 'BIT'>, 'BOOL': <TokenType.BOOLEAN: 'BOOLEAN'>, 'BOOLEAN': <TokenType.BOOLEAN: 'BOOLEAN'>, 'BYTE': <TokenType.TINYINT: 'TINYINT'>, 'MEDIUMINT': <TokenType.MEDIUMINT: 'MEDIUMINT'>, 'INT1': <TokenType.TINYINT: 'TINYINT'>, 'TINYINT': <TokenType.TINYINT: 'TINYINT'>, 'INT16': <TokenType.SMALLINT: 'SMALLINT'>, 'SHORT': <TokenType.SMALLINT: 'SMALLINT'>, 'SMALLINT': <TokenType.SMALLINT: 'SMALLINT'>, 'INT128': <TokenType.INT128: 'INT128'>, 'HUGEINT': <TokenType.INT128: 'INT128'>, 'INT2': <TokenType.SMALLINT: 'SMALLINT'>, 'INTEGER': <TokenType.INT: 'INT'>, 'INT': <TokenType.INT: 'INT'>, 'INT4': <TokenType.INT: 'INT'>, 'INT32': <TokenType.INT: 'INT'>, 'INT64': <TokenType.BIGINT: 'BIGINT'>, 'LONG': <TokenType.BIGINT: 'BIGINT'>, 'BIGINT': <TokenType.BIGINT: 'BIGINT'>, 'INT8': <TokenType.TINYINT: 'TINYINT'>, 'UINT': <TokenType.UINT: 'UINT'>, 'DEC': <TokenType.DECIMAL: 'DECIMAL'>, 'DECIMAL': <TokenType.DECIMAL: 'DECIMAL'>, 'BIGDECIMAL': <TokenType.BIGDECIMAL: 'BIGDECIMAL'>, 'BIGNUMERIC': <TokenType.BIGDECIMAL: 'BIGDECIMAL'>, 'LIST': <TokenType.LIST: 'LIST'>, 'MAP': <TokenType.MAP: 'MAP'>, 'NULLABLE': <TokenType.NULLABLE: 'NULLABLE'>, 'NUMBER': <TokenType.DECIMAL: 'DECIMAL'>, 'NUMERIC': <TokenType.DECIMAL: 'DECIMAL'>, 'FIXED': <TokenType.DECIMAL: 'DECIMAL'>, 'REAL': <TokenType.FLOAT: 'FLOAT'>, 'FLOAT': <TokenType.FLOAT: 'FLOAT'>, 'FLOAT4': <TokenType.FLOAT: 'FLOAT'>, 'FLOAT8': <TokenType.DOUBLE: 'DOUBLE'>, 'DOUBLE': <TokenType.DOUBLE: 'DOUBLE'>, 'DOUBLE PRECISION': <TokenType.DOUBLE: 'DOUBLE'>, 'JSON': <TokenType.JSON: 'JSON'>, 'JSONB': <TokenType.JSONB: 'JSONB'>, 'CHAR': <TokenType.TEXT: 'TEXT'>, 'CHARACTER': <TokenType.CHAR: 'CHAR'>, 'NCHAR': <TokenType.NCHAR: 'NCHAR'>, 'VARCHAR': <TokenType.TEXT: 'TEXT'>, 'VARCHAR2': <TokenType.VARCHAR: 'VARCHAR'>, 'NVARCHAR': <TokenType.NVARCHAR: 'NVARCHAR'>, 'NVARCHAR2': <TokenType.NVARCHAR: 'NVARCHAR'>, 'BPCHAR': <TokenType.TEXT: 'TEXT'>, 'STR': <TokenType.TEXT: 'TEXT'>, 'STRING': <TokenType.TEXT: 'TEXT'>, 'TEXT': <TokenType.TEXT: 'TEXT'>, 'LONGTEXT': <TokenType.LONGTEXT: 'LONGTEXT'>, 'MEDIUMTEXT': <TokenType.MEDIUMTEXT: 'MEDIUMTEXT'>, 'TINYTEXT': <TokenType.TINYTEXT: 'TINYTEXT'>, 'CLOB': <TokenType.TEXT: 'TEXT'>, 'LONGVARCHAR': <TokenType.TEXT: 'TEXT'>, 'BINARY': <TokenType.VARBINARY: 'VARBINARY'>, 'BLOB': <TokenType.VARBINARY: 'VARBINARY'>, 'LONGBLOB': <TokenType.LONGBLOB: 'LONGBLOB'>, 'MEDIUMBLOB': <TokenType.MEDIUMBLOB: 'MEDIUMBLOB'>, 'TINYBLOB': <TokenType.TINYBLOB: 'TINYBLOB'>, 'BYTEA': <TokenType.VARBINARY: 'VARBINARY'>, 'VARBINARY': <TokenType.VARBINARY: 'VARBINARY'>, 'TIME': <TokenType.TIME: 'TIME'>, 'TIMETZ': <TokenType.TIMETZ: 'TIMETZ'>, 'TIMESTAMP': <TokenType.TIMESTAMP: 'TIMESTAMP'>, 'TIMESTAMPTZ': <TokenType.TIMESTAMPTZ: 'TIMESTAMPTZ'>, 'TIMESTAMPLTZ': <TokenType.TIMESTAMPLTZ: 'TIMESTAMPLTZ'>, 'TIMESTAMP_LTZ': <TokenType.TIMESTAMPLTZ: 'TIMESTAMPLTZ'>, 'TIMESTAMPNTZ': <TokenType.TIMESTAMPNTZ: 'TIMESTAMPNTZ'>, 'TIMESTAMP_NTZ': <TokenType.TIMESTAMPNTZ: 'TIMESTAMPNTZ'>, 'DATE': <TokenType.DATE: 'DATE'>, 'DATETIME': <TokenType.DATETIME: 'DATETIME'>, 'INT4RANGE': <TokenType.INT4RANGE: 'INT4RANGE'>, 'INT4MULTIRANGE': <TokenType.INT4MULTIRANGE: 'INT4MULTIRANGE'>, 'INT8RANGE': <TokenType.INT8RANGE: 'INT8RANGE'>, 'INT8MULTIRANGE': <TokenType.INT8MULTIRANGE: 'INT8MULTIRANGE'>, 'NUMRANGE': <TokenType.NUMRANGE: 'NUMRANGE'>, 'NUMMULTIRANGE': <TokenType.NUMMULTIRANGE: 'NUMMULTIRANGE'>, 'TSRANGE': <TokenType.TSRANGE: 'TSRANGE'>, 'TSMULTIRANGE': <TokenType.TSMULTIRANGE: 'TSMULTIRANGE'>, 'TSTZRANGE': <TokenType.TSTZRANGE: 'TSTZRANGE'>, 'TSTZMULTIRANGE': <TokenType.TSTZMULTIRANGE: 'TSTZMULTIRANGE'>, 'DATERANGE': <TokenType.DATERANGE: 'DATERANGE'>, 'DATEMULTIRANGE': <TokenType.DATEMULTIRANGE: 'DATEMULTIRANGE'>, 'UNIQUE': <TokenType.UNIQUE: 'UNIQUE'>, 'VECTOR': <TokenType.VECTOR: 'VECTOR'>, 'STRUCT': <TokenType.STRUCT: 'STRUCT'>, 'SEQUENCE': <TokenType.SEQUENCE: 'SEQUENCE'>, 'VARIANT': <TokenType.VARIANT: 'VARIANT'>, 'ALTER': <TokenType.ALTER: 'ALTER'>, 'ANALYZE': <TokenType.COMMAND: 'COMMAND'>, 'CALL': <TokenType.COMMAND: 'COMMAND'>, 'COMMENT': <TokenType.COMMENT: 'COMMENT'>, 'EXPLAIN': <TokenType.COMMAND: 'COMMAND'>, 'GRANT': <TokenType.COMMAND: 'COMMAND'>, 'OPTIMIZE': <TokenType.COMMAND: 'COMMAND'>, 'PREPARE': <TokenType.COMMAND: 'COMMAND'>, 'VACUUM': <TokenType.COMMAND: 'COMMAND'>, 'USER-DEFINED': <TokenType.USERDEFINED: 'USERDEFINED'>, 'FOR VERSION': <TokenType.VERSION_SNAPSHOT: 'VERSION_SNAPSHOT'>, 'FOR TIMESTAMP': <TokenType.TIMESTAMP_SNAPSHOT: 'TIMESTAMP_SNAPSHOT'>, '//': <TokenType.DIV: 'DIV'>, 'ATTACH': <TokenType.COMMAND: 'COMMAND'>, 'BITSTRING': <TokenType.BIT: 'BIT'>, 'CHARACTER VARYING': <TokenType.TEXT: 'TEXT'>, 'EXCLUDE': <TokenType.EXCEPT: 'EXCEPT'>, 'LOGICAL': <TokenType.BOOLEAN: 'BOOLEAN'>, 'ONLY': <TokenType.ONLY: 'ONLY'>, 'PIVOT_WIDER': <TokenType.PIVOT: 'PIVOT'>, 'POSITIONAL': <TokenType.POSITIONAL: 'POSITIONAL'>, 'SIGNED': <TokenType.INT: 'INT'>, 'UBIGINT': <TokenType.UBIGINT: 'UBIGINT'>, 'UINTEGER': <TokenType.UINT: 'UINT'>, 'USMALLINT': <TokenType.USMALLINT: 'USMALLINT'>, 'UTINYINT': <TokenType.UTINYINT: 'UTINYINT'>, 'TIMESTAMP_S': <TokenType.TIMESTAMP_S: 'TIMESTAMP_S'>, 'TIMESTAMP_MS': <TokenType.TIMESTAMP_MS: 'TIMESTAMP_MS'>, 'TIMESTAMP_NS': <TokenType.TIMESTAMP_NS: 'TIMESTAMP_NS'>, 'TIMESTAMP_US': <TokenType.TIMESTAMP: 'TIMESTAMP'>}</span> + <label class="view-value-button pdoc-button" for="DuckDB.Tokenizer.KEYWORDS-view-value"></label><span class="default_value">{'{%': <TokenType.BLOCK_START: 'BLOCK_START'>, '{%+': <TokenType.BLOCK_START: 'BLOCK_START'>, '{%-': <TokenType.BLOCK_START: 'BLOCK_START'>, '%}': <TokenType.BLOCK_END: 'BLOCK_END'>, '+%}': <TokenType.BLOCK_END: 'BLOCK_END'>, '-%}': <TokenType.BLOCK_END: 'BLOCK_END'>, '{{+': <TokenType.BLOCK_START: 'BLOCK_START'>, '{{-': <TokenType.BLOCK_START: 'BLOCK_START'>, '+}}': <TokenType.BLOCK_END: 'BLOCK_END'>, '-}}': <TokenType.BLOCK_END: 'BLOCK_END'>, '==': <TokenType.EQ: 'EQ'>, '::': <TokenType.DCOLON: 'DCOLON'>, '||': <TokenType.DPIPE: 'DPIPE'>, '>=': <TokenType.GTE: 'GTE'>, '<=': <TokenType.LTE: 'LTE'>, '<>': <TokenType.NEQ: 'NEQ'>, '!=': <TokenType.NEQ: 'NEQ'>, ':=': <TokenType.COLON_EQ: 'COLON_EQ'>, '<=>': <TokenType.NULLSAFE_EQ: 'NULLSAFE_EQ'>, '->': <TokenType.ARROW: 'ARROW'>, '->>': <TokenType.DARROW: 'DARROW'>, '=>': <TokenType.FARROW: 'FARROW'>, '#>': <TokenType.HASH_ARROW: 'HASH_ARROW'>, '#>>': <TokenType.DHASH_ARROW: 'DHASH_ARROW'>, '<->': <TokenType.LR_ARROW: 'LR_ARROW'>, '&&': <TokenType.DAMP: 'DAMP'>, '??': <TokenType.DQMARK: 'DQMARK'>, 'ALL': <TokenType.ALL: 'ALL'>, 'ALWAYS': <TokenType.ALWAYS: 'ALWAYS'>, 'AND': <TokenType.AND: 'AND'>, 'ANTI': <TokenType.ANTI: 'ANTI'>, 'ANY': <TokenType.ANY: 'ANY'>, 'ASC': <TokenType.ASC: 'ASC'>, 'AS': <TokenType.ALIAS: 'ALIAS'>, 'ASOF': <TokenType.ASOF: 'ASOF'>, 'AUTOINCREMENT': <TokenType.AUTO_INCREMENT: 'AUTO_INCREMENT'>, 'AUTO_INCREMENT': <TokenType.AUTO_INCREMENT: 'AUTO_INCREMENT'>, 'BEGIN': <TokenType.BEGIN: 'BEGIN'>, 'BETWEEN': <TokenType.BETWEEN: 'BETWEEN'>, 'CACHE': <TokenType.CACHE: 'CACHE'>, 'UNCACHE': <TokenType.UNCACHE: 'UNCACHE'>, 'CASE': <TokenType.CASE: 'CASE'>, 'CHARACTER SET': <TokenType.CHARACTER_SET: 'CHARACTER_SET'>, 'CLUSTER BY': <TokenType.CLUSTER_BY: 'CLUSTER_BY'>, 'COLLATE': <TokenType.COLLATE: 'COLLATE'>, 'COLUMN': <TokenType.COLUMN: 'COLUMN'>, 'COMMIT': <TokenType.COMMIT: 'COMMIT'>, 'CONNECT BY': <TokenType.CONNECT_BY: 'CONNECT_BY'>, 'CONSTRAINT': <TokenType.CONSTRAINT: 'CONSTRAINT'>, 'COPY': <TokenType.COPY: 'COPY'>, 'CREATE': <TokenType.CREATE: 'CREATE'>, 'CROSS': <TokenType.CROSS: 'CROSS'>, 'CUBE': <TokenType.CUBE: 'CUBE'>, 'CURRENT_DATE': <TokenType.CURRENT_DATE: 'CURRENT_DATE'>, 'CURRENT_TIME': <TokenType.CURRENT_TIME: 'CURRENT_TIME'>, 'CURRENT_TIMESTAMP': <TokenType.CURRENT_TIMESTAMP: 'CURRENT_TIMESTAMP'>, 'CURRENT_USER': <TokenType.CURRENT_USER: 'CURRENT_USER'>, 'DATABASE': <TokenType.DATABASE: 'DATABASE'>, 'DEFAULT': <TokenType.DEFAULT: 'DEFAULT'>, 'DELETE': <TokenType.DELETE: 'DELETE'>, 'DESC': <TokenType.DESC: 'DESC'>, 'DESCRIBE': <TokenType.DESCRIBE: 'DESCRIBE'>, 'DISTINCT': <TokenType.DISTINCT: 'DISTINCT'>, 'DISTRIBUTE BY': <TokenType.DISTRIBUTE_BY: 'DISTRIBUTE_BY'>, 'DIV': <TokenType.DIV: 'DIV'>, 'DROP': <TokenType.DROP: 'DROP'>, 'ELSE': <TokenType.ELSE: 'ELSE'>, 'END': <TokenType.END: 'END'>, 'ENUM': <TokenType.ENUM: 'ENUM'>, 'ESCAPE': <TokenType.ESCAPE: 'ESCAPE'>, 'EXCEPT': <TokenType.EXCEPT: 'EXCEPT'>, 'EXECUTE': <TokenType.EXECUTE: 'EXECUTE'>, 'EXISTS': <TokenType.EXISTS: 'EXISTS'>, 'FALSE': <TokenType.FALSE: 'FALSE'>, 'FETCH': <TokenType.FETCH: 'FETCH'>, 'FILTER': <TokenType.FILTER: 'FILTER'>, 'FIRST': <TokenType.FIRST: 'FIRST'>, 'FULL': <TokenType.FULL: 'FULL'>, 'FUNCTION': <TokenType.FUNCTION: 'FUNCTION'>, 'FOR': <TokenType.FOR: 'FOR'>, 'FOREIGN KEY': <TokenType.FOREIGN_KEY: 'FOREIGN_KEY'>, 'FORMAT': <TokenType.FORMAT: 'FORMAT'>, 'FROM': <TokenType.FROM: 'FROM'>, 'GEOGRAPHY': <TokenType.GEOGRAPHY: 'GEOGRAPHY'>, 'GEOMETRY': <TokenType.GEOMETRY: 'GEOMETRY'>, 'GLOB': <TokenType.GLOB: 'GLOB'>, 'GROUP BY': <TokenType.GROUP_BY: 'GROUP_BY'>, 'GROUPING SETS': <TokenType.GROUPING_SETS: 'GROUPING_SETS'>, 'HAVING': <TokenType.HAVING: 'HAVING'>, 'ILIKE': <TokenType.ILIKE: 'ILIKE'>, 'IN': <TokenType.IN: 'IN'>, 'INDEX': <TokenType.INDEX: 'INDEX'>, 'INET': <TokenType.INET: 'INET'>, 'INNER': <TokenType.INNER: 'INNER'>, 'INSERT': <TokenType.INSERT: 'INSERT'>, 'INTERVAL': <TokenType.INTERVAL: 'INTERVAL'>, 'INTERSECT': <TokenType.INTERSECT: 'INTERSECT'>, 'INTO': <TokenType.INTO: 'INTO'>, 'IS': <TokenType.IS: 'IS'>, 'ISNULL': <TokenType.ISNULL: 'ISNULL'>, 'JOIN': <TokenType.JOIN: 'JOIN'>, 'KEEP': <TokenType.KEEP: 'KEEP'>, 'KILL': <TokenType.KILL: 'KILL'>, 'LATERAL': <TokenType.LATERAL: 'LATERAL'>, 'LEFT': <TokenType.LEFT: 'LEFT'>, 'LIKE': <TokenType.LIKE: 'LIKE'>, 'LIMIT': <TokenType.LIMIT: 'LIMIT'>, 'LOAD': <TokenType.LOAD: 'LOAD'>, 'LOCK': <TokenType.LOCK: 'LOCK'>, 'MERGE': <TokenType.MERGE: 'MERGE'>, 'NATURAL': <TokenType.NATURAL: 'NATURAL'>, 'NEXT': <TokenType.NEXT: 'NEXT'>, 'NOT': <TokenType.NOT: 'NOT'>, 'NOTNULL': <TokenType.NOTNULL: 'NOTNULL'>, 'NULL': <TokenType.NULL: 'NULL'>, 'OBJECT': <TokenType.OBJECT: 'OBJECT'>, 'OFFSET': <TokenType.OFFSET: 'OFFSET'>, 'ON': <TokenType.ON: 'ON'>, 'OR': <TokenType.OR: 'OR'>, 'XOR': <TokenType.XOR: 'XOR'>, 'ORDER BY': <TokenType.ORDER_BY: 'ORDER_BY'>, 'ORDINALITY': <TokenType.ORDINALITY: 'ORDINALITY'>, 'OUTER': <TokenType.OUTER: 'OUTER'>, 'OVER': <TokenType.OVER: 'OVER'>, 'OVERLAPS': <TokenType.OVERLAPS: 'OVERLAPS'>, 'OVERWRITE': <TokenType.OVERWRITE: 'OVERWRITE'>, 'PARTITION': <TokenType.PARTITION: 'PARTITION'>, 'PARTITION BY': <TokenType.PARTITION_BY: 'PARTITION_BY'>, 'PARTITIONED BY': <TokenType.PARTITION_BY: 'PARTITION_BY'>, 'PARTITIONED_BY': <TokenType.PARTITION_BY: 'PARTITION_BY'>, 'PERCENT': <TokenType.PERCENT: 'PERCENT'>, 'PIVOT': <TokenType.PIVOT: 'PIVOT'>, 'PRAGMA': <TokenType.PRAGMA: 'PRAGMA'>, 'PRIMARY KEY': <TokenType.PRIMARY_KEY: 'PRIMARY_KEY'>, 'PROCEDURE': <TokenType.PROCEDURE: 'PROCEDURE'>, 'QUALIFY': <TokenType.QUALIFY: 'QUALIFY'>, 'RANGE': <TokenType.RANGE: 'RANGE'>, 'RECURSIVE': <TokenType.RECURSIVE: 'RECURSIVE'>, 'REGEXP': <TokenType.RLIKE: 'RLIKE'>, 'REPLACE': <TokenType.REPLACE: 'REPLACE'>, 'RETURNING': <TokenType.RETURNING: 'RETURNING'>, 'REFERENCES': <TokenType.REFERENCES: 'REFERENCES'>, 'RIGHT': <TokenType.RIGHT: 'RIGHT'>, 'RLIKE': <TokenType.RLIKE: 'RLIKE'>, 'ROLLBACK': <TokenType.ROLLBACK: 'ROLLBACK'>, 'ROLLUP': <TokenType.ROLLUP: 'ROLLUP'>, 'ROW': <TokenType.ROW: 'ROW'>, 'ROWS': <TokenType.ROWS: 'ROWS'>, 'SCHEMA': <TokenType.SCHEMA: 'SCHEMA'>, 'SELECT': <TokenType.SELECT: 'SELECT'>, 'SEMI': <TokenType.SEMI: 'SEMI'>, 'SET': <TokenType.SET: 'SET'>, 'SETTINGS': <TokenType.SETTINGS: 'SETTINGS'>, 'SHOW': <TokenType.SHOW: 'SHOW'>, 'SIMILAR TO': <TokenType.SIMILAR_TO: 'SIMILAR_TO'>, 'SOME': <TokenType.SOME: 'SOME'>, 'SORT BY': <TokenType.SORT_BY: 'SORT_BY'>, 'START WITH': <TokenType.START_WITH: 'START_WITH'>, 'STRAIGHT_JOIN': <TokenType.STRAIGHT_JOIN: 'STRAIGHT_JOIN'>, 'TABLE': <TokenType.TABLE: 'TABLE'>, 'TABLESAMPLE': <TokenType.TABLE_SAMPLE: 'TABLE_SAMPLE'>, 'TEMP': <TokenType.TEMPORARY: 'TEMPORARY'>, 'TEMPORARY': <TokenType.TEMPORARY: 'TEMPORARY'>, 'THEN': <TokenType.THEN: 'THEN'>, 'TRUE': <TokenType.TRUE: 'TRUE'>, 'TRUNCATE': <TokenType.TRUNCATE: 'TRUNCATE'>, 'UNION': <TokenType.UNION: 'UNION'>, 'UNKNOWN': <TokenType.UNKNOWN: 'UNKNOWN'>, 'UNNEST': <TokenType.UNNEST: 'UNNEST'>, 'UNPIVOT': <TokenType.UNPIVOT: 'UNPIVOT'>, 'UPDATE': <TokenType.UPDATE: 'UPDATE'>, 'USE': <TokenType.USE: 'USE'>, 'USING': <TokenType.USING: 'USING'>, 'UUID': <TokenType.UUID: 'UUID'>, 'VALUES': <TokenType.VALUES: 'VALUES'>, 'VIEW': <TokenType.VIEW: 'VIEW'>, 'VOLATILE': <TokenType.VOLATILE: 'VOLATILE'>, 'WHEN': <TokenType.WHEN: 'WHEN'>, 'WHERE': <TokenType.WHERE: 'WHERE'>, 'WINDOW': <TokenType.WINDOW: 'WINDOW'>, 'WITH': <TokenType.WITH: 'WITH'>, 'APPLY': <TokenType.APPLY: 'APPLY'>, 'ARRAY': <TokenType.ARRAY: 'ARRAY'>, 'BIT': <TokenType.BIT: 'BIT'>, 'BOOL': <TokenType.BOOLEAN: 'BOOLEAN'>, 'BOOLEAN': <TokenType.BOOLEAN: 'BOOLEAN'>, 'BYTE': <TokenType.TINYINT: 'TINYINT'>, 'MEDIUMINT': <TokenType.MEDIUMINT: 'MEDIUMINT'>, 'INT1': <TokenType.TINYINT: 'TINYINT'>, 'TINYINT': <TokenType.TINYINT: 'TINYINT'>, 'INT16': <TokenType.SMALLINT: 'SMALLINT'>, 'SHORT': <TokenType.SMALLINT: 'SMALLINT'>, 'SMALLINT': <TokenType.SMALLINT: 'SMALLINT'>, 'INT128': <TokenType.INT128: 'INT128'>, 'HUGEINT': <TokenType.INT128: 'INT128'>, 'INT2': <TokenType.SMALLINT: 'SMALLINT'>, 'INTEGER': <TokenType.INT: 'INT'>, 'INT': <TokenType.INT: 'INT'>, 'INT4': <TokenType.INT: 'INT'>, 'INT32': <TokenType.INT: 'INT'>, 'INT64': <TokenType.BIGINT: 'BIGINT'>, 'LONG': <TokenType.BIGINT: 'BIGINT'>, 'BIGINT': <TokenType.BIGINT: 'BIGINT'>, 'INT8': <TokenType.TINYINT: 'TINYINT'>, 'UINT': <TokenType.UINT: 'UINT'>, 'DEC': <TokenType.DECIMAL: 'DECIMAL'>, 'DECIMAL': <TokenType.DECIMAL: 'DECIMAL'>, 'BIGDECIMAL': <TokenType.BIGDECIMAL: 'BIGDECIMAL'>, 'BIGNUMERIC': <TokenType.BIGDECIMAL: 'BIGDECIMAL'>, 'LIST': <TokenType.LIST: 'LIST'>, 'MAP': <TokenType.MAP: 'MAP'>, 'NULLABLE': <TokenType.NULLABLE: 'NULLABLE'>, 'NUMBER': <TokenType.DECIMAL: 'DECIMAL'>, 'NUMERIC': <TokenType.DECIMAL: 'DECIMAL'>, 'FIXED': <TokenType.DECIMAL: 'DECIMAL'>, 'REAL': <TokenType.FLOAT: 'FLOAT'>, 'FLOAT': <TokenType.FLOAT: 'FLOAT'>, 'FLOAT4': <TokenType.FLOAT: 'FLOAT'>, 'FLOAT8': <TokenType.DOUBLE: 'DOUBLE'>, 'DOUBLE': <TokenType.DOUBLE: 'DOUBLE'>, 'DOUBLE PRECISION': <TokenType.DOUBLE: 'DOUBLE'>, 'JSON': <TokenType.JSON: 'JSON'>, 'JSONB': <TokenType.JSONB: 'JSONB'>, 'CHAR': <TokenType.TEXT: 'TEXT'>, 'CHARACTER': <TokenType.CHAR: 'CHAR'>, 'NCHAR': <TokenType.NCHAR: 'NCHAR'>, 'VARCHAR': <TokenType.TEXT: 'TEXT'>, 'VARCHAR2': <TokenType.VARCHAR: 'VARCHAR'>, 'NVARCHAR': <TokenType.NVARCHAR: 'NVARCHAR'>, 'NVARCHAR2': <TokenType.NVARCHAR: 'NVARCHAR'>, 'BPCHAR': <TokenType.TEXT: 'TEXT'>, 'STR': <TokenType.TEXT: 'TEXT'>, 'STRING': <TokenType.TEXT: 'TEXT'>, 'TEXT': <TokenType.TEXT: 'TEXT'>, 'LONGTEXT': <TokenType.LONGTEXT: 'LONGTEXT'>, 'MEDIUMTEXT': <TokenType.MEDIUMTEXT: 'MEDIUMTEXT'>, 'TINYTEXT': <TokenType.TINYTEXT: 'TINYTEXT'>, 'CLOB': <TokenType.TEXT: 'TEXT'>, 'LONGVARCHAR': <TokenType.TEXT: 'TEXT'>, 'BINARY': <TokenType.VARBINARY: 'VARBINARY'>, 'BLOB': <TokenType.VARBINARY: 'VARBINARY'>, 'LONGBLOB': <TokenType.LONGBLOB: 'LONGBLOB'>, 'MEDIUMBLOB': <TokenType.MEDIUMBLOB: 'MEDIUMBLOB'>, 'TINYBLOB': <TokenType.TINYBLOB: 'TINYBLOB'>, 'BYTEA': <TokenType.VARBINARY: 'VARBINARY'>, 'VARBINARY': <TokenType.VARBINARY: 'VARBINARY'>, 'TIME': <TokenType.TIME: 'TIME'>, 'TIMETZ': <TokenType.TIMETZ: 'TIMETZ'>, 'TIMESTAMP': <TokenType.TIMESTAMP: 'TIMESTAMP'>, 'TIMESTAMPTZ': <TokenType.TIMESTAMPTZ: 'TIMESTAMPTZ'>, 'TIMESTAMPLTZ': <TokenType.TIMESTAMPLTZ: 'TIMESTAMPLTZ'>, 'TIMESTAMP_LTZ': <TokenType.TIMESTAMPLTZ: 'TIMESTAMPLTZ'>, 'TIMESTAMPNTZ': <TokenType.TIMESTAMPNTZ: 'TIMESTAMPNTZ'>, 'TIMESTAMP_NTZ': <TokenType.TIMESTAMPNTZ: 'TIMESTAMPNTZ'>, 'DATE': <TokenType.DATE: 'DATE'>, 'DATETIME': <TokenType.DATETIME: 'DATETIME'>, 'INT4RANGE': <TokenType.INT4RANGE: 'INT4RANGE'>, 'INT4MULTIRANGE': <TokenType.INT4MULTIRANGE: 'INT4MULTIRANGE'>, 'INT8RANGE': <TokenType.INT8RANGE: 'INT8RANGE'>, 'INT8MULTIRANGE': <TokenType.INT8MULTIRANGE: 'INT8MULTIRANGE'>, 'NUMRANGE': <TokenType.NUMRANGE: 'NUMRANGE'>, 'NUMMULTIRANGE': <TokenType.NUMMULTIRANGE: 'NUMMULTIRANGE'>, 'TSRANGE': <TokenType.TSRANGE: 'TSRANGE'>, 'TSMULTIRANGE': <TokenType.TSMULTIRANGE: 'TSMULTIRANGE'>, 'TSTZRANGE': <TokenType.TSTZRANGE: 'TSTZRANGE'>, 'TSTZMULTIRANGE': <TokenType.TSTZMULTIRANGE: 'TSTZMULTIRANGE'>, 'DATERANGE': <TokenType.DATERANGE: 'DATERANGE'>, 'DATEMULTIRANGE': <TokenType.DATEMULTIRANGE: 'DATEMULTIRANGE'>, 'UNIQUE': <TokenType.UNIQUE: 'UNIQUE'>, 'VECTOR': <TokenType.VECTOR: 'VECTOR'>, 'STRUCT': <TokenType.STRUCT: 'STRUCT'>, 'SEQUENCE': <TokenType.SEQUENCE: 'SEQUENCE'>, 'VARIANT': <TokenType.VARIANT: 'VARIANT'>, 'ALTER': <TokenType.ALTER: 'ALTER'>, 'ANALYZE': <TokenType.COMMAND: 'COMMAND'>, 'CALL': <TokenType.COMMAND: 'COMMAND'>, 'COMMENT': <TokenType.COMMENT: 'COMMENT'>, 'EXPLAIN': <TokenType.COMMAND: 'COMMAND'>, 'GRANT': <TokenType.COMMAND: 'COMMAND'>, 'OPTIMIZE': <TokenType.COMMAND: 'COMMAND'>, 'PREPARE': <TokenType.COMMAND: 'COMMAND'>, 'VACUUM': <TokenType.COMMAND: 'COMMAND'>, 'USER-DEFINED': <TokenType.USERDEFINED: 'USERDEFINED'>, 'FOR VERSION': <TokenType.VERSION_SNAPSHOT: 'VERSION_SNAPSHOT'>, 'FOR TIMESTAMP': <TokenType.TIMESTAMP_SNAPSHOT: 'TIMESTAMP_SNAPSHOT'>, '//': <TokenType.DIV: 'DIV'>, 'ATTACH': <TokenType.COMMAND: 'COMMAND'>, 'BITSTRING': <TokenType.BIT: 'BIT'>, 'CHARACTER VARYING': <TokenType.TEXT: 'TEXT'>, 'EXCLUDE': <TokenType.EXCEPT: 'EXCEPT'>, 'LOGICAL': <TokenType.BOOLEAN: 'BOOLEAN'>, 'ONLY': <TokenType.ONLY: 'ONLY'>, 'PIVOT_WIDER': <TokenType.PIVOT: 'PIVOT'>, 'POSITIONAL': <TokenType.POSITIONAL: 'POSITIONAL'>, 'SIGNED': <TokenType.INT: 'INT'>, 'SUMMARIZE': <TokenType.SUMMARIZE: 'SUMMARIZE'>, 'TIMESTAMP_S': <TokenType.TIMESTAMP_S: 'TIMESTAMP_S'>, 'TIMESTAMP_MS': <TokenType.TIMESTAMP_MS: 'TIMESTAMP_MS'>, 'TIMESTAMP_NS': <TokenType.TIMESTAMP_NS: 'TIMESTAMP_NS'>, 'TIMESTAMP_US': <TokenType.TIMESTAMP: 'TIMESTAMP'>, 'UBIGINT': <TokenType.UBIGINT: 'UBIGINT'>, 'UINTEGER': <TokenType.UINT: 'UINT'>, 'USMALLINT': <TokenType.USMALLINT: 'USMALLINT'>, 'UTINYINT': <TokenType.UTINYINT: 'UTINYINT'>}</span> </div> @@ -2490,136 +2512,136 @@ Possible values: <code>"nulls_are_small"</code>, <code>"nulls_are_large"</code>, </div> <a class="headerlink" href="#DuckDB.Parser"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DuckDB.Parser-259"><a href="#DuckDB.Parser-259"><span class="linenos">259</span></a> <span class="k">class</span> <span class="nc">Parser</span><span class="p">(</span><span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="p">):</span> -</span><span id="DuckDB.Parser-260"><a href="#DuckDB.Parser-260"><span class="linenos">260</span></a> <span class="n">BITWISE</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="DuckDB.Parser-261"><a href="#DuckDB.Parser-261"><span class="linenos">261</span></a> <span class="o">**</span><span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">BITWISE</span><span class="p">,</span> -</span><span id="DuckDB.Parser-262"><a href="#DuckDB.Parser-262"><span class="linenos">262</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">TILDA</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpLike</span><span class="p">,</span> -</span><span id="DuckDB.Parser-263"><a href="#DuckDB.Parser-263"><span class="linenos">263</span></a> <span class="p">}</span> -</span><span id="DuckDB.Parser-264"><a href="#DuckDB.Parser-264"><span class="linenos">264</span></a> -</span><span id="DuckDB.Parser-265"><a href="#DuckDB.Parser-265"><span class="linenos">265</span></a> <span class="n">FUNCTIONS_WITH_ALIASED_ARGS</span> <span class="o">=</span> <span class="p">{</span><span class="o">*</span><span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">FUNCTIONS_WITH_ALIASED_ARGS</span><span class="p">,</span> <span class="s2">"STRUCT_PACK"</span><span class="p">}</span> -</span><span id="DuckDB.Parser-266"><a href="#DuckDB.Parser-266"><span class="linenos">266</span></a> -</span><span id="DuckDB.Parser-267"><a href="#DuckDB.Parser-267"><span class="linenos">267</span></a> <span class="n">FUNCTIONS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="DuckDB.Parser-268"><a href="#DuckDB.Parser-268"><span class="linenos">268</span></a> <span class="o">**</span><span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">FUNCTIONS</span><span class="p">,</span> -</span><span id="DuckDB.Parser-269"><a href="#DuckDB.Parser-269"><span class="linenos">269</span></a> <span class="s2">"ARRAY_REVERSE_SORT"</span><span class="p">:</span> <span class="n">_build_sort_array_desc</span><span class="p">,</span> -</span><span id="DuckDB.Parser-270"><a href="#DuckDB.Parser-270"><span class="linenos">270</span></a> <span class="s2">"ARRAY_SORT"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SortArray</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="DuckDB.Parser-271"><a href="#DuckDB.Parser-271"><span class="linenos">271</span></a> <span class="s2">"DATEDIFF"</span><span class="p">:</span> <span class="n">_build_date_diff</span><span class="p">,</span> -</span><span id="DuckDB.Parser-272"><a href="#DuckDB.Parser-272"><span class="linenos">272</span></a> <span class="s2">"DATE_DIFF"</span><span class="p">:</span> <span class="n">_build_date_diff</span><span class="p">,</span> -</span><span id="DuckDB.Parser-273"><a href="#DuckDB.Parser-273"><span class="linenos">273</span></a> <span class="s2">"DATE_TRUNC"</span><span class="p">:</span> <span class="n">date_trunc_to_time</span><span class="p">,</span> -</span><span id="DuckDB.Parser-274"><a href="#DuckDB.Parser-274"><span class="linenos">274</span></a> <span class="s2">"DATETRUNC"</span><span class="p">:</span> <span class="n">date_trunc_to_time</span><span class="p">,</span> -</span><span id="DuckDB.Parser-275"><a href="#DuckDB.Parser-275"><span class="linenos">275</span></a> <span class="s2">"DECODE"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Decode</span><span class="p">(</span> -</span><span id="DuckDB.Parser-276"><a href="#DuckDB.Parser-276"><span class="linenos">276</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">charset</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">string</span><span class="p">(</span><span class="s2">"utf-8"</span><span class="p">)</span> -</span><span id="DuckDB.Parser-277"><a href="#DuckDB.Parser-277"><span class="linenos">277</span></a> <span class="p">),</span> -</span><span id="DuckDB.Parser-278"><a href="#DuckDB.Parser-278"><span class="linenos">278</span></a> <span class="s2">"ENCODE"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Encode</span><span class="p">(</span> -</span><span id="DuckDB.Parser-279"><a href="#DuckDB.Parser-279"><span class="linenos">279</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">charset</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">string</span><span class="p">(</span><span class="s2">"utf-8"</span><span class="p">)</span> -</span><span id="DuckDB.Parser-280"><a href="#DuckDB.Parser-280"><span class="linenos">280</span></a> <span class="p">),</span> -</span><span id="DuckDB.Parser-281"><a href="#DuckDB.Parser-281"><span class="linenos">281</span></a> <span class="s2">"EPOCH"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TimeToUnix</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="DuckDB.Parser-282"><a href="#DuckDB.Parser-282"><span class="linenos">282</span></a> <span class="s2">"EPOCH_MS"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToTime</span><span class="p">(</span> -</span><span id="DuckDB.Parser-283"><a href="#DuckDB.Parser-283"><span class="linenos">283</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">scale</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">UnixToTime</span><span class="o">.</span><span class="n">MILLIS</span> -</span><span id="DuckDB.Parser-284"><a href="#DuckDB.Parser-284"><span class="linenos">284</span></a> <span class="p">),</span> -</span><span id="DuckDB.Parser-285"><a href="#DuckDB.Parser-285"><span class="linenos">285</span></a> <span class="s2">"JSON"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ParseJSON</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="DuckDB.Parser-286"><a href="#DuckDB.Parser-286"><span class="linenos">286</span></a> <span class="s2">"JSON_EXTRACT_PATH"</span><span class="p">:</span> <span class="n">parser</span><span class="o">.</span><span class="n">build_extract_json_with_path</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">JSONExtract</span><span class="p">),</span> -</span><span id="DuckDB.Parser-287"><a href="#DuckDB.Parser-287"><span class="linenos">287</span></a> <span class="s2">"JSON_EXTRACT_STRING"</span><span class="p">:</span> <span class="n">parser</span><span class="o">.</span><span class="n">build_extract_json_with_path</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">JSONExtractScalar</span><span class="p">),</span> -</span><span id="DuckDB.Parser-288"><a href="#DuckDB.Parser-288"><span class="linenos">288</span></a> <span class="s2">"LIST_HAS"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayContains</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="DuckDB.Parser-289"><a href="#DuckDB.Parser-289"><span class="linenos">289</span></a> <span class="s2">"LIST_REVERSE_SORT"</span><span class="p">:</span> <span class="n">_build_sort_array_desc</span><span class="p">,</span> -</span><span id="DuckDB.Parser-290"><a href="#DuckDB.Parser-290"><span class="linenos">290</span></a> <span class="s2">"LIST_SORT"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SortArray</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="DuckDB.Parser-291"><a href="#DuckDB.Parser-291"><span class="linenos">291</span></a> <span class="s2">"LIST_VALUE"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Array</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="DuckDB.Parser-292"><a href="#DuckDB.Parser-292"><span class="linenos">292</span></a> <span class="s2">"MAKE_TIME"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TimeFromParts</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="DuckDB.Parser-293"><a href="#DuckDB.Parser-293"><span class="linenos">293</span></a> <span class="s2">"MAKE_TIMESTAMP"</span><span class="p">:</span> <span class="n">_build_make_timestamp</span><span class="p">,</span> -</span><span id="DuckDB.Parser-294"><a href="#DuckDB.Parser-294"><span class="linenos">294</span></a> <span class="s2">"MEDIAN"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">PercentileCont</span><span class="p">(</span> -</span><span id="DuckDB.Parser-295"><a href="#DuckDB.Parser-295"><span class="linenos">295</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">number</span><span class="p">(</span><span class="mf">0.5</span><span class="p">)</span> -</span><span id="DuckDB.Parser-296"><a href="#DuckDB.Parser-296"><span class="linenos">296</span></a> <span class="p">),</span> -</span><span id="DuckDB.Parser-297"><a href="#DuckDB.Parser-297"><span class="linenos">297</span></a> <span class="s2">"QUANTILE_CONT"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">PercentileCont</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="DuckDB.Parser-298"><a href="#DuckDB.Parser-298"><span class="linenos">298</span></a> <span class="s2">"QUANTILE_DISC"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">PercentileDisc</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="DuckDB.Parser-299"><a href="#DuckDB.Parser-299"><span class="linenos">299</span></a> <span class="s2">"REGEXP_EXTRACT"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpExtract</span><span class="p">(</span> -</span><span id="DuckDB.Parser-300"><a href="#DuckDB.Parser-300"><span class="linenos">300</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">expression</span><span class="o">=</span><span class="n">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 class="n">group</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">2</span><span class="p">)</span> -</span><span id="DuckDB.Parser-301"><a href="#DuckDB.Parser-301"><span class="linenos">301</span></a> <span class="p">),</span> -</span><span id="DuckDB.Parser-302"><a href="#DuckDB.Parser-302"><span class="linenos">302</span></a> <span class="s2">"REGEXP_MATCHES"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpLike</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="DuckDB.Parser-303"><a href="#DuckDB.Parser-303"><span class="linenos">303</span></a> <span class="s2">"REGEXP_REPLACE"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpReplace</span><span class="p">(</span> -</span><span id="DuckDB.Parser-304"><a href="#DuckDB.Parser-304"><span class="linenos">304</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> -</span><span id="DuckDB.Parser-305"><a href="#DuckDB.Parser-305"><span class="linenos">305</span></a> <span class="n">expression</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-306"><a href="#DuckDB.Parser-306"><span class="linenos">306</span></a> <span class="n">replacement</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">2</span><span class="p">),</span> -</span><span id="DuckDB.Parser-307"><a href="#DuckDB.Parser-307"><span class="linenos">307</span></a> <span class="n">modifiers</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">3</span><span class="p">),</span> -</span><span id="DuckDB.Parser-308"><a href="#DuckDB.Parser-308"><span class="linenos">308</span></a> <span class="p">),</span> -</span><span id="DuckDB.Parser-309"><a href="#DuckDB.Parser-309"><span class="linenos">309</span></a> <span class="s2">"STRFTIME"</span><span class="p">:</span> <span class="n">build_formatted_time</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">TimeToStr</span><span class="p">,</span> <span class="s2">"duckdb"</span><span class="p">),</span> -</span><span id="DuckDB.Parser-310"><a href="#DuckDB.Parser-310"><span class="linenos">310</span></a> <span class="s2">"STRING_SPLIT"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Split</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="DuckDB.Parser-311"><a href="#DuckDB.Parser-311"><span class="linenos">311</span></a> <span class="s2">"STRING_SPLIT_REGEX"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpSplit</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="DuckDB.Parser-312"><a href="#DuckDB.Parser-312"><span class="linenos">312</span></a> <span class="s2">"STRING_TO_ARRAY"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Split</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="DuckDB.Parser-313"><a href="#DuckDB.Parser-313"><span class="linenos">313</span></a> <span class="s2">"STRPTIME"</span><span class="p">:</span> <span class="n">build_formatted_time</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">StrToTime</span><span class="p">,</span> <span class="s2">"duckdb"</span><span class="p">),</span> -</span><span id="DuckDB.Parser-314"><a href="#DuckDB.Parser-314"><span class="linenos">314</span></a> <span class="s2">"STRUCT_PACK"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Struct</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="DuckDB.Parser-315"><a href="#DuckDB.Parser-315"><span class="linenos">315</span></a> <span class="s2">"STR_SPLIT"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Split</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="DuckDB.Parser-316"><a href="#DuckDB.Parser-316"><span class="linenos">316</span></a> <span class="s2">"STR_SPLIT_REGEX"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpSplit</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="DuckDB.Parser-317"><a href="#DuckDB.Parser-317"><span class="linenos">317</span></a> <span class="s2">"TO_TIMESTAMP"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToTime</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="DuckDB.Parser-318"><a href="#DuckDB.Parser-318"><span class="linenos">318</span></a> <span class="s2">"UNNEST"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Explode</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="DuckDB.Parser-319"><a href="#DuckDB.Parser-319"><span class="linenos">319</span></a> <span class="s2">"XOR"</span><span class="p">:</span> <span class="n">binary_from_function</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">BitwiseXor</span><span class="p">),</span> -</span><span id="DuckDB.Parser-320"><a href="#DuckDB.Parser-320"><span class="linenos">320</span></a> <span class="s2">"GENERATE_SERIES"</span><span class="p">:</span> <span class="n">_build_generate_series</span><span class="p">(),</span> -</span><span id="DuckDB.Parser-321"><a href="#DuckDB.Parser-321"><span class="linenos">321</span></a> <span class="s2">"RANGE"</span><span class="p">:</span> <span class="n">_build_generate_series</span><span class="p">(</span><span class="n">end_exclusive</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> -</span><span id="DuckDB.Parser-322"><a href="#DuckDB.Parser-322"><span class="linenos">322</span></a> <span class="p">}</span> -</span><span id="DuckDB.Parser-323"><a href="#DuckDB.Parser-323"><span class="linenos">323</span></a> -</span><span id="DuckDB.Parser-324"><a href="#DuckDB.Parser-324"><span class="linenos">324</span></a> <span class="n">FUNCTIONS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">"DATE_SUB"</span><span class="p">)</span> -</span><span id="DuckDB.Parser-325"><a href="#DuckDB.Parser-325"><span class="linenos">325</span></a> -</span><span id="DuckDB.Parser-326"><a href="#DuckDB.Parser-326"><span class="linenos">326</span></a> <span class="n">FUNCTION_PARSERS</span> <span class="o">=</span> <span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">FUNCTION_PARSERS</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> -</span><span id="DuckDB.Parser-327"><a href="#DuckDB.Parser-327"><span class="linenos">327</span></a> <span class="n">FUNCTION_PARSERS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">"DECODE"</span><span class="p">)</span> -</span><span id="DuckDB.Parser-328"><a href="#DuckDB.Parser-328"><span class="linenos">328</span></a> -</span><span id="DuckDB.Parser-329"><a href="#DuckDB.Parser-329"><span class="linenos">329</span></a> <span class="n">NO_PAREN_FUNCTION_PARSERS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="DuckDB.Parser-330"><a href="#DuckDB.Parser-330"><span class="linenos">330</span></a> <span class="o">**</span><span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">NO_PAREN_FUNCTION_PARSERS</span><span class="p">,</span> -</span><span id="DuckDB.Parser-331"><a href="#DuckDB.Parser-331"><span class="linenos">331</span></a> <span class="s2">"MAP"</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_map</span><span class="p">(),</span> -</span><span id="DuckDB.Parser-332"><a href="#DuckDB.Parser-332"><span class="linenos">332</span></a> <span class="p">}</span> -</span><span id="DuckDB.Parser-333"><a href="#DuckDB.Parser-333"><span class="linenos">333</span></a> -</span><span id="DuckDB.Parser-334"><a href="#DuckDB.Parser-334"><span class="linenos">334</span></a> <span class="n">TABLE_ALIAS_TOKENS</span> <span class="o">=</span> <span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">TABLE_ALIAS_TOKENS</span> <span class="o">-</span> <span class="p">{</span> -</span><span id="DuckDB.Parser-335"><a href="#DuckDB.Parser-335"><span class="linenos">335</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">SEMI</span><span class="p">,</span> -</span><span id="DuckDB.Parser-336"><a href="#DuckDB.Parser-336"><span class="linenos">336</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">ANTI</span><span class="p">,</span> -</span><span id="DuckDB.Parser-337"><a href="#DuckDB.Parser-337"><span class="linenos">337</span></a> <span class="p">}</span> -</span><span id="DuckDB.Parser-338"><a href="#DuckDB.Parser-338"><span class="linenos">338</span></a> -</span><span id="DuckDB.Parser-339"><a href="#DuckDB.Parser-339"><span class="linenos">339</span></a> <span class="n">PLACEHOLDER_PARSERS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="DuckDB.Parser-340"><a href="#DuckDB.Parser-340"><span class="linenos">340</span></a> <span class="o">**</span><span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">PLACEHOLDER_PARSERS</span><span class="p">,</span> -</span><span id="DuckDB.Parser-341"><a href="#DuckDB.Parser-341"><span class="linenos">341</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">PARAMETER</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">:</span> <span class="p">(</span> -</span><span id="DuckDB.Parser-342"><a href="#DuckDB.Parser-342"><span class="linenos">342</span></a> <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">Placeholder</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">_prev</span><span class="o">.</span><span class="n">text</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">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">NUMBER</span><span class="p">)</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_set</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">ID_VAR_TOKENS</span><span class="p">)</span> -</span><span id="DuckDB.Parser-344"><a href="#DuckDB.Parser-344"><span class="linenos">344</span></a> <span class="k">else</span> <span class="kc">None</span> -</span><span id="DuckDB.Parser-345"><a href="#DuckDB.Parser-345"><span class="linenos">345</span></a> <span class="p">),</span> -</span><span id="DuckDB.Parser-346"><a href="#DuckDB.Parser-346"><span class="linenos">346</span></a> <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="n">TYPE_CONVERTERS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="DuckDB.Parser-349"><a href="#DuckDB.Parser-349"><span class="linenos">349</span></a> <span class="c1"># https://duckdb.org/docs/sql/data_types/numeric</span> -</span><span id="DuckDB.Parser-350"><a href="#DuckDB.Parser-350"><span class="linenos">350</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">DECIMAL</span><span class="p">:</span> <span class="n">build_default_decimal_type</span><span class="p">(</span><span class="n">precision</span><span class="o">=</span><span class="mi">18</span><span class="p">,</span> <span class="n">scale</span><span class="o">=</span><span class="mi">3</span><span class="p">),</span> -</span><span id="DuckDB.Parser-351"><a href="#DuckDB.Parser-351"><span class="linenos">351</span></a> <span class="c1"># https://duckdb.org/docs/sql/data_types/text</span> -</span><span id="DuckDB.Parser-352"><a href="#DuckDB.Parser-352"><span class="linenos">352</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">TEXT</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">dtype</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">build</span><span class="p">(</span><span class="s2">"TEXT"</span><span class="p">),</span> -</span><span id="DuckDB.Parser-353"><a href="#DuckDB.Parser-353"><span class="linenos">353</span></a> <span class="p">}</span> -</span><span id="DuckDB.Parser-354"><a href="#DuckDB.Parser-354"><span class="linenos">354</span></a> -</span><span id="DuckDB.Parser-355"><a href="#DuckDB.Parser-355"><span class="linenos">355</span></a> <span class="k">def</span> <span class="nf">_parse_table_sample</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">as_modifier</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">TableSample</span><span class="p">]:</span> -</span><span id="DuckDB.Parser-356"><a href="#DuckDB.Parser-356"><span class="linenos">356</span></a> <span class="c1"># https://duckdb.org/docs/sql/samples.html</span> -</span><span id="DuckDB.Parser-357"><a href="#DuckDB.Parser-357"><span class="linenos">357</span></a> <span class="n">sample</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_parse_table_sample</span><span class="p">(</span><span class="n">as_modifier</span><span class="o">=</span><span class="n">as_modifier</span><span class="p">)</span> -</span><span id="DuckDB.Parser-358"><a href="#DuckDB.Parser-358"><span class="linenos">358</span></a> <span class="k">if</span> <span class="n">sample</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">sample</span><span 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.Parser-359"><a href="#DuckDB.Parser-359"><span class="linenos">359</span></a> <span class="k">if</span> <span class="n">sample</span><span 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.Parser-360"><a href="#DuckDB.Parser-360"><span class="linenos">360</span></a> <span class="n">sample</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.Parser-361"><a href="#DuckDB.Parser-361"><span class="linenos">361</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="DuckDB.Parser-362"><a href="#DuckDB.Parser-362"><span class="linenos">362</span></a> <span class="n">sample</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">"SYSTEM"</span><span class="p">))</span> -</span><span id="DuckDB.Parser-363"><a href="#DuckDB.Parser-363"><span class="linenos">363</span></a> -</span><span id="DuckDB.Parser-364"><a href="#DuckDB.Parser-364"><span class="linenos">364</span></a> <span class="k">return</span> <span class="n">sample</span> -</span><span id="DuckDB.Parser-365"><a href="#DuckDB.Parser-365"><span class="linenos">365</span></a> -</span><span id="DuckDB.Parser-366"><a href="#DuckDB.Parser-366"><span class="linenos">366</span></a> <span class="k">def</span> <span class="nf">_parse_bracket</span><span class="p">(</span> -</span><span id="DuckDB.Parser-367"><a href="#DuckDB.Parser-367"><span class="linenos">367</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">this</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="DuckDB.Parser-368"><a href="#DuckDB.Parser-368"><span class="linenos">368</span></a> <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> -</span><span id="DuckDB.Parser-369"><a href="#DuckDB.Parser-369"><span class="linenos">369</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">_parse_bracket</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> -</span><span id="DuckDB.Parser-370"><a href="#DuckDB.Parser-370"><span class="linenos">370</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">bracket</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Bracket</span><span class="p">):</span> -</span><span id="DuckDB.Parser-371"><a href="#DuckDB.Parser-371"><span class="linenos">371</span></a> <span class="n">bracket</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"returns_list_for_maps"</span><span class="p">,</span> <span class="kc">True</span><span class="p">)</span> -</span><span id="DuckDB.Parser-372"><a href="#DuckDB.Parser-372"><span class="linenos">372</span></a> -</span><span id="DuckDB.Parser-373"><a href="#DuckDB.Parser-373"><span class="linenos">373</span></a> <span class="k">return</span> <span class="n">bracket</span> -</span><span id="DuckDB.Parser-374"><a href="#DuckDB.Parser-374"><span class="linenos">374</span></a> -</span><span id="DuckDB.Parser-375"><a href="#DuckDB.Parser-375"><span class="linenos">375</span></a> <span class="k">def</span> <span class="nf">_parse_map</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">ToMap</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Map</span><span class="p">:</span> -</span><span id="DuckDB.Parser-376"><a href="#DuckDB.Parser-376"><span class="linenos">376</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-377"><a href="#DuckDB.Parser-377"><span class="linenos">377</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> + <div class="pdoc-code codehilite"><pre><span></span><span id="DuckDB.Parser-265"><a href="#DuckDB.Parser-265"><span class="linenos">265</span></a> <span class="k">class</span> <span class="nc">Parser</span><span class="p">(</span><span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="p">):</span> +</span><span id="DuckDB.Parser-266"><a href="#DuckDB.Parser-266"><span class="linenos">266</span></a> <span class="n">BITWISE</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="DuckDB.Parser-267"><a href="#DuckDB.Parser-267"><span class="linenos">267</span></a> <span class="o">**</span><span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">BITWISE</span><span class="p">,</span> +</span><span id="DuckDB.Parser-268"><a href="#DuckDB.Parser-268"><span class="linenos">268</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">TILDA</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpLike</span><span class="p">,</span> +</span><span id="DuckDB.Parser-269"><a href="#DuckDB.Parser-269"><span class="linenos">269</span></a> <span class="p">}</span> +</span><span id="DuckDB.Parser-270"><a href="#DuckDB.Parser-270"><span class="linenos">270</span></a> +</span><span id="DuckDB.Parser-271"><a href="#DuckDB.Parser-271"><span class="linenos">271</span></a> <span class="n">FUNCTIONS_WITH_ALIASED_ARGS</span> <span class="o">=</span> <span class="p">{</span><span class="o">*</span><span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">FUNCTIONS_WITH_ALIASED_ARGS</span><span class="p">,</span> <span class="s2">"STRUCT_PACK"</span><span class="p">}</span> +</span><span id="DuckDB.Parser-272"><a href="#DuckDB.Parser-272"><span class="linenos">272</span></a> +</span><span id="DuckDB.Parser-273"><a href="#DuckDB.Parser-273"><span class="linenos">273</span></a> <span class="n">FUNCTIONS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="DuckDB.Parser-274"><a href="#DuckDB.Parser-274"><span class="linenos">274</span></a> <span class="o">**</span><span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">FUNCTIONS</span><span class="p">,</span> +</span><span id="DuckDB.Parser-275"><a href="#DuckDB.Parser-275"><span class="linenos">275</span></a> <span class="s2">"ARRAY_REVERSE_SORT"</span><span class="p">:</span> <span class="n">_build_sort_array_desc</span><span class="p">,</span> +</span><span id="DuckDB.Parser-276"><a href="#DuckDB.Parser-276"><span class="linenos">276</span></a> <span class="s2">"ARRAY_SORT"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SortArray</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="DuckDB.Parser-277"><a href="#DuckDB.Parser-277"><span class="linenos">277</span></a> <span class="s2">"DATEDIFF"</span><span class="p">:</span> <span class="n">_build_date_diff</span><span class="p">,</span> +</span><span id="DuckDB.Parser-278"><a href="#DuckDB.Parser-278"><span class="linenos">278</span></a> <span class="s2">"DATE_DIFF"</span><span class="p">:</span> <span class="n">_build_date_diff</span><span class="p">,</span> +</span><span id="DuckDB.Parser-279"><a href="#DuckDB.Parser-279"><span class="linenos">279</span></a> <span class="s2">"DATE_TRUNC"</span><span class="p">:</span> <span class="n">date_trunc_to_time</span><span class="p">,</span> +</span><span id="DuckDB.Parser-280"><a href="#DuckDB.Parser-280"><span class="linenos">280</span></a> <span class="s2">"DATETRUNC"</span><span class="p">:</span> <span class="n">date_trunc_to_time</span><span class="p">,</span> +</span><span id="DuckDB.Parser-281"><a href="#DuckDB.Parser-281"><span class="linenos">281</span></a> <span class="s2">"DECODE"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Decode</span><span class="p">(</span> +</span><span id="DuckDB.Parser-282"><a href="#DuckDB.Parser-282"><span class="linenos">282</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">charset</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">string</span><span class="p">(</span><span class="s2">"utf-8"</span><span class="p">)</span> +</span><span id="DuckDB.Parser-283"><a href="#DuckDB.Parser-283"><span class="linenos">283</span></a> <span class="p">),</span> +</span><span id="DuckDB.Parser-284"><a href="#DuckDB.Parser-284"><span class="linenos">284</span></a> <span class="s2">"ENCODE"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Encode</span><span class="p">(</span> +</span><span id="DuckDB.Parser-285"><a href="#DuckDB.Parser-285"><span class="linenos">285</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">charset</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">string</span><span class="p">(</span><span class="s2">"utf-8"</span><span class="p">)</span> +</span><span id="DuckDB.Parser-286"><a href="#DuckDB.Parser-286"><span class="linenos">286</span></a> <span class="p">),</span> +</span><span id="DuckDB.Parser-287"><a href="#DuckDB.Parser-287"><span class="linenos">287</span></a> <span class="s2">"EPOCH"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TimeToUnix</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="DuckDB.Parser-288"><a href="#DuckDB.Parser-288"><span class="linenos">288</span></a> <span class="s2">"EPOCH_MS"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToTime</span><span class="p">(</span> +</span><span id="DuckDB.Parser-289"><a href="#DuckDB.Parser-289"><span class="linenos">289</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">scale</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">UnixToTime</span><span class="o">.</span><span class="n">MILLIS</span> +</span><span id="DuckDB.Parser-290"><a href="#DuckDB.Parser-290"><span class="linenos">290</span></a> <span class="p">),</span> +</span><span id="DuckDB.Parser-291"><a href="#DuckDB.Parser-291"><span class="linenos">291</span></a> <span class="s2">"JSON"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ParseJSON</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="DuckDB.Parser-292"><a href="#DuckDB.Parser-292"><span class="linenos">292</span></a> <span class="s2">"JSON_EXTRACT_PATH"</span><span class="p">:</span> <span class="n">parser</span><span class="o">.</span><span class="n">build_extract_json_with_path</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">JSONExtract</span><span class="p">),</span> +</span><span id="DuckDB.Parser-293"><a href="#DuckDB.Parser-293"><span class="linenos">293</span></a> <span class="s2">"JSON_EXTRACT_STRING"</span><span class="p">:</span> <span class="n">parser</span><span class="o">.</span><span class="n">build_extract_json_with_path</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">JSONExtractScalar</span><span class="p">),</span> +</span><span id="DuckDB.Parser-294"><a href="#DuckDB.Parser-294"><span class="linenos">294</span></a> <span class="s2">"LIST_HAS"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayContains</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="DuckDB.Parser-295"><a href="#DuckDB.Parser-295"><span class="linenos">295</span></a> <span class="s2">"LIST_REVERSE_SORT"</span><span class="p">:</span> <span class="n">_build_sort_array_desc</span><span class="p">,</span> +</span><span id="DuckDB.Parser-296"><a href="#DuckDB.Parser-296"><span class="linenos">296</span></a> <span class="s2">"LIST_SORT"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SortArray</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="DuckDB.Parser-297"><a href="#DuckDB.Parser-297"><span class="linenos">297</span></a> <span class="s2">"LIST_VALUE"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Array</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="DuckDB.Parser-298"><a href="#DuckDB.Parser-298"><span class="linenos">298</span></a> <span class="s2">"MAKE_TIME"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TimeFromParts</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="DuckDB.Parser-299"><a href="#DuckDB.Parser-299"><span class="linenos">299</span></a> <span class="s2">"MAKE_TIMESTAMP"</span><span class="p">:</span> <span class="n">_build_make_timestamp</span><span class="p">,</span> +</span><span id="DuckDB.Parser-300"><a href="#DuckDB.Parser-300"><span class="linenos">300</span></a> <span class="s2">"MEDIAN"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">PercentileCont</span><span class="p">(</span> +</span><span id="DuckDB.Parser-301"><a href="#DuckDB.Parser-301"><span class="linenos">301</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">number</span><span class="p">(</span><span class="mf">0.5</span><span class="p">)</span> +</span><span id="DuckDB.Parser-302"><a href="#DuckDB.Parser-302"><span class="linenos">302</span></a> <span class="p">),</span> +</span><span id="DuckDB.Parser-303"><a href="#DuckDB.Parser-303"><span class="linenos">303</span></a> <span class="s2">"QUANTILE_CONT"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">PercentileCont</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="DuckDB.Parser-304"><a href="#DuckDB.Parser-304"><span class="linenos">304</span></a> <span class="s2">"QUANTILE_DISC"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">PercentileDisc</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="DuckDB.Parser-305"><a href="#DuckDB.Parser-305"><span class="linenos">305</span></a> <span class="s2">"REGEXP_EXTRACT"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpExtract</span><span class="p">(</span> +</span><span id="DuckDB.Parser-306"><a href="#DuckDB.Parser-306"><span class="linenos">306</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">expression</span><span class="o">=</span><span class="n">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 class="n">group</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">2</span><span class="p">)</span> +</span><span id="DuckDB.Parser-307"><a href="#DuckDB.Parser-307"><span class="linenos">307</span></a> <span class="p">),</span> +</span><span id="DuckDB.Parser-308"><a href="#DuckDB.Parser-308"><span class="linenos">308</span></a> <span class="s2">"REGEXP_MATCHES"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpLike</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="DuckDB.Parser-309"><a href="#DuckDB.Parser-309"><span class="linenos">309</span></a> <span class="s2">"REGEXP_REPLACE"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpReplace</span><span class="p">(</span> +</span><span id="DuckDB.Parser-310"><a href="#DuckDB.Parser-310"><span class="linenos">310</span></a> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> +</span><span id="DuckDB.Parser-311"><a href="#DuckDB.Parser-311"><span class="linenos">311</span></a> <span class="n">expression</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-312"><a href="#DuckDB.Parser-312"><span class="linenos">312</span></a> <span class="n">replacement</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">2</span><span class="p">),</span> +</span><span id="DuckDB.Parser-313"><a href="#DuckDB.Parser-313"><span class="linenos">313</span></a> <span class="n">modifiers</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">3</span><span class="p">),</span> +</span><span id="DuckDB.Parser-314"><a href="#DuckDB.Parser-314"><span class="linenos">314</span></a> <span class="p">),</span> +</span><span id="DuckDB.Parser-315"><a href="#DuckDB.Parser-315"><span class="linenos">315</span></a> <span class="s2">"STRFTIME"</span><span class="p">:</span> <span class="n">build_formatted_time</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">TimeToStr</span><span class="p">,</span> <span class="s2">"duckdb"</span><span class="p">),</span> +</span><span id="DuckDB.Parser-316"><a href="#DuckDB.Parser-316"><span class="linenos">316</span></a> <span class="s2">"STRING_SPLIT"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Split</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="DuckDB.Parser-317"><a href="#DuckDB.Parser-317"><span class="linenos">317</span></a> <span class="s2">"STRING_SPLIT_REGEX"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpSplit</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="DuckDB.Parser-318"><a href="#DuckDB.Parser-318"><span class="linenos">318</span></a> <span class="s2">"STRING_TO_ARRAY"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Split</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="DuckDB.Parser-319"><a href="#DuckDB.Parser-319"><span class="linenos">319</span></a> <span class="s2">"STRPTIME"</span><span class="p">:</span> <span class="n">build_formatted_time</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">StrToTime</span><span class="p">,</span> <span class="s2">"duckdb"</span><span class="p">),</span> +</span><span id="DuckDB.Parser-320"><a href="#DuckDB.Parser-320"><span class="linenos">320</span></a> <span class="s2">"STRUCT_PACK"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Struct</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="DuckDB.Parser-321"><a href="#DuckDB.Parser-321"><span class="linenos">321</span></a> <span class="s2">"STR_SPLIT"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Split</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="DuckDB.Parser-322"><a href="#DuckDB.Parser-322"><span class="linenos">322</span></a> <span class="s2">"STR_SPLIT_REGEX"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpSplit</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="DuckDB.Parser-323"><a href="#DuckDB.Parser-323"><span class="linenos">323</span></a> <span class="s2">"TO_TIMESTAMP"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToTime</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="DuckDB.Parser-324"><a href="#DuckDB.Parser-324"><span class="linenos">324</span></a> <span class="s2">"UNNEST"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Explode</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="DuckDB.Parser-325"><a href="#DuckDB.Parser-325"><span class="linenos">325</span></a> <span class="s2">"XOR"</span><span class="p">:</span> <span class="n">binary_from_function</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">BitwiseXor</span><span class="p">),</span> +</span><span id="DuckDB.Parser-326"><a href="#DuckDB.Parser-326"><span class="linenos">326</span></a> <span class="s2">"GENERATE_SERIES"</span><span class="p">:</span> <span class="n">_build_generate_series</span><span class="p">(),</span> +</span><span id="DuckDB.Parser-327"><a href="#DuckDB.Parser-327"><span class="linenos">327</span></a> <span class="s2">"RANGE"</span><span class="p">:</span> <span class="n">_build_generate_series</span><span class="p">(</span><span class="n">end_exclusive</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> +</span><span id="DuckDB.Parser-328"><a href="#DuckDB.Parser-328"><span class="linenos">328</span></a> <span class="p">}</span> +</span><span id="DuckDB.Parser-329"><a href="#DuckDB.Parser-329"><span class="linenos">329</span></a> +</span><span id="DuckDB.Parser-330"><a href="#DuckDB.Parser-330"><span class="linenos">330</span></a> <span class="n">FUNCTIONS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">"DATE_SUB"</span><span class="p">)</span> +</span><span id="DuckDB.Parser-331"><a href="#DuckDB.Parser-331"><span class="linenos">331</span></a> +</span><span id="DuckDB.Parser-332"><a href="#DuckDB.Parser-332"><span class="linenos">332</span></a> <span class="n">FUNCTION_PARSERS</span> <span class="o">=</span> <span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">FUNCTION_PARSERS</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> +</span><span id="DuckDB.Parser-333"><a href="#DuckDB.Parser-333"><span class="linenos">333</span></a> <span class="n">FUNCTION_PARSERS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">"DECODE"</span><span class="p">)</span> +</span><span id="DuckDB.Parser-334"><a href="#DuckDB.Parser-334"><span class="linenos">334</span></a> +</span><span id="DuckDB.Parser-335"><a href="#DuckDB.Parser-335"><span class="linenos">335</span></a> <span class="n">NO_PAREN_FUNCTION_PARSERS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="DuckDB.Parser-336"><a href="#DuckDB.Parser-336"><span class="linenos">336</span></a> <span class="o">**</span><span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">NO_PAREN_FUNCTION_PARSERS</span><span class="p">,</span> +</span><span id="DuckDB.Parser-337"><a href="#DuckDB.Parser-337"><span class="linenos">337</span></a> <span class="s2">"MAP"</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_map</span><span class="p">(),</span> +</span><span id="DuckDB.Parser-338"><a href="#DuckDB.Parser-338"><span class="linenos">338</span></a> <span class="p">}</span> +</span><span id="DuckDB.Parser-339"><a href="#DuckDB.Parser-339"><span class="linenos">339</span></a> +</span><span id="DuckDB.Parser-340"><a href="#DuckDB.Parser-340"><span class="linenos">340</span></a> <span class="n">TABLE_ALIAS_TOKENS</span> <span class="o">=</span> <span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">TABLE_ALIAS_TOKENS</span> <span class="o">-</span> <span class="p">{</span> +</span><span id="DuckDB.Parser-341"><a href="#DuckDB.Parser-341"><span class="linenos">341</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">SEMI</span><span class="p">,</span> +</span><span id="DuckDB.Parser-342"><a href="#DuckDB.Parser-342"><span class="linenos">342</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">ANTI</span><span class="p">,</span> +</span><span id="DuckDB.Parser-343"><a href="#DuckDB.Parser-343"><span class="linenos">343</span></a> <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">PLACEHOLDER_PARSERS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="DuckDB.Parser-346"><a href="#DuckDB.Parser-346"><span class="linenos">346</span></a> <span class="o">**</span><span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">PLACEHOLDER_PARSERS</span><span class="p">,</span> +</span><span id="DuckDB.Parser-347"><a href="#DuckDB.Parser-347"><span class="linenos">347</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">PARAMETER</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">:</span> <span class="p">(</span> +</span><span id="DuckDB.Parser-348"><a href="#DuckDB.Parser-348"><span class="linenos">348</span></a> <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">Placeholder</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">_prev</span><span class="o">.</span><span class="n">text</span><span class="p">)</span> +</span><span id="DuckDB.Parser-349"><a href="#DuckDB.Parser-349"><span class="linenos">349</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">NUMBER</span><span class="p">)</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_set</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">ID_VAR_TOKENS</span><span class="p">)</span> +</span><span id="DuckDB.Parser-350"><a href="#DuckDB.Parser-350"><span class="linenos">350</span></a> <span class="k">else</span> <span class="kc">None</span> +</span><span id="DuckDB.Parser-351"><a href="#DuckDB.Parser-351"><span class="linenos">351</span></a> <span class="p">),</span> +</span><span id="DuckDB.Parser-352"><a href="#DuckDB.Parser-352"><span class="linenos">352</span></a> <span class="p">}</span> +</span><span id="DuckDB.Parser-353"><a href="#DuckDB.Parser-353"><span class="linenos">353</span></a> +</span><span id="DuckDB.Parser-354"><a href="#DuckDB.Parser-354"><span class="linenos">354</span></a> <span class="n">TYPE_CONVERTERS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="DuckDB.Parser-355"><a href="#DuckDB.Parser-355"><span class="linenos">355</span></a> <span class="c1"># https://duckdb.org/docs/sql/data_types/numeric</span> +</span><span id="DuckDB.Parser-356"><a href="#DuckDB.Parser-356"><span class="linenos">356</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">DECIMAL</span><span class="p">:</span> <span class="n">build_default_decimal_type</span><span class="p">(</span><span class="n">precision</span><span class="o">=</span><span class="mi">18</span><span class="p">,</span> <span class="n">scale</span><span class="o">=</span><span class="mi">3</span><span class="p">),</span> +</span><span id="DuckDB.Parser-357"><a href="#DuckDB.Parser-357"><span class="linenos">357</span></a> <span class="c1"># https://duckdb.org/docs/sql/data_types/text</span> +</span><span id="DuckDB.Parser-358"><a href="#DuckDB.Parser-358"><span class="linenos">358</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">TEXT</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">dtype</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">build</span><span class="p">(</span><span class="s2">"TEXT"</span><span class="p">),</span> +</span><span id="DuckDB.Parser-359"><a href="#DuckDB.Parser-359"><span class="linenos">359</span></a> <span class="p">}</span> +</span><span id="DuckDB.Parser-360"><a href="#DuckDB.Parser-360"><span class="linenos">360</span></a> +</span><span id="DuckDB.Parser-361"><a href="#DuckDB.Parser-361"><span class="linenos">361</span></a> <span class="k">def</span> <span class="nf">_parse_table_sample</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">as_modifier</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">TableSample</span><span class="p">]:</span> +</span><span id="DuckDB.Parser-362"><a href="#DuckDB.Parser-362"><span class="linenos">362</span></a> <span class="c1"># https://duckdb.org/docs/sql/samples.html</span> +</span><span id="DuckDB.Parser-363"><a href="#DuckDB.Parser-363"><span class="linenos">363</span></a> <span class="n">sample</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_parse_table_sample</span><span class="p">(</span><span class="n">as_modifier</span><span class="o">=</span><span class="n">as_modifier</span><span class="p">)</span> +</span><span id="DuckDB.Parser-364"><a href="#DuckDB.Parser-364"><span class="linenos">364</span></a> <span class="k">if</span> <span class="n">sample</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">sample</span><span 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.Parser-365"><a href="#DuckDB.Parser-365"><span class="linenos">365</span></a> <span class="k">if</span> <span class="n">sample</span><span 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.Parser-366"><a href="#DuckDB.Parser-366"><span class="linenos">366</span></a> <span class="n">sample</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.Parser-367"><a href="#DuckDB.Parser-367"><span class="linenos">367</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="DuckDB.Parser-368"><a href="#DuckDB.Parser-368"><span class="linenos">368</span></a> <span class="n">sample</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">"SYSTEM"</span><span class="p">))</span> +</span><span id="DuckDB.Parser-369"><a href="#DuckDB.Parser-369"><span class="linenos">369</span></a> +</span><span id="DuckDB.Parser-370"><a href="#DuckDB.Parser-370"><span class="linenos">370</span></a> <span class="k">return</span> <span class="n">sample</span> +</span><span id="DuckDB.Parser-371"><a href="#DuckDB.Parser-371"><span class="linenos">371</span></a> +</span><span id="DuckDB.Parser-372"><a href="#DuckDB.Parser-372"><span class="linenos">372</span></a> <span class="k">def</span> <span class="nf">_parse_bracket</span><span class="p">(</span> +</span><span id="DuckDB.Parser-373"><a href="#DuckDB.Parser-373"><span class="linenos">373</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">this</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="DuckDB.Parser-374"><a href="#DuckDB.Parser-374"><span class="linenos">374</span></a> <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> +</span><span id="DuckDB.Parser-375"><a href="#DuckDB.Parser-375"><span class="linenos">375</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">_parse_bracket</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> +</span><span id="DuckDB.Parser-376"><a href="#DuckDB.Parser-376"><span class="linenos">376</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">bracket</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Bracket</span><span class="p">):</span> +</span><span id="DuckDB.Parser-377"><a href="#DuckDB.Parser-377"><span class="linenos">377</span></a> <span class="n">bracket</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"returns_list_for_maps"</span><span class="p">,</span> <span class="kc">True</span><span class="p">)</span> </span><span id="DuckDB.Parser-378"><a href="#DuckDB.Parser-378"><span class="linenos">378</span></a> -</span><span id="DuckDB.Parser-379"><a href="#DuckDB.Parser-379"><span class="linenos">379</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-380"><a href="#DuckDB.Parser-380"><span class="linenos">380</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-381"><a href="#DuckDB.Parser-381"><span class="linenos">381</span></a> -</span><span id="DuckDB.Parser-382"><a href="#DuckDB.Parser-382"><span class="linenos">382</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> -</span><span id="DuckDB.Parser-383"><a href="#DuckDB.Parser-383"><span class="linenos">383</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_field_def</span><span class="p">()</span> +</span><span id="DuckDB.Parser-379"><a href="#DuckDB.Parser-379"><span class="linenos">379</span></a> <span class="k">return</span> <span class="n">bracket</span> +</span><span id="DuckDB.Parser-380"><a href="#DuckDB.Parser-380"><span class="linenos">380</span></a> +</span><span id="DuckDB.Parser-381"><a href="#DuckDB.Parser-381"><span class="linenos">381</span></a> <span class="k">def</span> <span class="nf">_parse_map</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">ToMap</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Map</span><span class="p">:</span> +</span><span id="DuckDB.Parser-382"><a href="#DuckDB.Parser-382"><span class="linenos">382</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-383"><a href="#DuckDB.Parser-383"><span class="linenos">383</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-384"><a href="#DuckDB.Parser-384"><span class="linenos">384</span></a> -</span><span id="DuckDB.Parser-385"><a href="#DuckDB.Parser-385"><span class="linenos">385</span></a> <span class="k">def</span> <span class="nf">_pivot_column_names</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">aggregations</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">])</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> -</span><span id="DuckDB.Parser-386"><a href="#DuckDB.Parser-386"><span class="linenos">386</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">aggregations</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> -</span><span id="DuckDB.Parser-387"><a href="#DuckDB.Parser-387"><span class="linenos">387</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_pivot_column_names</span><span class="p">(</span><span class="n">aggregations</span><span class="p">)</span> -</span><span id="DuckDB.Parser-388"><a href="#DuckDB.Parser-388"><span class="linenos">388</span></a> <span class="k">return</span> <span class="n">pivot_column_names</span><span class="p">(</span><span class="n">aggregations</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="s2">"duckdb"</span><span class="p">)</span> +</span><span id="DuckDB.Parser-385"><a href="#DuckDB.Parser-385"><span class="linenos">385</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-386"><a href="#DuckDB.Parser-386"><span class="linenos">386</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-387"><a href="#DuckDB.Parser-387"><span class="linenos">387</span></a> +</span><span id="DuckDB.Parser-388"><a href="#DuckDB.Parser-388"><span class="linenos">388</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> +</span><span id="DuckDB.Parser-389"><a href="#DuckDB.Parser-389"><span class="linenos">389</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_field_def</span><span class="p">()</span> +</span><span id="DuckDB.Parser-390"><a href="#DuckDB.Parser-390"><span class="linenos">390</span></a> +</span><span id="DuckDB.Parser-391"><a href="#DuckDB.Parser-391"><span class="linenos">391</span></a> <span class="k">def</span> <span class="nf">_pivot_column_names</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">aggregations</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">])</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> +</span><span id="DuckDB.Parser-392"><a href="#DuckDB.Parser-392"><span class="linenos">392</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">aggregations</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> +</span><span id="DuckDB.Parser-393"><a href="#DuckDB.Parser-393"><span class="linenos">393</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_pivot_column_names</span><span class="p">(</span><span class="n">aggregations</span><span class="p">)</span> +</span><span id="DuckDB.Parser-394"><a href="#DuckDB.Parser-394"><span class="linenos">394</span></a> <span class="k">return</span> <span class="n">pivot_column_names</span><span class="p">(</span><span class="n">aggregations</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="s2">"duckdb"</span><span class="p">)</span> </span></pre></div> @@ -2656,7 +2678,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> @@ -2708,7 +2730,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.UNNEST: 'UNNEST'>, <TokenType.TEXT: 'TEXT'>, <TokenType.FILTER: 'FILTER'>, <TokenType.TIMESTAMPLTZ: 'TIMESTAMPLTZ'>, <TokenType.TSTZMULTIRANGE: 'TSTZMULTIRANGE'>, <TokenType.ANY: 'ANY'>, <TokenType.TIMESTAMP_NS: 'TIMESTAMP_NS'>, <TokenType.NCHAR: 'NCHAR'>, <TokenType.LIST: 'LIST'>, <TokenType.TEMPORARY: 'TEMPORARY'>, <TokenType.UPDATE: 'UPDATE'>, <TokenType.IPPREFIX: 'IPPREFIX'>, <TokenType.VECTOR: 'VECTOR'>, <TokenType.TRUE: 'TRUE'>, <TokenType.NUMMULTIRANGE: 'NUMMULTIRANGE'>, <TokenType.NUMRANGE: 'NUMRANGE'>, <TokenType.COMMAND: 'COMMAND'>, <TokenType.TAG: 'TAG'>, <TokenType.UINT256: 'UINT256'>, <TokenType.SUPER: 'SUPER'>, <TokenType.RANGE: 'RANGE'>, <TokenType.DOUBLE: 'DOUBLE'>, <TokenType.VARIANT: 'VARIANT'>, <TokenType.ISNULL: 'ISNULL'>, <TokenType.YEAR: 'YEAR'>, <TokenType.INTERVAL: 'INTERVAL'>, <TokenType.TDIGEST: 'TDIGEST'>, <TokenType.GEOMETRY: 'GEOMETRY'>, <TokenType.IPV6: 'IPV6'>, <TokenType.ALL: 'ALL'>, <TokenType.NEXT: 'NEXT'>, <TokenType.TSTZRANGE: 'TSTZRANGE'>, <TokenType.EXECUTE: 'EXECUTE'>, <TokenType.TOP: 'TOP'>, <TokenType.EXISTS: 'EXISTS'>, <TokenType.BPCHAR: 'BPCHAR'>, <TokenType.DATETIME: 'DATETIME'>, <TokenType.INT8RANGE: 'INT8RANGE'>, <TokenType.JSONB: 'JSONB'>, <TokenType.FIXEDSTRING: 'FIXEDSTRING'>, <TokenType.FUNCTION: 'FUNCTION'>, <TokenType.SMALLMONEY: 'SMALLMONEY'>, <TokenType.INT4RANGE: 'INT4RANGE'>, <TokenType.DICTIONARY: 'DICTIONARY'>, <TokenType.COMMENT: 'COMMENT'>, <TokenType.ROWS: 'ROWS'>, <TokenType.SMALLINT: 'SMALLINT'>, <TokenType.ROW: 'ROW'>, <TokenType.VARBINARY: 'VARBINARY'>, <TokenType.NULLABLE: 'NULLABLE'>, <TokenType.OVERWRITE: 'OVERWRITE'>, <TokenType.STREAMLIT: 'STREAMLIT'>, <TokenType.IPV4: 'IPV4'>, <TokenType.STRAIGHT_JOIN: 'STRAIGHT_JOIN'>, <TokenType.SCHEMA: 'SCHEMA'>, <TokenType.DELETE: 'DELETE'>, <TokenType.PRAGMA: 'PRAGMA'>, <TokenType.RECURSIVE: 'RECURSIVE'>, <TokenType.DEFAULT: 'DEFAULT'>, <TokenType.DIV: 'DIV'>, <TokenType.FLOAT: 'FLOAT'>, <TokenType.STORAGE_INTEGRATION: 'STORAGE_INTEGRATION'>, <TokenType.FALSE: 'FALSE'>, <TokenType.CURRENT_TIME: 'CURRENT_TIME'>, <TokenType.TIMETZ: 'TIMETZ'>, <TokenType.USE: 'USE'>, <TokenType.TABLE: 'TABLE'>, <TokenType.UMEDIUMINT: 'UMEDIUMINT'>, <TokenType.SOME: 'SOME'>, <TokenType.CURRENT_TIMESTAMP: 'CURRENT_TIMESTAMP'>, <TokenType.IMAGE: 'IMAGE'>, <TokenType.FIRST: 'FIRST'>, <TokenType.AGGREGATEFUNCTION: 'AGGREGATEFUNCTION'>, <TokenType.INT8MULTIRANGE: 'INT8MULTIRANGE'>, <TokenType.LONGBLOB: 'LONGBLOB'>, <TokenType.CASE: 'CASE'>, <TokenType.INT: 'INT'>, <TokenType.PIVOT: 'PIVOT'>, <TokenType.OVERLAPS: 'OVERLAPS'>, <TokenType.ASC: 'ASC'>, <TokenType.SMALLSERIAL: 'SMALLSERIAL'>, <TokenType.UNIQUEIDENTIFIER: 'UNIQUEIDENTIFIER'>, <TokenType.IPADDRESS: 'IPADDRESS'>, <TokenType.OPERATOR: 'OPERATOR'>, <TokenType.REFRESH: 'REFRESH'>, <TokenType.BEGIN: 'BEGIN'>, <TokenType.NESTED: 'NESTED'>, <TokenType.HSTORE: 'HSTORE'>, <TokenType.INT128: 'INT128'>, <TokenType.UDECIMAL: 'UDECIMAL'>, <TokenType.AUTO_INCREMENT: 'AUTO_INCREMENT'>, <TokenType.FINAL: 'FINAL'>, <TokenType.FORMAT: 'FORMAT'>, <TokenType.ROLLUP: 'ROLLUP'>, <TokenType.TIMESTAMPTZ: 'TIMESTAMPTZ'>, <TokenType.OBJECT_IDENTIFIER: 'OBJECT_IDENTIFIER'>, <TokenType.SEQUENCE: 'SEQUENCE'>, <TokenType.CACHE: 'CACHE'>, <TokenType.TIMESTAMP_S: 'TIMESTAMP_S'>, <TokenType.NAME: 'NAME'>, <TokenType.UNIQUE: 'UNIQUE'>, <TokenType.COLLATE: 'COLLATE'>, <TokenType.NULL: 'NULL'>, <TokenType.REPLACE: 'REPLACE'>, <TokenType.COPY: 'COPY'>, <TokenType.USMALLINT: 'USMALLINT'>, <TokenType.INET: 'INET'>, <TokenType.DATETIME64: 'DATETIME64'>, <TokenType.VAR: 'VAR'>, <TokenType.BINARY: 'BINARY'>, <TokenType.DATERANGE: 'DATERANGE'>, <TokenType.UNKNOWN: 'UNKNOWN'>, <TokenType.SHOW: 'SHOW'>, <TokenType.DATE: 'DATE'>, <TokenType.BIGDECIMAL: 'BIGDECIMAL'>, <TokenType.SERIAL: 'SERIAL'>, <TokenType.SIMPLEAGGREGATEFUNCTION: 'SIMPLEAGGREGATEFUNCTION'>, <TokenType.INT4MULTIRANGE: 'INT4MULTIRANGE'>, <TokenType.CURRENT_USER: 'CURRENT_USER'>, <TokenType.ENUM16: 'ENUM16'>, <TokenType.VIEW: 'VIEW'>, <TokenType.SETTINGS: 'SETTINGS'>, <TokenType.BIGSERIAL: 'BIGSERIAL'>, <TokenType.XML: 'XML'>, <TokenType.CONSTRAINT: 'CONSTRAINT'>, <TokenType.DECIMAL: 'DECIMAL'>, <TokenType.MAP: 'MAP'>, <TokenType.CURRENT_DATETIME: 'CURRENT_DATETIME'>, <TokenType.OBJECT: 'OBJECT'>, <TokenType.STRUCT: 'STRUCT'>, <TokenType.DATE32: 'DATE32'>, <TokenType.DESC: 'DESC'>, <TokenType.ENUM: 'ENUM'>, <TokenType.WAREHOUSE: 'WAREHOUSE'>, <TokenType.UNPIVOT: 'UNPIVOT'>, <TokenType.BIGINT: 'BIGINT'>, <TokenType.PROCEDURE: 'PROCEDURE'>, <TokenType.GEOGRAPHY: 'GEOGRAPHY'>, <TokenType.DESCRIBE: 'DESCRIBE'>, <TokenType.PSEUDO_TYPE: 'PSEUDO_TYPE'>, <TokenType.MERGE: 'MERGE'>, <TokenType.ESCAPE: 'ESCAPE'>, <TokenType.COMMIT: 'COMMIT'>, <TokenType.IDENTIFIER: 'IDENTIFIER'>, <TokenType.DATEMULTIRANGE: 'DATEMULTIRANGE'>, <TokenType.TIME: 'TIME'>, <TokenType.ROWVERSION: 'ROWVERSION'>, <TokenType.NVARCHAR: 'NVARCHAR'>, <TokenType.CHAR: 'CHAR'>, <TokenType.MEDIUMINT: 'MEDIUMINT'>, <TokenType.PERCENT: 'PERCENT'>, <TokenType.IS: 'IS'>, <TokenType.VOLATILE: 'VOLATILE'>, <TokenType.MODEL: 'MODEL'>, <TokenType.DATABASE: 'DATABASE'>, <TokenType.TSMULTIRANGE: 'TSMULTIRANGE'>, <TokenType.UTINYINT: 'UTINYINT'>, <TokenType.MONEY: 'MONEY'>, <TokenType.MEDIUMTEXT: 'MEDIUMTEXT'>, <TokenType.ARRAY: 'ARRAY'>, <TokenType.KEEP: 'KEEP'>, <TokenType.INDEX: 'INDEX'>, <TokenType.UINT128: 'UINT128'>, <TokenType.CURRENT_DATE: 'CURRENT_DATE'>, <TokenType.TINYBLOB: 'TINYBLOB'>, <TokenType.TIMESTAMP_MS: 'TIMESTAMP_MS'>, <TokenType.JSON: 'JSON'>, <TokenType.SET: 'SET'>, <TokenType.BIT: 'BIT'>, <TokenType.MEDIUMBLOB: 'MEDIUMBLOB'>, <TokenType.TSRANGE: 'TSRANGE'>, <TokenType.LOWCARDINALITY: 'LOWCARDINALITY'>, <TokenType.TRUNCATE: 'TRUNCATE'>, <TokenType.LOAD: 'LOAD'>, <TokenType.TINYTEXT: 'TINYTEXT'>, <TokenType.END: 'END'>, <TokenType.TINYINT: 'TINYINT'>, <TokenType.BOOLEAN: 'BOOLEAN'>, <TokenType.TIMESTAMP: 'TIMESTAMP'>, <TokenType.COLUMN: 'COLUMN'>, <TokenType.REFERENCES: 'REFERENCES'>, <TokenType.UINT: 'UINT'>, <TokenType.KILL: 'KILL'>, <TokenType.PARTITION: 'PARTITION'>, <TokenType.UUID: 'UUID'>, <TokenType.INT256: 'INT256'>, <TokenType.TIMESTAMPNTZ: 'TIMESTAMPNTZ'>, <TokenType.HLLSKETCH: 'HLLSKETCH'>, <TokenType.FOREIGN_KEY: 'FOREIGN_KEY'>, <TokenType.UBIGINT: 'UBIGINT'>, <TokenType.ORDINALITY: 'ORDINALITY'>, <TokenType.LONGTEXT: 'LONGTEXT'>, <TokenType.USERDEFINED: 'USERDEFINED'>, <TokenType.VARCHAR: 'VARCHAR'>, <TokenType.ENUM8: 'ENUM8'>}</span> + <label class="view-value-button pdoc-button" for="DuckDB.Parser.TABLE_ALIAS_TOKENS-view-value"></label><span class="default_value">{<TokenType.ESCAPE: 'ESCAPE'>, <TokenType.REPLACE: 'REPLACE'>, <TokenType.DESC: 'DESC'>, <TokenType.TOP: 'TOP'>, <TokenType.USE: 'USE'>, <TokenType.DATERANGE: 'DATERANGE'>, <TokenType.TSMULTIRANGE: 'TSMULTIRANGE'>, <TokenType.KEEP: 'KEEP'>, <TokenType.TINYBLOB: 'TINYBLOB'>, <TokenType.TIMESTAMP_NS: 'TIMESTAMP_NS'>, <TokenType.UINT256: 'UINT256'>, <TokenType.LOAD: 'LOAD'>, <TokenType.EXISTS: 'EXISTS'>, <TokenType.SOME: 'SOME'>, <TokenType.BIGSERIAL: 'BIGSERIAL'>, <TokenType.OBJECT_IDENTIFIER: 'OBJECT_IDENTIFIER'>, <TokenType.FILTER: 'FILTER'>, <TokenType.DATABASE: 'DATABASE'>, <TokenType.BIGINT: 'BIGINT'>, <TokenType.SMALLINT: 'SMALLINT'>, <TokenType.XML: 'XML'>, <TokenType.DIV: 'DIV'>, <TokenType.UUID: 'UUID'>, <TokenType.MONEY: 'MONEY'>, <TokenType.ENUM: 'ENUM'>, <TokenType.COLLATE: 'COLLATE'>, <TokenType.KILL: 'KILL'>, <TokenType.TIMESTAMP_MS: 'TIMESTAMP_MS'>, <TokenType.VARIANT: 'VARIANT'>, <TokenType.ARRAY: 'ARRAY'>, <TokenType.DELETE: 'DELETE'>, <TokenType.DATE: 'DATE'>, <TokenType.NULLABLE: 'NULLABLE'>, <TokenType.STRUCT: 'STRUCT'>, <TokenType.INT4MULTIRANGE: 'INT4MULTIRANGE'>, <TokenType.FALSE: 'FALSE'>, <TokenType.ORDINALITY: 'ORDINALITY'>, <TokenType.BOOLEAN: 'BOOLEAN'>, <TokenType.IS: 'IS'>, <TokenType.FIRST: 'FIRST'>, <TokenType.STORAGE_INTEGRATION: 'STORAGE_INTEGRATION'>, <TokenType.BEGIN: 'BEGIN'>, <TokenType.HSTORE: 'HSTORE'>, <TokenType.CHAR: 'CHAR'>, <TokenType.ROWS: 'ROWS'>, <TokenType.SUPER: 'SUPER'>, <TokenType.INT4RANGE: 'INT4RANGE'>, <TokenType.TSTZMULTIRANGE: 'TSTZMULTIRANGE'>, <TokenType.INT: 'INT'>, <TokenType.DATE32: 'DATE32'>, <TokenType.SETTINGS: 'SETTINGS'>, <TokenType.MODEL: 'MODEL'>, <TokenType.IDENTIFIER: 'IDENTIFIER'>, <TokenType.MEDIUMBLOB: 'MEDIUMBLOB'>, <TokenType.UINT128: 'UINT128'>, <TokenType.SCHEMA: 'SCHEMA'>, <TokenType.IPV6: 'IPV6'>, <TokenType.COPY: 'COPY'>, <TokenType.UNPIVOT: 'UNPIVOT'>, <TokenType.BPCHAR: 'BPCHAR'>, <TokenType.GEOMETRY: 'GEOMETRY'>, <TokenType.DATETIME: 'DATETIME'>, <TokenType.TSTZRANGE: 'TSTZRANGE'>, <TokenType.CASE: 'CASE'>, <TokenType.VIEW: 'VIEW'>, <TokenType.IPPREFIX: 'IPPREFIX'>, <TokenType.DATETIME64: 'DATETIME64'>, <TokenType.FINAL: 'FINAL'>, <TokenType.NUMMULTIRANGE: 'NUMMULTIRANGE'>, <TokenType.IPADDRESS: 'IPADDRESS'>, <TokenType.TINYTEXT: 'TINYTEXT'>, <TokenType.CURRENT_TIMESTAMP: 'CURRENT_TIMESTAMP'>, <TokenType.SHOW: 'SHOW'>, <TokenType.NEXT: 'NEXT'>, <TokenType.RECURSIVE: 'RECURSIVE'>, <TokenType.PERCENT: 'PERCENT'>, <TokenType.COLUMN: 'COLUMN'>, <TokenType.REFERENCES: 'REFERENCES'>, <TokenType.OVERWRITE: 'OVERWRITE'>, <TokenType.OPERATOR: 'OPERATOR'>, <TokenType.DEFAULT: 'DEFAULT'>, <TokenType.JSON: 'JSON'>, <TokenType.TSRANGE: 'TSRANGE'>, <TokenType.COMMAND: 'COMMAND'>, <TokenType.TEMPORARY: 'TEMPORARY'>, <TokenType.CURRENT_DATE: 'CURRENT_DATE'>, <TokenType.TEXT: 'TEXT'>, <TokenType.SMALLSERIAL: 'SMALLSERIAL'>, <TokenType.HLLSKETCH: 'HLLSKETCH'>, <TokenType.SET: 'SET'>, <TokenType.UNKNOWN: 'UNKNOWN'>, <TokenType.VAR: 'VAR'>, <TokenType.ASC: 'ASC'>, <TokenType.PARTITION: 'PARTITION'>, <TokenType.SMALLMONEY: 'SMALLMONEY'>, <TokenType.DATEMULTIRANGE: 'DATEMULTIRANGE'>, <TokenType.TIME: 'TIME'>, <TokenType.LONGTEXT: 'LONGTEXT'>, <TokenType.ALL: 'ALL'>, <TokenType.MEDIUMTEXT: 'MEDIUMTEXT'>, <TokenType.CUBE: 'CUBE'>, <TokenType.ENUM8: 'ENUM8'>, <TokenType.UMEDIUMINT: 'UMEDIUMINT'>, <TokenType.ENUM16: 'ENUM16'>, <TokenType.ROWVERSION: 'ROWVERSION'>, <TokenType.BINARY: 'BINARY'>, <TokenType.NUMRANGE: 'NUMRANGE'>, <TokenType.TABLE: 'TABLE'>, <TokenType.UTINYINT: 'UTINYINT'>, <TokenType.GEOGRAPHY: 'GEOGRAPHY'>, <TokenType.PROCEDURE: 'PROCEDURE'>, <TokenType.UNNEST: 'UNNEST'>, <TokenType.UNIQUEIDENTIFIER: 'UNIQUEIDENTIFIER'>, <TokenType.UBIGINT: 'UBIGINT'>, <TokenType.DICTIONARY: 'DICTIONARY'>, <TokenType.INT256: 'INT256'>, <TokenType.COMMENT: 'COMMENT'>, <TokenType.MERGE: 'MERGE'>, <TokenType.SERIAL: 'SERIAL'>, <TokenType.IPV4: 'IPV4'>, <TokenType.BIGDECIMAL: 'BIGDECIMAL'>, <TokenType.TINYINT: 'TINYINT'>, <TokenType.CURRENT_DATETIME: 'CURRENT_DATETIME'>, <TokenType.UNIQUE: 'UNIQUE'>, <TokenType.LONGBLOB: 'LONGBLOB'>, <TokenType.FORMAT: 'FORMAT'>, <TokenType.COMMIT: 'COMMIT'>, <TokenType.BIT: 'BIT'>, <TokenType.OBJECT: 'OBJECT'>, <TokenType.STRAIGHT_JOIN: 'STRAIGHT_JOIN'>, <TokenType.TIMESTAMPNTZ: 'TIMESTAMPNTZ'>, <TokenType.VARBINARY: 'VARBINARY'>, <TokenType.LIST: 'LIST'>, <TokenType.FLOAT: 'FLOAT'>, <TokenType.DECIMAL: 'DECIMAL'>, <TokenType.TRUNCATE: 'TRUNCATE'>, <TokenType.RANGE: 'RANGE'>, <TokenType.PIVOT: 'PIVOT'>, <TokenType.TIMESTAMPTZ: 'TIMESTAMPTZ'>, <TokenType.YEAR: 'YEAR'>, <TokenType.NESTED: 'NESTED'>, <TokenType.VOLATILE: 'VOLATILE'>, <TokenType.INT8RANGE: 'INT8RANGE'>, <TokenType.INT128: 'INT128'>, <TokenType.TRUE: 'TRUE'>, <TokenType.MAP: 'MAP'>, <TokenType.INT8MULTIRANGE: 'INT8MULTIRANGE'>, <TokenType.USERDEFINED: 'USERDEFINED'>, <TokenType.LOWCARDINALITY: 'LOWCARDINALITY'>, <TokenType.VARCHAR: 'VARCHAR'>, <TokenType.FIXEDSTRING: 'FIXEDSTRING'>, <TokenType.INDEX: 'INDEX'>, <TokenType.AUTO_INCREMENT: 'AUTO_INCREMENT'>, <TokenType.CURRENT_USER: 'CURRENT_USER'>, <TokenType.JSONB: 'JSONB'>, <TokenType.USMALLINT: 'USMALLINT'>, <TokenType.CONSTRAINT: 'CONSTRAINT'>, <TokenType.INTERVAL: 'INTERVAL'>, <TokenType.REFRESH: 'REFRESH'>, <TokenType.STREAMLIT: 'STREAMLIT'>, <TokenType.END: 'END'>, <TokenType.FOREIGN_KEY: 'FOREIGN_KEY'>, <TokenType.DESCRIBE: 'DESCRIBE'>, <TokenType.UINT: 'UINT'>, <TokenType.TDIGEST: 'TDIGEST'>, <TokenType.NAME: 'NAME'>, <TokenType.OVERLAPS: 'OVERLAPS'>, <TokenType.TIMESTAMPLTZ: 'TIMESTAMPLTZ'>, <TokenType.TIMETZ: 'TIMETZ'>, <TokenType.PRAGMA: 'PRAGMA'>, <TokenType.ROW: 'ROW'>, <TokenType.ROLLUP: 'ROLLUP'>, <TokenType.INET: 'INET'>, <TokenType.FUNCTION: 'FUNCTION'>, <TokenType.ANY: 'ANY'>, <TokenType.NCHAR: 'NCHAR'>, <TokenType.NVARCHAR: 'NVARCHAR'>, <TokenType.VECTOR: 'VECTOR'>, <TokenType.UDECIMAL: 'UDECIMAL'>, <TokenType.EXECUTE: 'EXECUTE'>, <TokenType.TIMESTAMP_S: 'TIMESTAMP_S'>, <TokenType.TIMESTAMP: 'TIMESTAMP'>, <TokenType.NULL: 'NULL'>, <TokenType.PSEUDO_TYPE: 'PSEUDO_TYPE'>, <TokenType.UPDATE: 'UPDATE'>, <TokenType.TAG: 'TAG'>, <TokenType.IMAGE: 'IMAGE'>, <TokenType.CACHE: 'CACHE'>, <TokenType.SEQUENCE: 'SEQUENCE'>, <TokenType.MEDIUMINT: 'MEDIUMINT'>, <TokenType.SIMPLEAGGREGATEFUNCTION: 'SIMPLEAGGREGATEFUNCTION'>, <TokenType.ISNULL: 'ISNULL'>, <TokenType.DOUBLE: 'DOUBLE'>, <TokenType.AGGREGATEFUNCTION: 'AGGREGATEFUNCTION'>, <TokenType.WAREHOUSE: 'WAREHOUSE'>, <TokenType.CURRENT_TIME: 'CURRENT_TIME'>}</span> </div> @@ -2747,7 +2769,7 @@ Default: 3</li> <div class="attr variable"> <span class="name">ID_VAR_TOKENS</span> = <input id="DuckDB.Parser.ID_VAR_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.ID_VAR_TOKENS-view-value"></label><span class="default_value">{<TokenType.UNNEST: 'UNNEST'>, <TokenType.TEXT: 'TEXT'>, <TokenType.FILTER: 'FILTER'>, <TokenType.TIMESTAMPLTZ: 'TIMESTAMPLTZ'>, <TokenType.TSTZMULTIRANGE: 'TSTZMULTIRANGE'>, <TokenType.ANY: 'ANY'>, <TokenType.TIMESTAMP_NS: 'TIMESTAMP_NS'>, <TokenType.NCHAR: 'NCHAR'>, <TokenType.FULL: 'FULL'>, <TokenType.LIST: 'LIST'>, <TokenType.TEMPORARY: 'TEMPORARY'>, <TokenType.UPDATE: 'UPDATE'>, <TokenType.IPPREFIX: 'IPPREFIX'>, <TokenType.VECTOR: 'VECTOR'>, <TokenType.TRUE: 'TRUE'>, <TokenType.NUMMULTIRANGE: 'NUMMULTIRANGE'>, <TokenType.NUMRANGE: 'NUMRANGE'>, <TokenType.COMMAND: 'COMMAND'>, <TokenType.TAG: 'TAG'>, <TokenType.UINT256: 'UINT256'>, <TokenType.SUPER: 'SUPER'>, <TokenType.RANGE: 'RANGE'>, <TokenType.DOUBLE: 'DOUBLE'>, <TokenType.VARIANT: 'VARIANT'>, <TokenType.ISNULL: 'ISNULL'>, <TokenType.YEAR: 'YEAR'>, <TokenType.INTERVAL: 'INTERVAL'>, <TokenType.TDIGEST: 'TDIGEST'>, <TokenType.GEOMETRY: 'GEOMETRY'>, <TokenType.LEFT: 'LEFT'>, <TokenType.IPV6: 'IPV6'>, <TokenType.ASOF: 'ASOF'>, <TokenType.ALL: 'ALL'>, <TokenType.NEXT: 'NEXT'>, <TokenType.TSTZRANGE: 'TSTZRANGE'>, <TokenType.EXECUTE: 'EXECUTE'>, <TokenType.TOP: 'TOP'>, <TokenType.EXISTS: 'EXISTS'>, <TokenType.BPCHAR: 'BPCHAR'>, <TokenType.DATETIME: 'DATETIME'>, <TokenType.INT8RANGE: 'INT8RANGE'>, <TokenType.JSONB: 'JSONB'>, <TokenType.FIXEDSTRING: 'FIXEDSTRING'>, <TokenType.FUNCTION: 'FUNCTION'>, <TokenType.SMALLMONEY: 'SMALLMONEY'>, <TokenType.INT4RANGE: 'INT4RANGE'>, <TokenType.DICTIONARY: 'DICTIONARY'>, <TokenType.COMMENT: 'COMMENT'>, <TokenType.ROWS: 'ROWS'>, <TokenType.SMALLINT: 'SMALLINT'>, <TokenType.ROW: 'ROW'>, <TokenType.VARBINARY: 'VARBINARY'>, <TokenType.NULLABLE: 'NULLABLE'>, <TokenType.OVERWRITE: 'OVERWRITE'>, <TokenType.STREAMLIT: 'STREAMLIT'>, <TokenType.SEMI: 'SEMI'>, <TokenType.IPV4: 'IPV4'>, <TokenType.SCHEMA: 'SCHEMA'>, <TokenType.STRAIGHT_JOIN: 'STRAIGHT_JOIN'>, <TokenType.DELETE: 'DELETE'>, <TokenType.PRAGMA: 'PRAGMA'>, <TokenType.RECURSIVE: 'RECURSIVE'>, <TokenType.DEFAULT: 'DEFAULT'>, <TokenType.DIV: 'DIV'>, <TokenType.FLOAT: 'FLOAT'>, <TokenType.STORAGE_INTEGRATION: 'STORAGE_INTEGRATION'>, <TokenType.FALSE: 'FALSE'>, <TokenType.CURRENT_TIME: 'CURRENT_TIME'>, <TokenType.TIMETZ: 'TIMETZ'>, <TokenType.USE: 'USE'>, <TokenType.TABLE: 'TABLE'>, <TokenType.UMEDIUMINT: 'UMEDIUMINT'>, <TokenType.SOME: 'SOME'>, <TokenType.CURRENT_TIMESTAMP: 'CURRENT_TIMESTAMP'>, <TokenType.IMAGE: 'IMAGE'>, <TokenType.FIRST: 'FIRST'>, <TokenType.AGGREGATEFUNCTION: 'AGGREGATEFUNCTION'>, <TokenType.INT8MULTIRANGE: 'INT8MULTIRANGE'>, <TokenType.LONGBLOB: 'LONGBLOB'>, <TokenType.CASE: 'CASE'>, <TokenType.INT: 'INT'>, <TokenType.PIVOT: 'PIVOT'>, <TokenType.OVERLAPS: 'OVERLAPS'>, <TokenType.ASC: 'ASC'>, <TokenType.SMALLSERIAL: 'SMALLSERIAL'>, <TokenType.UNIQUEIDENTIFIER: 'UNIQUEIDENTIFIER'>, <TokenType.IPADDRESS: 'IPADDRESS'>, <TokenType.OPERATOR: 'OPERATOR'>, <TokenType.REFRESH: 'REFRESH'>, <TokenType.BEGIN: 'BEGIN'>, <TokenType.NESTED: 'NESTED'>, <TokenType.HSTORE: 'HSTORE'>, <TokenType.INT128: 'INT128'>, <TokenType.UDECIMAL: 'UDECIMAL'>, <TokenType.AUTO_INCREMENT: 'AUTO_INCREMENT'>, <TokenType.FINAL: 'FINAL'>, <TokenType.FORMAT: 'FORMAT'>, <TokenType.ROLLUP: 'ROLLUP'>, <TokenType.TIMESTAMPTZ: 'TIMESTAMPTZ'>, <TokenType.OBJECT_IDENTIFIER: 'OBJECT_IDENTIFIER'>, <TokenType.SEQUENCE: 'SEQUENCE'>, <TokenType.CACHE: 'CACHE'>, <TokenType.TIMESTAMP_S: 'TIMESTAMP_S'>, <TokenType.NAME: 'NAME'>, <TokenType.UNIQUE: 'UNIQUE'>, <TokenType.COLLATE: 'COLLATE'>, <TokenType.NULL: 'NULL'>, <TokenType.REPLACE: 'REPLACE'>, <TokenType.COPY: 'COPY'>, <TokenType.USMALLINT: 'USMALLINT'>, <TokenType.INET: 'INET'>, <TokenType.DATETIME64: 'DATETIME64'>, <TokenType.VAR: 'VAR'>, <TokenType.BINARY: 'BINARY'>, <TokenType.DATERANGE: 'DATERANGE'>, <TokenType.UNKNOWN: 'UNKNOWN'>, <TokenType.NATURAL: 'NATURAL'>, <TokenType.SHOW: 'SHOW'>, <TokenType.DATE: 'DATE'>, <TokenType.BIGDECIMAL: 'BIGDECIMAL'>, <TokenType.SERIAL: 'SERIAL'>, <TokenType.SIMPLEAGGREGATEFUNCTION: 'SIMPLEAGGREGATEFUNCTION'>, <TokenType.INT4MULTIRANGE: 'INT4MULTIRANGE'>, <TokenType.CURRENT_USER: 'CURRENT_USER'>, <TokenType.ENUM16: 'ENUM16'>, <TokenType.VIEW: 'VIEW'>, <TokenType.SETTINGS: 'SETTINGS'>, <TokenType.BIGSERIAL: 'BIGSERIAL'>, <TokenType.XML: 'XML'>, <TokenType.CONSTRAINT: 'CONSTRAINT'>, <TokenType.DECIMAL: 'DECIMAL'>, <TokenType.MAP: 'MAP'>, <TokenType.CURRENT_DATETIME: 'CURRENT_DATETIME'>, <TokenType.OBJECT: 'OBJECT'>, <TokenType.STRUCT: 'STRUCT'>, <TokenType.DATE32: 'DATE32'>, <TokenType.DESC: 'DESC'>, <TokenType.ENUM: 'ENUM'>, <TokenType.WAREHOUSE: 'WAREHOUSE'>, <TokenType.UNPIVOT: 'UNPIVOT'>, <TokenType.BIGINT: 'BIGINT'>, <TokenType.PROCEDURE: 'PROCEDURE'>, <TokenType.GEOGRAPHY: 'GEOGRAPHY'>, <TokenType.DESCRIBE: 'DESCRIBE'>, <TokenType.PSEUDO_TYPE: 'PSEUDO_TYPE'>, <TokenType.MERGE: 'MERGE'>, <TokenType.ESCAPE: 'ESCAPE'>, <TokenType.WINDOW: 'WINDOW'>, <TokenType.COMMIT: 'COMMIT'>, <TokenType.IDENTIFIER: 'IDENTIFIER'>, <TokenType.DATEMULTIRANGE: 'DATEMULTIRANGE'>, <TokenType.TIME: 'TIME'>, <TokenType.ROWVERSION: 'ROWVERSION'>, <TokenType.NVARCHAR: 'NVARCHAR'>, <TokenType.CHAR: 'CHAR'>, <TokenType.MEDIUMINT: 'MEDIUMINT'>, <TokenType.PERCENT: 'PERCENT'>, <TokenType.IS: 'IS'>, <TokenType.VOLATILE: 'VOLATILE'>, <TokenType.MODEL: 'MODEL'>, <TokenType.DATABASE: 'DATABASE'>, <TokenType.TSMULTIRANGE: 'TSMULTIRANGE'>, <TokenType.UTINYINT: 'UTINYINT'>, <TokenType.MONEY: 'MONEY'>, <TokenType.MEDIUMTEXT: 'MEDIUMTEXT'>, <TokenType.ARRAY: 'ARRAY'>, <TokenType.KEEP: 'KEEP'>, <TokenType.INDEX: 'INDEX'>, <TokenType.UINT128: 'UINT128'>, <TokenType.CURRENT_DATE: 'CURRENT_DATE'>, <TokenType.TINYBLOB: 'TINYBLOB'>, <TokenType.TIMESTAMP_MS: 'TIMESTAMP_MS'>, <TokenType.JSON: 'JSON'>, <TokenType.SET: 'SET'>, <TokenType.RIGHT: 'RIGHT'>, <TokenType.BIT: 'BIT'>, <TokenType.MEDIUMBLOB: 'MEDIUMBLOB'>, <TokenType.TSRANGE: 'TSRANGE'>, <TokenType.LOWCARDINALITY: 'LOWCARDINALITY'>, <TokenType.TRUNCATE: 'TRUNCATE'>, <TokenType.LOAD: 'LOAD'>, <TokenType.TINYTEXT: 'TINYTEXT'>, <TokenType.END: 'END'>, <TokenType.TINYINT: 'TINYINT'>, <TokenType.BOOLEAN: 'BOOLEAN'>, <TokenType.TIMESTAMP: 'TIMESTAMP'>, <TokenType.COLUMN: 'COLUMN'>, <TokenType.REFERENCES: 'REFERENCES'>, <TokenType.UINT: 'UINT'>, <TokenType.KILL: 'KILL'>, <TokenType.PARTITION: 'PARTITION'>, <TokenType.UUID: 'UUID'>, <TokenType.APPLY: 'APPLY'>, <TokenType.INT256: 'INT256'>, <TokenType.TIMESTAMPNTZ: 'TIMESTAMPNTZ'>, <TokenType.HLLSKETCH: 'HLLSKETCH'>, <TokenType.FOREIGN_KEY: 'FOREIGN_KEY'>, <TokenType.UBIGINT: 'UBIGINT'>, <TokenType.ORDINALITY: 'ORDINALITY'>, <TokenType.LONGTEXT: 'LONGTEXT'>, <TokenType.USERDEFINED: 'USERDEFINED'>, <TokenType.VARCHAR: 'VARCHAR'>, <TokenType.ENUM8: 'ENUM8'>, <TokenType.OFFSET: 'OFFSET'>, <TokenType.ANTI: 'ANTI'>}</span> + <label class="view-value-button pdoc-button" for="DuckDB.Parser.ID_VAR_TOKENS-view-value"></label><span class="default_value">{<TokenType.ESCAPE: 'ESCAPE'>, <TokenType.REPLACE: 'REPLACE'>, <TokenType.DESC: 'DESC'>, <TokenType.TOP: 'TOP'>, <TokenType.USE: 'USE'>, <TokenType.DATERANGE: 'DATERANGE'>, <TokenType.TSMULTIRANGE: 'TSMULTIRANGE'>, <TokenType.KEEP: 'KEEP'>, <TokenType.TINYBLOB: 'TINYBLOB'>, <TokenType.TIMESTAMP_NS: 'TIMESTAMP_NS'>, <TokenType.UINT256: 'UINT256'>, <TokenType.ANTI: 'ANTI'>, <TokenType.LOAD: 'LOAD'>, <TokenType.EXISTS: 'EXISTS'>, <TokenType.SOME: 'SOME'>, <TokenType.BIGSERIAL: 'BIGSERIAL'>, <TokenType.OBJECT_IDENTIFIER: 'OBJECT_IDENTIFIER'>, <TokenType.FILTER: 'FILTER'>, <TokenType.DATABASE: 'DATABASE'>, <TokenType.BIGINT: 'BIGINT'>, <TokenType.SMALLINT: 'SMALLINT'>, <TokenType.XML: 'XML'>, <TokenType.DIV: 'DIV'>, <TokenType.UUID: 'UUID'>, <TokenType.RIGHT: 'RIGHT'>, <TokenType.MONEY: 'MONEY'>, <TokenType.ENUM: 'ENUM'>, <TokenType.COLLATE: 'COLLATE'>, <TokenType.KILL: 'KILL'>, <TokenType.TIMESTAMP_MS: 'TIMESTAMP_MS'>, <TokenType.VARIANT: 'VARIANT'>, <TokenType.ARRAY: 'ARRAY'>, <TokenType.DELETE: 'DELETE'>, <TokenType.DATE: 'DATE'>, <TokenType.NULLABLE: 'NULLABLE'>, <TokenType.STRUCT: 'STRUCT'>, <TokenType.INT4MULTIRANGE: 'INT4MULTIRANGE'>, <TokenType.FALSE: 'FALSE'>, <TokenType.ORDINALITY: 'ORDINALITY'>, <TokenType.ASOF: 'ASOF'>, <TokenType.IS: 'IS'>, <TokenType.BOOLEAN: 'BOOLEAN'>, <TokenType.FIRST: 'FIRST'>, <TokenType.STORAGE_INTEGRATION: 'STORAGE_INTEGRATION'>, <TokenType.BEGIN: 'BEGIN'>, <TokenType.HSTORE: 'HSTORE'>, <TokenType.CHAR: 'CHAR'>, <TokenType.ROWS: 'ROWS'>, <TokenType.SUPER: 'SUPER'>, <TokenType.INT4RANGE: 'INT4RANGE'>, <TokenType.TSTZMULTIRANGE: 'TSTZMULTIRANGE'>, <TokenType.INT: 'INT'>, <TokenType.DATE32: 'DATE32'>, <TokenType.SETTINGS: 'SETTINGS'>, <TokenType.MODEL: 'MODEL'>, <TokenType.IDENTIFIER: 'IDENTIFIER'>, <TokenType.MEDIUMBLOB: 'MEDIUMBLOB'>, <TokenType.UINT128: 'UINT128'>, <TokenType.SCHEMA: 'SCHEMA'>, <TokenType.IPV6: 'IPV6'>, <TokenType.COPY: 'COPY'>, <TokenType.SEMI: 'SEMI'>, <TokenType.BPCHAR: 'BPCHAR'>, <TokenType.UNPIVOT: 'UNPIVOT'>, <TokenType.GEOMETRY: 'GEOMETRY'>, <TokenType.DATETIME: 'DATETIME'>, <TokenType.TSTZRANGE: 'TSTZRANGE'>, <TokenType.CASE: 'CASE'>, <TokenType.VIEW: 'VIEW'>, <TokenType.IPPREFIX: 'IPPREFIX'>, <TokenType.DATETIME64: 'DATETIME64'>, <TokenType.FINAL: 'FINAL'>, <TokenType.NUMMULTIRANGE: 'NUMMULTIRANGE'>, <TokenType.IPADDRESS: 'IPADDRESS'>, <TokenType.TINYTEXT: 'TINYTEXT'>, <TokenType.CURRENT_TIMESTAMP: 'CURRENT_TIMESTAMP'>, <TokenType.SHOW: 'SHOW'>, <TokenType.NEXT: 'NEXT'>, <TokenType.RECURSIVE: 'RECURSIVE'>, <TokenType.PERCENT: 'PERCENT'>, <TokenType.COLUMN: 'COLUMN'>, <TokenType.REFERENCES: 'REFERENCES'>, <TokenType.OVERWRITE: 'OVERWRITE'>, <TokenType.OPERATOR: 'OPERATOR'>, <TokenType.DEFAULT: 'DEFAULT'>, <TokenType.JSON: 'JSON'>, <TokenType.TSRANGE: 'TSRANGE'>, <TokenType.COMMAND: 'COMMAND'>, <TokenType.TEMPORARY: 'TEMPORARY'>, <TokenType.CURRENT_DATE: 'CURRENT_DATE'>, <TokenType.TEXT: 'TEXT'>, <TokenType.SMALLSERIAL: 'SMALLSERIAL'>, <TokenType.HLLSKETCH: 'HLLSKETCH'>, <TokenType.SET: 'SET'>, <TokenType.UNKNOWN: 'UNKNOWN'>, <TokenType.VAR: 'VAR'>, <TokenType.ASC: 'ASC'>, <TokenType.PARTITION: 'PARTITION'>, <TokenType.SMALLMONEY: 'SMALLMONEY'>, <TokenType.DATEMULTIRANGE: 'DATEMULTIRANGE'>, <TokenType.TIME: 'TIME'>, <TokenType.LONGTEXT: 'LONGTEXT'>, <TokenType.ALL: 'ALL'>, <TokenType.MEDIUMTEXT: 'MEDIUMTEXT'>, <TokenType.CUBE: 'CUBE'>, <TokenType.ENUM8: 'ENUM8'>, <TokenType.UMEDIUMINT: 'UMEDIUMINT'>, <TokenType.ENUM16: 'ENUM16'>, <TokenType.ROWVERSION: 'ROWVERSION'>, <TokenType.BINARY: 'BINARY'>, <TokenType.NUMRANGE: 'NUMRANGE'>, <TokenType.TABLE: 'TABLE'>, <TokenType.UTINYINT: 'UTINYINT'>, <TokenType.GEOGRAPHY: 'GEOGRAPHY'>, <TokenType.PROCEDURE: 'PROCEDURE'>, <TokenType.UNNEST: 'UNNEST'>, <TokenType.UNIQUEIDENTIFIER: 'UNIQUEIDENTIFIER'>, <TokenType.UBIGINT: 'UBIGINT'>, <TokenType.DICTIONARY: 'DICTIONARY'>, <TokenType.INT256: 'INT256'>, <TokenType.COMMENT: 'COMMENT'>, <TokenType.MERGE: 'MERGE'>, <TokenType.WINDOW: 'WINDOW'>, <TokenType.SERIAL: 'SERIAL'>, <TokenType.IPV4: 'IPV4'>, <TokenType.BIGDECIMAL: 'BIGDECIMAL'>, <TokenType.TINYINT: 'TINYINT'>, <TokenType.CURRENT_DATETIME: 'CURRENT_DATETIME'>, <TokenType.UNIQUE: 'UNIQUE'>, <TokenType.LONGBLOB: 'LONGBLOB'>, <TokenType.FORMAT: 'FORMAT'>, <TokenType.COMMIT: 'COMMIT'>, <TokenType.NATURAL: 'NATURAL'>, <TokenType.BIT: 'BIT'>, <TokenType.OBJECT: 'OBJECT'>, <TokenType.STRAIGHT_JOIN: 'STRAIGHT_JOIN'>, <TokenType.TIMESTAMPNTZ: 'TIMESTAMPNTZ'>, <TokenType.VARBINARY: 'VARBINARY'>, <TokenType.LIST: 'LIST'>, <TokenType.FLOAT: 'FLOAT'>, <TokenType.DECIMAL: 'DECIMAL'>, <TokenType.TRUNCATE: 'TRUNCATE'>, <TokenType.RANGE: 'RANGE'>, <TokenType.PIVOT: 'PIVOT'>, <TokenType.TIMESTAMPTZ: 'TIMESTAMPTZ'>, <TokenType.YEAR: 'YEAR'>, <TokenType.NESTED: 'NESTED'>, <TokenType.VOLATILE: 'VOLATILE'>, <TokenType.INT8RANGE: 'INT8RANGE'>, <TokenType.INT128: 'INT128'>, <TokenType.TRUE: 'TRUE'>, <TokenType.MAP: 'MAP'>, <TokenType.INT8MULTIRANGE: 'INT8MULTIRANGE'>, <TokenType.USERDEFINED: 'USERDEFINED'>, <TokenType.LOWCARDINALITY: 'LOWCARDINALITY'>, <TokenType.VARCHAR: 'VARCHAR'>, <TokenType.FIXEDSTRING: 'FIXEDSTRING'>, <TokenType.INDEX: 'INDEX'>, <TokenType.LEFT: 'LEFT'>, <TokenType.AUTO_INCREMENT: 'AUTO_INCREMENT'>, <TokenType.CURRENT_USER: 'CURRENT_USER'>, <TokenType.JSONB: 'JSONB'>, <TokenType.USMALLINT: 'USMALLINT'>, <TokenType.CONSTRAINT: 'CONSTRAINT'>, <TokenType.INTERVAL: 'INTERVAL'>, <TokenType.REFRESH: 'REFRESH'>, <TokenType.STREAMLIT: 'STREAMLIT'>, <TokenType.END: 'END'>, <TokenType.FULL: 'FULL'>, <TokenType.FOREIGN_KEY: 'FOREIGN_KEY'>, <TokenType.DESCRIBE: 'DESCRIBE'>, <TokenType.UINT: 'UINT'>, <TokenType.TDIGEST: 'TDIGEST'>, <TokenType.APPLY: 'APPLY'>, <TokenType.NAME: 'NAME'>, <TokenType.OVERLAPS: 'OVERLAPS'>, <TokenType.TIMESTAMPLTZ: 'TIMESTAMPLTZ'>, <TokenType.TIMETZ: 'TIMETZ'>, <TokenType.PRAGMA: 'PRAGMA'>, <TokenType.ROW: 'ROW'>, <TokenType.ROLLUP: 'ROLLUP'>, <TokenType.INET: 'INET'>, <TokenType.FUNCTION: 'FUNCTION'>, <TokenType.ANY: 'ANY'>, <TokenType.NCHAR: 'NCHAR'>, <TokenType.NVARCHAR: 'NVARCHAR'>, <TokenType.VECTOR: 'VECTOR'>, <TokenType.UDECIMAL: 'UDECIMAL'>, <TokenType.EXECUTE: 'EXECUTE'>, <TokenType.TIMESTAMP_S: 'TIMESTAMP_S'>, <TokenType.TIMESTAMP: 'TIMESTAMP'>, <TokenType.NULL: 'NULL'>, <TokenType.PSEUDO_TYPE: 'PSEUDO_TYPE'>, <TokenType.UPDATE: 'UPDATE'>, <TokenType.TAG: 'TAG'>, <TokenType.IMAGE: 'IMAGE'>, <TokenType.CACHE: 'CACHE'>, <TokenType.SEQUENCE: 'SEQUENCE'>, <TokenType.MEDIUMINT: 'MEDIUMINT'>, <TokenType.SIMPLEAGGREGATEFUNCTION: 'SIMPLEAGGREGATEFUNCTION'>, <TokenType.ISNULL: 'ISNULL'>, <TokenType.DOUBLE: 'DOUBLE'>, <TokenType.AGGREGATEFUNCTION: 'AGGREGATEFUNCTION'>, <TokenType.WAREHOUSE: 'WAREHOUSE'>, <TokenType.CURRENT_TIME: 'CURRENT_TIME'>, <TokenType.OFFSET: 'OFFSET'>}</span> </div> @@ -2916,447 +2938,446 @@ Default: 3</li> </div> <a class="headerlink" href="#DuckDB.Generator"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DuckDB.Generator-390"><a href="#DuckDB.Generator-390"><span class="linenos">390</span></a> <span class="k">class</span> <span class="nc">Generator</span><span class="p">(</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="p">):</span> -</span><span id="DuckDB.Generator-391"><a href="#DuckDB.Generator-391"><span class="linenos">391</span></a> <span class="n">PARAMETER_TOKEN</span> <span class="o">=</span> <span class="s2">"$"</span> -</span><span id="DuckDB.Generator-392"><a href="#DuckDB.Generator-392"><span class="linenos">392</span></a> <span class="n">NAMED_PLACEHOLDER_TOKEN</span> <span class="o">=</span> <span class="s2">"$"</span> -</span><span id="DuckDB.Generator-393"><a href="#DuckDB.Generator-393"><span class="linenos">393</span></a> <span class="n">JOIN_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="DuckDB.Generator-394"><a href="#DuckDB.Generator-394"><span class="linenos">394</span></a> <span class="n">TABLE_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="DuckDB.Generator-395"><a href="#DuckDB.Generator-395"><span class="linenos">395</span></a> <span class="n">QUERY_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="DuckDB.Generator-396"><a href="#DuckDB.Generator-396"><span class="linenos">396</span></a> <span class="n">LIMIT_FETCH</span> <span class="o">=</span> <span class="s2">"LIMIT"</span> -</span><span id="DuckDB.Generator-397"><a href="#DuckDB.Generator-397"><span class="linenos">397</span></a> <span class="n">STRUCT_DELIMITER</span> <span class="o">=</span> <span class="p">(</span><span class="s2">"("</span><span class="p">,</span> <span class="s2">")"</span><span class="p">)</span> -</span><span id="DuckDB.Generator-398"><a href="#DuckDB.Generator-398"><span class="linenos">398</span></a> <span class="n">RENAME_TABLE_WITH_DB</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="DuckDB.Generator-399"><a href="#DuckDB.Generator-399"><span class="linenos">399</span></a> <span class="n">NVL2_SUPPORTED</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="DuckDB.Generator-400"><a href="#DuckDB.Generator-400"><span class="linenos">400</span></a> <span class="n">SEMI_ANTI_JOIN_WITH_SIDE</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="DuckDB.Generator-401"><a href="#DuckDB.Generator-401"><span class="linenos">401</span></a> <span class="n">TABLESAMPLE_KEYWORDS</span> <span class="o">=</span> <span class="s2">"USING SAMPLE"</span> -</span><span id="DuckDB.Generator-402"><a href="#DuckDB.Generator-402"><span class="linenos">402</span></a> <span class="n">TABLESAMPLE_SEED_KEYWORD</span> <span class="o">=</span> <span class="s2">"REPEATABLE"</span> -</span><span id="DuckDB.Generator-403"><a href="#DuckDB.Generator-403"><span class="linenos">403</span></a> <span class="n">LAST_DAY_SUPPORTS_DATE_PART</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="DuckDB.Generator-404"><a href="#DuckDB.Generator-404"><span class="linenos">404</span></a> <span class="n">JSON_KEY_VALUE_PAIR_SEP</span> <span class="o">=</span> <span class="s2">","</span> -</span><span id="DuckDB.Generator-405"><a href="#DuckDB.Generator-405"><span class="linenos">405</span></a> <span class="n">IGNORE_NULLS_IN_FUNC</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="DuckDB.Generator-406"><a href="#DuckDB.Generator-406"><span class="linenos">406</span></a> <span class="n">JSON_PATH_BRACKETED_KEY_SUPPORTED</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="DuckDB.Generator-407"><a href="#DuckDB.Generator-407"><span class="linenos">407</span></a> <span class="n">SUPPORTS_CREATE_TABLE_LIKE</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="DuckDB.Generator-408"><a href="#DuckDB.Generator-408"><span class="linenos">408</span></a> <span class="n">MULTI_ARG_DISTINCT</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="DuckDB.Generator-409"><a href="#DuckDB.Generator-409"><span class="linenos">409</span></a> <span class="n">CAN_IMPLEMENT_ARRAY_ANY</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="DuckDB.Generator-410"><a href="#DuckDB.Generator-410"><span class="linenos">410</span></a> <span class="n">SUPPORTS_TO_NUMBER</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="DuckDB.Generator-411"><a href="#DuckDB.Generator-411"><span class="linenos">411</span></a> <span class="n">COPY_HAS_INTO_KEYWORD</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="DuckDB.Generator-412"><a href="#DuckDB.Generator-412"><span class="linenos">412</span></a> <span class="n">STAR_EXCEPT</span> <span class="o">=</span> <span class="s2">"EXCLUDE"</span> -</span><span id="DuckDB.Generator-413"><a href="#DuckDB.Generator-413"><span class="linenos">413</span></a> <span class="n">PAD_FILL_PATTERN_IS_REQUIRED</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="DuckDB.Generator-414"><a href="#DuckDB.Generator-414"><span class="linenos">414</span></a> -</span><span id="DuckDB.Generator-415"><a href="#DuckDB.Generator-415"><span class="linenos">415</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="DuckDB.Generator-416"><a href="#DuckDB.Generator-416"><span class="linenos">416</span></a> <span class="o">**</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">TRANSFORMS</span><span class="p">,</span> -</span><span id="DuckDB.Generator-417"><a href="#DuckDB.Generator-417"><span class="linenos">417</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxDistinct</span><span class="p">:</span> <span class="n">approx_count_distinct_sql</span><span class="p">,</span> -</span><span id="DuckDB.Generator-418"><a href="#DuckDB.Generator-418"><span class="linenos">418</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Array</span><span class="p">:</span> <span class="n">inline_array_unless_query</span><span class="p">,</span> -</span><span id="DuckDB.Generator-419"><a href="#DuckDB.Generator-419"><span class="linenos">419</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayContainsAll</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"ARRAY_HAS_ALL"</span><span class="p">),</span> -</span><span id="DuckDB.Generator-420"><a href="#DuckDB.Generator-420"><span class="linenos">420</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayFilter</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"LIST_FILTER"</span><span class="p">),</span> -</span><span id="DuckDB.Generator-421"><a href="#DuckDB.Generator-421"><span class="linenos">421</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArraySize</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"ARRAY_LENGTH"</span><span class="p">),</span> -</span><span id="DuckDB.Generator-422"><a href="#DuckDB.Generator-422"><span class="linenos">422</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArgMax</span><span class="p">:</span> <span class="n">arg_max_or_min_no_count</span><span class="p">(</span><span class="s2">"ARG_MAX"</span><span class="p">),</span> -</span><span id="DuckDB.Generator-423"><a href="#DuckDB.Generator-423"><span class="linenos">423</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArgMin</span><span class="p">:</span> <span class="n">arg_max_or_min_no_count</span><span class="p">(</span><span class="s2">"ARG_MIN"</span><span class="p">),</span> -</span><span id="DuckDB.Generator-424"><a href="#DuckDB.Generator-424"><span class="linenos">424</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArraySort</span><span class="p">:</span> <span class="n">_array_sort_sql</span><span class="p">,</span> -</span><span id="DuckDB.Generator-425"><a href="#DuckDB.Generator-425"><span class="linenos">425</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArraySum</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"LIST_SUM"</span><span class="p">),</span> -</span><span id="DuckDB.Generator-426"><a href="#DuckDB.Generator-426"><span class="linenos">426</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseXor</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"XOR"</span><span class="p">),</span> -</span><span id="DuckDB.Generator-427"><a href="#DuckDB.Generator-427"><span class="linenos">427</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CommentColumnConstraint</span><span class="p">:</span> <span class="n">no_comment_column_constraint_sql</span><span class="p">,</span> -</span><span id="DuckDB.Generator-428"><a href="#DuckDB.Generator-428"><span class="linenos">428</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CurrentDate</span><span class="p">:</span> <span class="k">lambda</span> <span class="o">*</span><span class="n">_</span><span class="p">:</span> <span class="s2">"CURRENT_DATE"</span><span class="p">,</span> -</span><span id="DuckDB.Generator-429"><a href="#DuckDB.Generator-429"><span class="linenos">429</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CurrentTime</span><span class="p">:</span> <span class="k">lambda</span> <span class="o">*</span><span class="n">_</span><span class="p">:</span> <span class="s2">"CURRENT_TIME"</span><span class="p">,</span> -</span><span id="DuckDB.Generator-430"><a href="#DuckDB.Generator-430"><span class="linenos">430</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CurrentTimestamp</span><span class="p">:</span> <span class="k">lambda</span> <span class="o">*</span><span class="n">_</span><span class="p">:</span> <span class="s2">"CURRENT_TIMESTAMP"</span><span class="p">,</span> -</span><span id="DuckDB.Generator-431"><a href="#DuckDB.Generator-431"><span class="linenos">431</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DayOfMonth</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"DAYOFMONTH"</span><span class="p">),</span> -</span><span id="DuckDB.Generator-432"><a href="#DuckDB.Generator-432"><span class="linenos">432</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DayOfWeek</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"DAYOFWEEK"</span><span class="p">),</span> -</span><span id="DuckDB.Generator-433"><a href="#DuckDB.Generator-433"><span class="linenos">433</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DayOfYear</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"DAYOFYEAR"</span><span class="p">),</span> -</span><span id="DuckDB.Generator-434"><a href="#DuckDB.Generator-434"><span class="linenos">434</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">:</span> <span class="n">_datatype_sql</span><span class="p">,</span> -</span><span id="DuckDB.Generator-435"><a href="#DuckDB.Generator-435"><span class="linenos">435</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Date</span><span class="p">:</span> <span class="n">_date_sql</span><span class="p">,</span> -</span><span id="DuckDB.Generator-436"><a href="#DuckDB.Generator-436"><span class="linenos">436</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</span><span class="p">:</span> <span class="n">_date_delta_sql</span><span class="p">,</span> -</span><span id="DuckDB.Generator-437"><a href="#DuckDB.Generator-437"><span class="linenos">437</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateFromParts</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"MAKE_DATE"</span><span class="p">),</span> -</span><span id="DuckDB.Generator-438"><a href="#DuckDB.Generator-438"><span class="linenos">438</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateSub</span><span class="p">:</span> <span class="n">_date_delta_sql</span><span class="p">,</span> -</span><span id="DuckDB.Generator-439"><a href="#DuckDB.Generator-439"><span class="linenos">439</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateDiff</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="DuckDB.Generator-440"><a href="#DuckDB.Generator-440"><span class="linenos">440</span></a> <span class="s2">"DATE_DIFF"</span><span class="p">,</span> <span class="sa">f</span><span class="s2">"'</span><span class="si">{</span><span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'unit'</span><span class="p">)</span><span class="w"> </span><span class="ow">or</span><span class="w"> </span><span class="s1">'DAY'</span><span class="si">}</span><span class="s2">'"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span> -</span><span id="DuckDB.Generator-441"><a href="#DuckDB.Generator-441"><span class="linenos">441</span></a> <span class="p">),</span> -</span><span id="DuckDB.Generator-442"><a href="#DuckDB.Generator-442"><span class="linenos">442</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateStrToDate</span><span class="p">:</span> <span class="n">datestrtodate_sql</span><span class="p">,</span> -</span><span id="DuckDB.Generator-443"><a href="#DuckDB.Generator-443"><span class="linenos">443</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Datetime</span><span class="p">:</span> <span class="n">no_datetime_sql</span><span class="p">,</span> -</span><span id="DuckDB.Generator-444"><a href="#DuckDB.Generator-444"><span class="linenos">444</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DatetimeSub</span><span class="p">:</span> <span class="n">_date_delta_sql</span><span class="p">,</span> -</span><span id="DuckDB.Generator-445"><a href="#DuckDB.Generator-445"><span class="linenos">445</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DatetimeAdd</span><span class="p">:</span> <span class="n">_date_delta_sql</span><span class="p">,</span> -</span><span id="DuckDB.Generator-446"><a href="#DuckDB.Generator-446"><span class="linenos">446</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateToDi</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> -</span><span id="DuckDB.Generator-447"><a href="#DuckDB.Generator-447"><span class="linenos">447</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"CAST(STRFTIME(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="n">DuckDB</span><span class="o">.</span><span class="n">DATEINT_FORMAT</span><span class="si">}</span><span class="s2">) AS INT)"</span><span class="p">,</span> -</span><span id="DuckDB.Generator-448"><a href="#DuckDB.Generator-448"><span class="linenos">448</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Decode</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="n">encode_decode_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">,</span> <span class="s2">"DECODE"</span><span class="p">,</span> <span class="n">replace</span><span class="o">=</span><span class="kc">False</span><span class="p">),</span> -</span><span id="DuckDB.Generator-449"><a href="#DuckDB.Generator-449"><span class="linenos">449</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DiToDate</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> -</span><span id="DuckDB.Generator-450"><a href="#DuckDB.Generator-450"><span class="linenos">450</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"CAST(STRPTIME(CAST(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS TEXT), </span><span class="si">{</span><span class="n">DuckDB</span><span class="o">.</span><span class="n">DATEINT_FORMAT</span><span class="si">}</span><span class="s2">) AS DATE)"</span><span class="p">,</span> -</span><span id="DuckDB.Generator-451"><a href="#DuckDB.Generator-451"><span class="linenos">451</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Encode</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="n">encode_decode_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">,</span> <span class="s2">"ENCODE"</span><span class="p">,</span> <span class="n">replace</span><span class="o">=</span><span class="kc">False</span><span class="p">),</span> -</span><span id="DuckDB.Generator-452"><a href="#DuckDB.Generator-452"><span class="linenos">452</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Explode</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"UNNEST"</span><span class="p">),</span> -</span><span id="DuckDB.Generator-453"><a href="#DuckDB.Generator-453"><span class="linenos">453</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">IntDiv</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="s2">"//"</span><span class="p">),</span> -</span><span id="DuckDB.Generator-454"><a href="#DuckDB.Generator-454"><span class="linenos">454</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">IsInf</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"ISINF"</span><span class="p">),</span> -</span><span id="DuckDB.Generator-455"><a href="#DuckDB.Generator-455"><span class="linenos">455</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">IsNan</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"ISNAN"</span><span class="p">),</span> -</span><span id="DuckDB.Generator-456"><a href="#DuckDB.Generator-456"><span class="linenos">456</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtract</span><span class="p">:</span> <span class="n">_arrow_json_extract_sql</span><span class="p">,</span> -</span><span id="DuckDB.Generator-457"><a href="#DuckDB.Generator-457"><span class="linenos">457</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtractScalar</span><span class="p">:</span> <span class="n">_arrow_json_extract_sql</span><span class="p">,</span> -</span><span id="DuckDB.Generator-458"><a href="#DuckDB.Generator-458"><span class="linenos">458</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONFormat</span><span class="p">:</span> <span class="n">_json_format_sql</span><span class="p">,</span> -</span><span id="DuckDB.Generator-459"><a href="#DuckDB.Generator-459"><span class="linenos">459</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LogicalOr</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"BOOL_OR"</span><span class="p">),</span> -</span><span id="DuckDB.Generator-460"><a href="#DuckDB.Generator-460"><span class="linenos">460</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LogicalAnd</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"BOOL_AND"</span><span class="p">),</span> -</span><span id="DuckDB.Generator-461"><a href="#DuckDB.Generator-461"><span class="linenos">461</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MD5Digest</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"UNHEX"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"MD5"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">)),</span> -</span><span id="DuckDB.Generator-462"><a href="#DuckDB.Generator-462"><span class="linenos">462</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MonthsBetween</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="DuckDB.Generator-463"><a href="#DuckDB.Generator-463"><span class="linenos">463</span></a> <span class="s2">"DATEDIFF"</span><span class="p">,</span> -</span><span id="DuckDB.Generator-464"><a href="#DuckDB.Generator-464"><span class="linenos">464</span></a> <span class="s2">"'month'"</span><span class="p">,</span> -</span><span id="DuckDB.Generator-465"><a href="#DuckDB.Generator-465"><span class="linenos">465</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMP</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> -</span><span id="DuckDB.Generator-466"><a href="#DuckDB.Generator-466"><span class="linenos">466</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMP</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> -</span><span id="DuckDB.Generator-467"><a href="#DuckDB.Generator-467"><span class="linenos">467</span></a> <span class="p">),</span> -</span><span id="DuckDB.Generator-468"><a href="#DuckDB.Generator-468"><span class="linenos">468</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PercentileCont</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"QUANTILE_CONT"</span><span class="p">),</span> -</span><span id="DuckDB.Generator-469"><a href="#DuckDB.Generator-469"><span class="linenos">469</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PercentileDisc</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"QUANTILE_DISC"</span><span class="p">),</span> -</span><span id="DuckDB.Generator-470"><a href="#DuckDB.Generator-470"><span class="linenos">470</span></a> <span class="c1"># DuckDB doesn't allow qualified columns inside of PIVOT expressions.</span> -</span><span id="DuckDB.Generator-471"><a href="#DuckDB.Generator-471"><span class="linenos">471</span></a> <span class="c1"># See: https://github.com/duckdb/duckdb/blob/671faf92411182f81dce42ac43de8bfb05d9909e/src/planner/binder/tableref/bind_pivot.cpp#L61-L62</span> -</span><span id="DuckDB.Generator-472"><a href="#DuckDB.Generator-472"><span class="linenos">472</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Pivot</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">([</span><span class="n">transforms</span><span class="o">.</span><span class="n">unqualify_columns</span><span class="p">]),</span> -</span><span id="DuckDB.Generator-473"><a href="#DuckDB.Generator-473"><span class="linenos">473</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpExtract</span><span class="p">:</span> <span class="n">regexp_extract_sql</span><span class="p">,</span> -</span><span id="DuckDB.Generator-474"><a href="#DuckDB.Generator-474"><span class="linenos">474</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpReplace</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="DuckDB.Generator-475"><a href="#DuckDB.Generator-475"><span class="linenos">475</span></a> <span class="s2">"REGEXP_REPLACE"</span><span class="p">,</span> -</span><span id="DuckDB.Generator-476"><a href="#DuckDB.Generator-476"><span class="linenos">476</span></a> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> -</span><span id="DuckDB.Generator-477"><a href="#DuckDB.Generator-477"><span class="linenos">477</span></a> <span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> -</span><span id="DuckDB.Generator-478"><a href="#DuckDB.Generator-478"><span class="linenos">478</span></a> <span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"replacement"</span><span class="p">),</span> -</span><span id="DuckDB.Generator-479"><a href="#DuckDB.Generator-479"><span class="linenos">479</span></a> <span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"modifiers"</span><span class="p">),</span> -</span><span id="DuckDB.Generator-480"><a href="#DuckDB.Generator-480"><span class="linenos">480</span></a> <span class="p">),</span> -</span><span id="DuckDB.Generator-481"><a href="#DuckDB.Generator-481"><span class="linenos">481</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpLike</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"REGEXP_MATCHES"</span><span class="p">),</span> -</span><span id="DuckDB.Generator-482"><a href="#DuckDB.Generator-482"><span class="linenos">482</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpSplit</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"STR_SPLIT_REGEX"</span><span class="p">),</span> -</span><span id="DuckDB.Generator-483"><a href="#DuckDB.Generator-483"><span class="linenos">483</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Return</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">),</span> -</span><span id="DuckDB.Generator-484"><a href="#DuckDB.Generator-484"><span class="linenos">484</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ReturnsProperty</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="s2">"TABLE"</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">e</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">Schema</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span><span class="p">,</span> -</span><span id="DuckDB.Generator-485"><a href="#DuckDB.Generator-485"><span class="linenos">485</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Rand</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"RANDOM"</span><span class="p">),</span> -</span><span id="DuckDB.Generator-486"><a href="#DuckDB.Generator-486"><span class="linenos">486</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SafeDivide</span><span class="p">:</span> <span class="n">no_safe_divide_sql</span><span class="p">,</span> -</span><span id="DuckDB.Generator-487"><a href="#DuckDB.Generator-487"><span class="linenos">487</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Split</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"STR_SPLIT"</span><span class="p">),</span> -</span><span id="DuckDB.Generator-488"><a href="#DuckDB.Generator-488"><span class="linenos">488</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SortArray</span><span class="p">:</span> <span class="n">_sort_array_sql</span><span class="p">,</span> -</span><span id="DuckDB.Generator-489"><a href="#DuckDB.Generator-489"><span class="linenos">489</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrPosition</span><span class="p">:</span> <span class="n">str_position_sql</span><span class="p">,</span> -</span><span id="DuckDB.Generator-490"><a href="#DuckDB.Generator-490"><span class="linenos">490</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToUnix</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="DuckDB.Generator-491"><a href="#DuckDB.Generator-491"><span class="linenos">491</span></a> <span class="s2">"EPOCH"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"STRPTIME"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span><span class="n">e</span><span class="p">))</span> -</span><span id="DuckDB.Generator-492"><a href="#DuckDB.Generator-492"><span class="linenos">492</span></a> <span class="p">),</span> -</span><span id="DuckDB.Generator-493"><a href="#DuckDB.Generator-493"><span class="linenos">493</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Struct</span><span class="p">:</span> <span class="n">_struct_sql</span><span class="p">,</span> -</span><span id="DuckDB.Generator-494"><a href="#DuckDB.Generator-494"><span class="linenos">494</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeAdd</span><span class="p">:</span> <span class="n">_date_delta_sql</span><span class="p">,</span> -</span><span id="DuckDB.Generator-495"><a href="#DuckDB.Generator-495"><span class="linenos">495</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Time</span><span class="p">:</span> <span class="n">no_time_sql</span><span class="p">,</span> -</span><span id="DuckDB.Generator-496"><a href="#DuckDB.Generator-496"><span class="linenos">496</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Timestamp</span><span class="p">:</span> <span class="n">no_timestamp_sql</span><span class="p">,</span> -</span><span id="DuckDB.Generator-497"><a href="#DuckDB.Generator-497"><span class="linenos">497</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimestampDiff</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="DuckDB.Generator-498"><a href="#DuckDB.Generator-498"><span class="linenos">498</span></a> <span class="s2">"DATE_DIFF"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">unit</span><span class="p">),</span> <span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span> -</span><span id="DuckDB.Generator-499"><a href="#DuckDB.Generator-499"><span class="linenos">499</span></a> <span class="p">),</span> -</span><span id="DuckDB.Generator-500"><a href="#DuckDB.Generator-500"><span class="linenos">500</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimestampTrunc</span><span class="p">:</span> <span class="n">timestamptrunc_sql</span><span class="p">(),</span> -</span><span id="DuckDB.Generator-501"><a href="#DuckDB.Generator-501"><span class="linenos">501</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeStrToDate</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">e</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">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">DATE</span><span class="p">)),</span> -</span><span id="DuckDB.Generator-502"><a href="#DuckDB.Generator-502"><span class="linenos">502</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeStrToTime</span><span class="p">:</span> <span class="n">timestrtotime_sql</span><span class="p">,</span> -</span><span id="DuckDB.Generator-503"><a href="#DuckDB.Generator-503"><span class="linenos">503</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeStrToUnix</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="DuckDB.Generator-504"><a href="#DuckDB.Generator-504"><span class="linenos">504</span></a> <span class="s2">"EPOCH"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMP</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DuckDB.Generator-396"><a href="#DuckDB.Generator-396"><span class="linenos">396</span></a> <span class="k">class</span> <span class="nc">Generator</span><span class="p">(</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="p">):</span> +</span><span id="DuckDB.Generator-397"><a href="#DuckDB.Generator-397"><span class="linenos">397</span></a> <span class="n">PARAMETER_TOKEN</span> <span class="o">=</span> <span class="s2">"$"</span> +</span><span id="DuckDB.Generator-398"><a href="#DuckDB.Generator-398"><span class="linenos">398</span></a> <span class="n">NAMED_PLACEHOLDER_TOKEN</span> <span class="o">=</span> <span class="s2">"$"</span> +</span><span id="DuckDB.Generator-399"><a href="#DuckDB.Generator-399"><span class="linenos">399</span></a> <span class="n">JOIN_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="DuckDB.Generator-400"><a href="#DuckDB.Generator-400"><span class="linenos">400</span></a> <span class="n">TABLE_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="DuckDB.Generator-401"><a href="#DuckDB.Generator-401"><span class="linenos">401</span></a> <span class="n">QUERY_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="DuckDB.Generator-402"><a href="#DuckDB.Generator-402"><span class="linenos">402</span></a> <span class="n">LIMIT_FETCH</span> <span class="o">=</span> <span class="s2">"LIMIT"</span> +</span><span id="DuckDB.Generator-403"><a href="#DuckDB.Generator-403"><span class="linenos">403</span></a> <span class="n">STRUCT_DELIMITER</span> <span class="o">=</span> <span class="p">(</span><span class="s2">"("</span><span class="p">,</span> <span class="s2">")"</span><span class="p">)</span> +</span><span id="DuckDB.Generator-404"><a href="#DuckDB.Generator-404"><span class="linenos">404</span></a> <span class="n">RENAME_TABLE_WITH_DB</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="DuckDB.Generator-405"><a href="#DuckDB.Generator-405"><span class="linenos">405</span></a> <span class="n">NVL2_SUPPORTED</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="DuckDB.Generator-406"><a href="#DuckDB.Generator-406"><span class="linenos">406</span></a> <span class="n">SEMI_ANTI_JOIN_WITH_SIDE</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="DuckDB.Generator-407"><a href="#DuckDB.Generator-407"><span class="linenos">407</span></a> <span class="n">TABLESAMPLE_KEYWORDS</span> <span class="o">=</span> <span class="s2">"USING SAMPLE"</span> +</span><span id="DuckDB.Generator-408"><a href="#DuckDB.Generator-408"><span class="linenos">408</span></a> <span class="n">TABLESAMPLE_SEED_KEYWORD</span> <span class="o">=</span> <span class="s2">"REPEATABLE"</span> +</span><span id="DuckDB.Generator-409"><a href="#DuckDB.Generator-409"><span class="linenos">409</span></a> <span class="n">LAST_DAY_SUPPORTS_DATE_PART</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="DuckDB.Generator-410"><a href="#DuckDB.Generator-410"><span class="linenos">410</span></a> <span class="n">JSON_KEY_VALUE_PAIR_SEP</span> <span class="o">=</span> <span class="s2">","</span> +</span><span id="DuckDB.Generator-411"><a href="#DuckDB.Generator-411"><span class="linenos">411</span></a> <span class="n">IGNORE_NULLS_IN_FUNC</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="DuckDB.Generator-412"><a href="#DuckDB.Generator-412"><span class="linenos">412</span></a> <span class="n">JSON_PATH_BRACKETED_KEY_SUPPORTED</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="DuckDB.Generator-413"><a href="#DuckDB.Generator-413"><span class="linenos">413</span></a> <span class="n">SUPPORTS_CREATE_TABLE_LIKE</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="DuckDB.Generator-414"><a href="#DuckDB.Generator-414"><span class="linenos">414</span></a> <span class="n">MULTI_ARG_DISTINCT</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="DuckDB.Generator-415"><a href="#DuckDB.Generator-415"><span class="linenos">415</span></a> <span class="n">CAN_IMPLEMENT_ARRAY_ANY</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="DuckDB.Generator-416"><a href="#DuckDB.Generator-416"><span class="linenos">416</span></a> <span class="n">SUPPORTS_TO_NUMBER</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="DuckDB.Generator-417"><a href="#DuckDB.Generator-417"><span class="linenos">417</span></a> <span class="n">COPY_HAS_INTO_KEYWORD</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="DuckDB.Generator-418"><a href="#DuckDB.Generator-418"><span class="linenos">418</span></a> <span class="n">STAR_EXCEPT</span> <span class="o">=</span> <span class="s2">"EXCLUDE"</span> +</span><span id="DuckDB.Generator-419"><a href="#DuckDB.Generator-419"><span class="linenos">419</span></a> <span class="n">PAD_FILL_PATTERN_IS_REQUIRED</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="DuckDB.Generator-420"><a href="#DuckDB.Generator-420"><span class="linenos">420</span></a> +</span><span id="DuckDB.Generator-421"><a href="#DuckDB.Generator-421"><span class="linenos">421</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="DuckDB.Generator-422"><a href="#DuckDB.Generator-422"><span class="linenos">422</span></a> <span class="o">**</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">TRANSFORMS</span><span class="p">,</span> +</span><span id="DuckDB.Generator-423"><a href="#DuckDB.Generator-423"><span class="linenos">423</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxDistinct</span><span class="p">:</span> <span class="n">approx_count_distinct_sql</span><span class="p">,</span> +</span><span id="DuckDB.Generator-424"><a href="#DuckDB.Generator-424"><span class="linenos">424</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Array</span><span class="p">:</span> <span class="n">inline_array_unless_query</span><span class="p">,</span> +</span><span id="DuckDB.Generator-425"><a href="#DuckDB.Generator-425"><span class="linenos">425</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayContainsAll</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"ARRAY_HAS_ALL"</span><span class="p">),</span> +</span><span id="DuckDB.Generator-426"><a href="#DuckDB.Generator-426"><span class="linenos">426</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayFilter</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"LIST_FILTER"</span><span class="p">),</span> +</span><span id="DuckDB.Generator-427"><a href="#DuckDB.Generator-427"><span class="linenos">427</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArraySize</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"ARRAY_LENGTH"</span><span class="p">),</span> +</span><span id="DuckDB.Generator-428"><a href="#DuckDB.Generator-428"><span class="linenos">428</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArgMax</span><span class="p">:</span> <span class="n">arg_max_or_min_no_count</span><span class="p">(</span><span class="s2">"ARG_MAX"</span><span class="p">),</span> +</span><span id="DuckDB.Generator-429"><a href="#DuckDB.Generator-429"><span class="linenos">429</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArgMin</span><span class="p">:</span> <span class="n">arg_max_or_min_no_count</span><span class="p">(</span><span class="s2">"ARG_MIN"</span><span class="p">),</span> +</span><span id="DuckDB.Generator-430"><a href="#DuckDB.Generator-430"><span class="linenos">430</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArraySort</span><span class="p">:</span> <span class="n">_array_sort_sql</span><span class="p">,</span> +</span><span id="DuckDB.Generator-431"><a href="#DuckDB.Generator-431"><span class="linenos">431</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArraySum</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"LIST_SUM"</span><span class="p">),</span> +</span><span id="DuckDB.Generator-432"><a href="#DuckDB.Generator-432"><span class="linenos">432</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseXor</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"XOR"</span><span class="p">),</span> +</span><span id="DuckDB.Generator-433"><a href="#DuckDB.Generator-433"><span class="linenos">433</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CommentColumnConstraint</span><span class="p">:</span> <span class="n">no_comment_column_constraint_sql</span><span class="p">,</span> +</span><span id="DuckDB.Generator-434"><a href="#DuckDB.Generator-434"><span class="linenos">434</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CurrentDate</span><span class="p">:</span> <span class="k">lambda</span> <span class="o">*</span><span class="n">_</span><span class="p">:</span> <span class="s2">"CURRENT_DATE"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-435"><a href="#DuckDB.Generator-435"><span class="linenos">435</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CurrentTime</span><span class="p">:</span> <span class="k">lambda</span> <span class="o">*</span><span class="n">_</span><span class="p">:</span> <span class="s2">"CURRENT_TIME"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-436"><a href="#DuckDB.Generator-436"><span class="linenos">436</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CurrentTimestamp</span><span class="p">:</span> <span class="k">lambda</span> <span class="o">*</span><span class="n">_</span><span class="p">:</span> <span class="s2">"CURRENT_TIMESTAMP"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-437"><a href="#DuckDB.Generator-437"><span class="linenos">437</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DayOfMonth</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"DAYOFMONTH"</span><span class="p">),</span> +</span><span id="DuckDB.Generator-438"><a href="#DuckDB.Generator-438"><span class="linenos">438</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DayOfWeek</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"DAYOFWEEK"</span><span class="p">),</span> +</span><span id="DuckDB.Generator-439"><a href="#DuckDB.Generator-439"><span class="linenos">439</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DayOfYear</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"DAYOFYEAR"</span><span class="p">),</span> +</span><span id="DuckDB.Generator-440"><a href="#DuckDB.Generator-440"><span class="linenos">440</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">:</span> <span class="n">_datatype_sql</span><span class="p">,</span> +</span><span id="DuckDB.Generator-441"><a href="#DuckDB.Generator-441"><span class="linenos">441</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Date</span><span class="p">:</span> <span class="n">_date_sql</span><span class="p">,</span> +</span><span id="DuckDB.Generator-442"><a href="#DuckDB.Generator-442"><span class="linenos">442</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</span><span class="p">:</span> <span class="n">_date_delta_sql</span><span class="p">,</span> +</span><span id="DuckDB.Generator-443"><a href="#DuckDB.Generator-443"><span class="linenos">443</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateFromParts</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"MAKE_DATE"</span><span class="p">),</span> +</span><span id="DuckDB.Generator-444"><a href="#DuckDB.Generator-444"><span class="linenos">444</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateSub</span><span class="p">:</span> <span class="n">_date_delta_sql</span><span class="p">,</span> +</span><span id="DuckDB.Generator-445"><a href="#DuckDB.Generator-445"><span class="linenos">445</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateDiff</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> +</span><span id="DuckDB.Generator-446"><a href="#DuckDB.Generator-446"><span class="linenos">446</span></a> <span class="s2">"DATE_DIFF"</span><span class="p">,</span> <span class="sa">f</span><span class="s2">"'</span><span class="si">{</span><span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'unit'</span><span class="p">)</span><span class="w"> </span><span class="ow">or</span><span class="w"> </span><span class="s1">'DAY'</span><span class="si">}</span><span class="s2">'"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span> +</span><span id="DuckDB.Generator-447"><a href="#DuckDB.Generator-447"><span class="linenos">447</span></a> <span class="p">),</span> +</span><span id="DuckDB.Generator-448"><a href="#DuckDB.Generator-448"><span class="linenos">448</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateStrToDate</span><span class="p">:</span> <span class="n">datestrtodate_sql</span><span class="p">,</span> +</span><span id="DuckDB.Generator-449"><a href="#DuckDB.Generator-449"><span class="linenos">449</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Datetime</span><span class="p">:</span> <span class="n">no_datetime_sql</span><span class="p">,</span> +</span><span id="DuckDB.Generator-450"><a href="#DuckDB.Generator-450"><span class="linenos">450</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DatetimeSub</span><span class="p">:</span> <span class="n">_date_delta_sql</span><span class="p">,</span> +</span><span id="DuckDB.Generator-451"><a href="#DuckDB.Generator-451"><span class="linenos">451</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DatetimeAdd</span><span class="p">:</span> <span class="n">_date_delta_sql</span><span class="p">,</span> +</span><span id="DuckDB.Generator-452"><a href="#DuckDB.Generator-452"><span class="linenos">452</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateToDi</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> +</span><span id="DuckDB.Generator-453"><a href="#DuckDB.Generator-453"><span class="linenos">453</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"CAST(STRFTIME(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="n">DuckDB</span><span class="o">.</span><span class="n">DATEINT_FORMAT</span><span class="si">}</span><span class="s2">) AS INT)"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-454"><a href="#DuckDB.Generator-454"><span class="linenos">454</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Decode</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="n">encode_decode_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">,</span> <span class="s2">"DECODE"</span><span class="p">,</span> <span class="n">replace</span><span class="o">=</span><span class="kc">False</span><span class="p">),</span> +</span><span id="DuckDB.Generator-455"><a href="#DuckDB.Generator-455"><span class="linenos">455</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DiToDate</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> +</span><span id="DuckDB.Generator-456"><a href="#DuckDB.Generator-456"><span class="linenos">456</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"CAST(STRPTIME(CAST(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS TEXT), </span><span class="si">{</span><span class="n">DuckDB</span><span class="o">.</span><span class="n">DATEINT_FORMAT</span><span class="si">}</span><span class="s2">) AS DATE)"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-457"><a href="#DuckDB.Generator-457"><span class="linenos">457</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Encode</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="n">encode_decode_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">,</span> <span class="s2">"ENCODE"</span><span class="p">,</span> <span class="n">replace</span><span class="o">=</span><span class="kc">False</span><span class="p">),</span> +</span><span id="DuckDB.Generator-458"><a href="#DuckDB.Generator-458"><span class="linenos">458</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Explode</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"UNNEST"</span><span class="p">),</span> +</span><span id="DuckDB.Generator-459"><a href="#DuckDB.Generator-459"><span class="linenos">459</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">IntDiv</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="s2">"//"</span><span class="p">),</span> +</span><span id="DuckDB.Generator-460"><a href="#DuckDB.Generator-460"><span class="linenos">460</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">IsInf</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"ISINF"</span><span class="p">),</span> +</span><span id="DuckDB.Generator-461"><a href="#DuckDB.Generator-461"><span class="linenos">461</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">IsNan</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"ISNAN"</span><span class="p">),</span> +</span><span id="DuckDB.Generator-462"><a href="#DuckDB.Generator-462"><span class="linenos">462</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtract</span><span class="p">:</span> <span class="n">_arrow_json_extract_sql</span><span class="p">,</span> +</span><span id="DuckDB.Generator-463"><a href="#DuckDB.Generator-463"><span class="linenos">463</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtractScalar</span><span class="p">:</span> <span class="n">_arrow_json_extract_sql</span><span class="p">,</span> +</span><span id="DuckDB.Generator-464"><a href="#DuckDB.Generator-464"><span class="linenos">464</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONFormat</span><span class="p">:</span> <span class="n">_json_format_sql</span><span class="p">,</span> +</span><span id="DuckDB.Generator-465"><a href="#DuckDB.Generator-465"><span class="linenos">465</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LogicalOr</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"BOOL_OR"</span><span class="p">),</span> +</span><span id="DuckDB.Generator-466"><a href="#DuckDB.Generator-466"><span class="linenos">466</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LogicalAnd</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"BOOL_AND"</span><span class="p">),</span> +</span><span id="DuckDB.Generator-467"><a href="#DuckDB.Generator-467"><span class="linenos">467</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MD5Digest</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"UNHEX"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"MD5"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">)),</span> +</span><span id="DuckDB.Generator-468"><a href="#DuckDB.Generator-468"><span class="linenos">468</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MonthsBetween</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> +</span><span id="DuckDB.Generator-469"><a href="#DuckDB.Generator-469"><span class="linenos">469</span></a> <span class="s2">"DATEDIFF"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-470"><a href="#DuckDB.Generator-470"><span class="linenos">470</span></a> <span class="s2">"'month'"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-471"><a href="#DuckDB.Generator-471"><span class="linenos">471</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMP</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> +</span><span id="DuckDB.Generator-472"><a href="#DuckDB.Generator-472"><span class="linenos">472</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMP</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> +</span><span id="DuckDB.Generator-473"><a href="#DuckDB.Generator-473"><span class="linenos">473</span></a> <span class="p">),</span> +</span><span id="DuckDB.Generator-474"><a href="#DuckDB.Generator-474"><span class="linenos">474</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PercentileCont</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"QUANTILE_CONT"</span><span class="p">),</span> +</span><span id="DuckDB.Generator-475"><a href="#DuckDB.Generator-475"><span class="linenos">475</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PercentileDisc</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"QUANTILE_DISC"</span><span class="p">),</span> +</span><span id="DuckDB.Generator-476"><a href="#DuckDB.Generator-476"><span class="linenos">476</span></a> <span class="c1"># DuckDB doesn't allow qualified columns inside of PIVOT expressions.</span> +</span><span id="DuckDB.Generator-477"><a href="#DuckDB.Generator-477"><span class="linenos">477</span></a> <span class="c1"># See: https://github.com/duckdb/duckdb/blob/671faf92411182f81dce42ac43de8bfb05d9909e/src/planner/binder/tableref/bind_pivot.cpp#L61-L62</span> +</span><span id="DuckDB.Generator-478"><a href="#DuckDB.Generator-478"><span class="linenos">478</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Pivot</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">([</span><span class="n">transforms</span><span class="o">.</span><span class="n">unqualify_columns</span><span class="p">]),</span> +</span><span id="DuckDB.Generator-479"><a href="#DuckDB.Generator-479"><span class="linenos">479</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpExtract</span><span class="p">:</span> <span class="n">regexp_extract_sql</span><span class="p">,</span> +</span><span id="DuckDB.Generator-480"><a href="#DuckDB.Generator-480"><span class="linenos">480</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpReplace</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> +</span><span id="DuckDB.Generator-481"><a href="#DuckDB.Generator-481"><span class="linenos">481</span></a> <span class="s2">"REGEXP_REPLACE"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-482"><a href="#DuckDB.Generator-482"><span class="linenos">482</span></a> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> +</span><span id="DuckDB.Generator-483"><a href="#DuckDB.Generator-483"><span class="linenos">483</span></a> <span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> +</span><span id="DuckDB.Generator-484"><a href="#DuckDB.Generator-484"><span class="linenos">484</span></a> <span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"replacement"</span><span class="p">),</span> +</span><span id="DuckDB.Generator-485"><a href="#DuckDB.Generator-485"><span class="linenos">485</span></a> <span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"modifiers"</span><span class="p">),</span> +</span><span id="DuckDB.Generator-486"><a href="#DuckDB.Generator-486"><span class="linenos">486</span></a> <span class="p">),</span> +</span><span id="DuckDB.Generator-487"><a href="#DuckDB.Generator-487"><span class="linenos">487</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpLike</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"REGEXP_MATCHES"</span><span class="p">),</span> +</span><span id="DuckDB.Generator-488"><a href="#DuckDB.Generator-488"><span class="linenos">488</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpSplit</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"STR_SPLIT_REGEX"</span><span class="p">),</span> +</span><span id="DuckDB.Generator-489"><a href="#DuckDB.Generator-489"><span class="linenos">489</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Return</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">),</span> +</span><span id="DuckDB.Generator-490"><a href="#DuckDB.Generator-490"><span class="linenos">490</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ReturnsProperty</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="s2">"TABLE"</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">e</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">Schema</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span><span class="p">,</span> +</span><span id="DuckDB.Generator-491"><a href="#DuckDB.Generator-491"><span class="linenos">491</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Rand</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"RANDOM"</span><span class="p">),</span> +</span><span id="DuckDB.Generator-492"><a href="#DuckDB.Generator-492"><span class="linenos">492</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SafeDivide</span><span class="p">:</span> <span class="n">no_safe_divide_sql</span><span class="p">,</span> +</span><span id="DuckDB.Generator-493"><a href="#DuckDB.Generator-493"><span class="linenos">493</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Split</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"STR_SPLIT"</span><span class="p">),</span> +</span><span id="DuckDB.Generator-494"><a href="#DuckDB.Generator-494"><span class="linenos">494</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SortArray</span><span class="p">:</span> <span class="n">_sort_array_sql</span><span class="p">,</span> +</span><span id="DuckDB.Generator-495"><a href="#DuckDB.Generator-495"><span class="linenos">495</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrPosition</span><span class="p">:</span> <span class="n">str_position_sql</span><span class="p">,</span> +</span><span id="DuckDB.Generator-496"><a href="#DuckDB.Generator-496"><span class="linenos">496</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToUnix</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> +</span><span id="DuckDB.Generator-497"><a href="#DuckDB.Generator-497"><span class="linenos">497</span></a> <span class="s2">"EPOCH"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"STRPTIME"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span><span class="n">e</span><span class="p">))</span> +</span><span id="DuckDB.Generator-498"><a href="#DuckDB.Generator-498"><span class="linenos">498</span></a> <span class="p">),</span> +</span><span id="DuckDB.Generator-499"><a href="#DuckDB.Generator-499"><span class="linenos">499</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Struct</span><span class="p">:</span> <span class="n">_struct_sql</span><span class="p">,</span> +</span><span id="DuckDB.Generator-500"><a href="#DuckDB.Generator-500"><span class="linenos">500</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeAdd</span><span class="p">:</span> <span class="n">_date_delta_sql</span><span class="p">,</span> +</span><span id="DuckDB.Generator-501"><a href="#DuckDB.Generator-501"><span class="linenos">501</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Time</span><span class="p">:</span> <span class="n">no_time_sql</span><span class="p">,</span> +</span><span id="DuckDB.Generator-502"><a href="#DuckDB.Generator-502"><span class="linenos">502</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Timestamp</span><span class="p">:</span> <span class="n">no_timestamp_sql</span><span class="p">,</span> +</span><span id="DuckDB.Generator-503"><a href="#DuckDB.Generator-503"><span class="linenos">503</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimestampDiff</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> +</span><span id="DuckDB.Generator-504"><a href="#DuckDB.Generator-504"><span class="linenos">504</span></a> <span class="s2">"DATE_DIFF"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">unit</span><span class="p">),</span> <span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span> </span><span id="DuckDB.Generator-505"><a href="#DuckDB.Generator-505"><span class="linenos">505</span></a> <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">TimeToStr</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"STRFTIME"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span><span class="n">e</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">TimeToUnix</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"EPOCH"</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">TsOrDiToDi</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</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">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"CAST(SUBSTR(REPLACE(CAST(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS TEXT), '-', ''), 1, 8) AS INT)"</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">TsOrDsAdd</span><span class="p">:</span> <span class="n">_date_delta_sql</span><span class="p">,</span> -</span><span id="DuckDB.Generator-511"><a href="#DuckDB.Generator-511"><span class="linenos">511</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsDiff</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="DuckDB.Generator-512"><a href="#DuckDB.Generator-512"><span class="linenos">512</span></a> <span class="s2">"DATE_DIFF"</span><span class="p">,</span> -</span><span id="DuckDB.Generator-513"><a href="#DuckDB.Generator-513"><span class="linenos">513</span></a> <span class="sa">f</span><span class="s2">"'</span><span class="si">{</span><span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'unit'</span><span class="p">)</span><span class="w"> </span><span class="ow">or</span><span class="w"> </span><span class="s1">'DAY'</span><span class="si">}</span><span class="s2">'"</span><span class="p">,</span> -</span><span id="DuckDB.Generator-514"><a href="#DuckDB.Generator-514"><span class="linenos">514</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMP</span><span class="p">),</span> -</span><span id="DuckDB.Generator-515"><a href="#DuckDB.Generator-515"><span class="linenos">515</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMP</span><span class="p">),</span> -</span><span id="DuckDB.Generator-516"><a href="#DuckDB.Generator-516"><span class="linenos">516</span></a> <span class="p">),</span> -</span><span id="DuckDB.Generator-517"><a href="#DuckDB.Generator-517"><span class="linenos">517</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToStr</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</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">"STRFTIME"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"TO_TIMESTAMP"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">),</span> <span class="bp">self</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span><span class="n">e</span><span class="p">)</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 class="n">exp</span><span class="o">.</span><span class="n">UnixToTime</span><span class="p">:</span> <span class="n">_unix_to_time_sql</span><span class="p">,</span> -</span><span id="DuckDB.Generator-521"><a href="#DuckDB.Generator-521"><span class="linenos">521</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToTimeStr</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"CAST(TO_TIMESTAMP(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">) AS TEXT)"</span><span class="p">,</span> -</span><span id="DuckDB.Generator-522"><a href="#DuckDB.Generator-522"><span class="linenos">522</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VariancePop</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"VAR_POP"</span><span class="p">),</span> -</span><span id="DuckDB.Generator-523"><a href="#DuckDB.Generator-523"><span class="linenos">523</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">WeekOfYear</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"WEEKOFYEAR"</span><span class="p">),</span> -</span><span id="DuckDB.Generator-524"><a href="#DuckDB.Generator-524"><span class="linenos">524</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Xor</span><span class="p">:</span> <span class="n">bool_xor_sql</span><span class="p">,</span> -</span><span id="DuckDB.Generator-525"><a href="#DuckDB.Generator-525"><span class="linenos">525</span></a> <span class="p">}</span> -</span><span id="DuckDB.Generator-526"><a href="#DuckDB.Generator-526"><span class="linenos">526</span></a> -</span><span id="DuckDB.Generator-527"><a href="#DuckDB.Generator-527"><span class="linenos">527</span></a> <span class="n">SUPPORTED_JSON_PATH_PARTS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="DuckDB.Generator-528"><a href="#DuckDB.Generator-528"><span class="linenos">528</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONPathKey</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">exp</span><span class="o">.</span><span class="n">JSONPathRoot</span><span class="p">,</span> -</span><span id="DuckDB.Generator-530"><a href="#DuckDB.Generator-530"><span class="linenos">530</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONPathSubscript</span><span class="p">,</span> -</span><span id="DuckDB.Generator-531"><a href="#DuckDB.Generator-531"><span class="linenos">531</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONPathWildcard</span><span class="p">,</span> -</span><span id="DuckDB.Generator-532"><a href="#DuckDB.Generator-532"><span class="linenos">532</span></a> <span class="p">}</span> -</span><span id="DuckDB.Generator-533"><a href="#DuckDB.Generator-533"><span class="linenos">533</span></a> -</span><span id="DuckDB.Generator-534"><a href="#DuckDB.Generator-534"><span class="linenos">534</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="DuckDB.Generator-535"><a href="#DuckDB.Generator-535"><span class="linenos">535</span></a> <span class="o">**</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">TYPE_MAPPING</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">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">BINARY</span><span class="p">:</span> <span class="s2">"BLOB"</span><span class="p">,</span> -</span><span id="DuckDB.Generator-537"><a href="#DuckDB.Generator-537"><span class="linenos">537</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">BPCHAR</span><span class="p">:</span> <span class="s2">"TEXT"</span><span class="p">,</span> -</span><span id="DuckDB.Generator-538"><a href="#DuckDB.Generator-538"><span class="linenos">538</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">CHAR</span><span class="p">:</span> <span class="s2">"TEXT"</span><span class="p">,</span> -</span><span id="DuckDB.Generator-539"><a href="#DuckDB.Generator-539"><span class="linenos">539</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">FLOAT</span><span class="p">:</span> <span class="s2">"REAL"</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">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">NCHAR</span><span class="p">:</span> <span class="s2">"TEXT"</span><span class="p">,</span> -</span><span id="DuckDB.Generator-541"><a href="#DuckDB.Generator-541"><span class="linenos">541</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">NVARCHAR</span><span class="p">:</span> <span class="s2">"TEXT"</span><span class="p">,</span> -</span><span id="DuckDB.Generator-542"><a href="#DuckDB.Generator-542"><span class="linenos">542</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">UINT</span><span class="p">:</span> <span class="s2">"UINTEGER"</span><span class="p">,</span> -</span><span id="DuckDB.Generator-543"><a href="#DuckDB.Generator-543"><span class="linenos">543</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-544"><a href="#DuckDB.Generator-544"><span class="linenos">544</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-545"><a href="#DuckDB.Generator-545"><span class="linenos">545</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-546"><a href="#DuckDB.Generator-546"><span class="linenos">546</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-547"><a href="#DuckDB.Generator-547"><span class="linenos">547</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-548"><a href="#DuckDB.Generator-548"><span class="linenos">548</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-549"><a href="#DuckDB.Generator-549"><span class="linenos">549</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-550"><a href="#DuckDB.Generator-550"><span class="linenos">550</span></a> <span class="p">}</span> -</span><span id="DuckDB.Generator-551"><a href="#DuckDB.Generator-551"><span class="linenos">551</span></a> -</span><span id="DuckDB.Generator-552"><a href="#DuckDB.Generator-552"><span class="linenos">552</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-553"><a href="#DuckDB.Generator-553"><span class="linenos">553</span></a> <span class="n">RESERVED_KEYWORDS</span> <span class="o">=</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">"array"</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">"analyse"</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">"union"</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">"all"</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">"when"</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">"in_p"</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">"default"</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">"create_p"</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">"window"</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">"asymmetric"</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">"to"</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">"else"</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">"localtime"</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">"from"</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">"end_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">"select"</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">"current_date"</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">"foreign"</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">"with"</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">"grant"</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">"session_user"</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">"or"</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">"except"</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">"references"</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">"fetch"</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">"limit"</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">"group_p"</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">"leading"</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">"into"</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">"collate"</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">"offset"</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">"do"</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">"then"</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">"localtimestamp"</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">"check_p"</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">"lateral_p"</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">"current_role"</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">"where"</span><span class="p">,</span> -</span><span id="DuckDB.Generator-592"><a href="#DuckDB.Generator-592"><span class="linenos">592</span></a> <span class="s2">"asc_p"</span><span class="p">,</span> -</span><span id="DuckDB.Generator-593"><a href="#DuckDB.Generator-593"><span class="linenos">593</span></a> <span class="s2">"placing"</span><span class="p">,</span> -</span><span id="DuckDB.Generator-594"><a href="#DuckDB.Generator-594"><span class="linenos">594</span></a> <span class="s2">"desc_p"</span><span class="p">,</span> -</span><span id="DuckDB.Generator-595"><a href="#DuckDB.Generator-595"><span class="linenos">595</span></a> <span class="s2">"user"</span><span class="p">,</span> -</span><span id="DuckDB.Generator-596"><a href="#DuckDB.Generator-596"><span class="linenos">596</span></a> <span class="s2">"unique"</span><span class="p">,</span> -</span><span id="DuckDB.Generator-597"><a href="#DuckDB.Generator-597"><span class="linenos">597</span></a> <span class="s2">"initially"</span><span class="p">,</span> -</span><span id="DuckDB.Generator-598"><a href="#DuckDB.Generator-598"><span class="linenos">598</span></a> <span class="s2">"column"</span><span class="p">,</span> -</span><span id="DuckDB.Generator-599"><a href="#DuckDB.Generator-599"><span class="linenos">599</span></a> <span class="s2">"both"</span><span class="p">,</span> -</span><span id="DuckDB.Generator-600"><a href="#DuckDB.Generator-600"><span class="linenos">600</span></a> <span class="s2">"some"</span><span class="p">,</span> -</span><span id="DuckDB.Generator-601"><a href="#DuckDB.Generator-601"><span class="linenos">601</span></a> <span class="s2">"as"</span><span class="p">,</span> -</span><span id="DuckDB.Generator-602"><a href="#DuckDB.Generator-602"><span class="linenos">602</span></a> <span class="s2">"any"</span><span class="p">,</span> -</span><span id="DuckDB.Generator-603"><a href="#DuckDB.Generator-603"><span class="linenos">603</span></a> <span class="s2">"only"</span><span class="p">,</span> -</span><span id="DuckDB.Generator-604"><a href="#DuckDB.Generator-604"><span class="linenos">604</span></a> <span class="s2">"deferrable"</span><span class="p">,</span> -</span><span id="DuckDB.Generator-605"><a href="#DuckDB.Generator-605"><span class="linenos">605</span></a> <span class="s2">"null_p"</span><span class="p">,</span> -</span><span id="DuckDB.Generator-606"><a href="#DuckDB.Generator-606"><span class="linenos">606</span></a> <span class="s2">"current_time"</span><span class="p">,</span> -</span><span id="DuckDB.Generator-607"><a href="#DuckDB.Generator-607"><span class="linenos">607</span></a> <span class="s2">"true_p"</span><span class="p">,</span> -</span><span id="DuckDB.Generator-608"><a href="#DuckDB.Generator-608"><span class="linenos">608</span></a> <span class="s2">"table"</span><span class="p">,</span> -</span><span id="DuckDB.Generator-609"><a href="#DuckDB.Generator-609"><span class="linenos">609</span></a> <span class="s2">"case"</span><span class="p">,</span> -</span><span id="DuckDB.Generator-610"><a href="#DuckDB.Generator-610"><span class="linenos">610</span></a> <span class="s2">"trailing"</span><span class="p">,</span> -</span><span id="DuckDB.Generator-611"><a href="#DuckDB.Generator-611"><span class="linenos">611</span></a> <span class="s2">"variadic"</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">"for"</span><span class="p">,</span> -</span><span id="DuckDB.Generator-613"><a href="#DuckDB.Generator-613"><span class="linenos">613</span></a> <span class="s2">"on"</span><span class="p">,</span> -</span><span id="DuckDB.Generator-614"><a href="#DuckDB.Generator-614"><span class="linenos">614</span></a> <span class="s2">"distinct"</span><span class="p">,</span> -</span><span id="DuckDB.Generator-615"><a href="#DuckDB.Generator-615"><span class="linenos">615</span></a> <span class="s2">"false_p"</span><span class="p">,</span> -</span><span id="DuckDB.Generator-616"><a href="#DuckDB.Generator-616"><span class="linenos">616</span></a> <span class="s2">"not"</span><span class="p">,</span> -</span><span id="DuckDB.Generator-617"><a href="#DuckDB.Generator-617"><span class="linenos">617</span></a> <span class="s2">"constraint"</span><span class="p">,</span> -</span><span id="DuckDB.Generator-618"><a href="#DuckDB.Generator-618"><span class="linenos">618</span></a> <span class="s2">"current_timestamp"</span><span class="p">,</span> -</span><span id="DuckDB.Generator-619"><a href="#DuckDB.Generator-619"><span class="linenos">619</span></a> <span class="s2">"returning"</span><span class="p">,</span> -</span><span id="DuckDB.Generator-620"><a href="#DuckDB.Generator-620"><span class="linenos">620</span></a> <span class="s2">"primary"</span><span class="p">,</span> -</span><span id="DuckDB.Generator-621"><a href="#DuckDB.Generator-621"><span class="linenos">621</span></a> <span class="s2">"intersect"</span><span class="p">,</span> -</span><span id="DuckDB.Generator-622"><a href="#DuckDB.Generator-622"><span class="linenos">622</span></a> <span class="s2">"having"</span><span class="p">,</span> -</span><span id="DuckDB.Generator-623"><a href="#DuckDB.Generator-623"><span class="linenos">623</span></a> <span class="s2">"analyze"</span><span class="p">,</span> -</span><span id="DuckDB.Generator-624"><a href="#DuckDB.Generator-624"><span class="linenos">624</span></a> <span class="s2">"current_user"</span><span class="p">,</span> -</span><span id="DuckDB.Generator-625"><a href="#DuckDB.Generator-625"><span class="linenos">625</span></a> <span class="s2">"and"</span><span class="p">,</span> -</span><span id="DuckDB.Generator-626"><a href="#DuckDB.Generator-626"><span class="linenos">626</span></a> <span class="s2">"cast"</span><span class="p">,</span> -</span><span id="DuckDB.Generator-627"><a href="#DuckDB.Generator-627"><span class="linenos">627</span></a> <span class="s2">"symmetric"</span><span class="p">,</span> -</span><span id="DuckDB.Generator-628"><a href="#DuckDB.Generator-628"><span class="linenos">628</span></a> <span class="s2">"using"</span><span class="p">,</span> -</span><span id="DuckDB.Generator-629"><a href="#DuckDB.Generator-629"><span class="linenos">629</span></a> <span class="s2">"order"</span><span class="p">,</span> -</span><span id="DuckDB.Generator-630"><a href="#DuckDB.Generator-630"><span class="linenos">630</span></a> <span class="s2">"current_catalog"</span><span class="p">,</span> -</span><span id="DuckDB.Generator-631"><a href="#DuckDB.Generator-631"><span class="linenos">631</span></a> <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="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-634"><a href="#DuckDB.Generator-634"><span class="linenos">634</span></a> -</span><span id="DuckDB.Generator-635"><a href="#DuckDB.Generator-635"><span class="linenos">635</span></a> <span class="c1"># DuckDB doesn't generally support CREATE TABLE .. properties</span> -</span><span id="DuckDB.Generator-636"><a href="#DuckDB.Generator-636"><span class="linenos">636</span></a> <span class="c1"># https://duckdb.org/docs/sql/statements/create_table.html</span> -</span><span id="DuckDB.Generator-637"><a href="#DuckDB.Generator-637"><span class="linenos">637</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="DuckDB.Generator-638"><a href="#DuckDB.Generator-638"><span class="linenos">638</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-639"><a href="#DuckDB.Generator-639"><span class="linenos">639</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-640"><a href="#DuckDB.Generator-640"><span class="linenos">640</span></a> <span class="p">}</span> -</span><span id="DuckDB.Generator-641"><a href="#DuckDB.Generator-641"><span class="linenos">641</span></a> -</span><span id="DuckDB.Generator-642"><a href="#DuckDB.Generator-642"><span class="linenos">642</span></a> <span class="c1"># There are a few exceptions (e.g. temporary tables) which are supported or</span> -</span><span id="DuckDB.Generator-643"><a href="#DuckDB.Generator-643"><span class="linenos">643</span></a> <span class="c1"># can be transpiled to DuckDB, so we explicitly override them accordingly</span> -</span><span id="DuckDB.Generator-644"><a href="#DuckDB.Generator-644"><span class="linenos">644</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-645"><a href="#DuckDB.Generator-645"><span class="linenos">645</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-646"><a href="#DuckDB.Generator-646"><span class="linenos">646</span></a> <span class="n">PROPERTIES_LOCATION</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">ReturnsProperty</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_ALIAS</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">TimestampTrunc</span><span class="p">:</span> <span class="n">timestamptrunc_sql</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">TimeStrToDate</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">e</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">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">DATE</span><span class="p">)),</span> +</span><span id="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">TimeStrToTime</span><span class="p">:</span> <span class="n">timestrtotime_sql</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">TimeStrToUnix</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> +</span><span id="DuckDB.Generator-510"><a href="#DuckDB.Generator-510"><span class="linenos">510</span></a> <span class="s2">"EPOCH"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMP</span><span class="p">)</span> +</span><span id="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 class="n">exp</span><span class="o">.</span><span class="n">TimeToStr</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"STRFTIME"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span><span class="n">e</span><span class="p">)),</span> +</span><span id="DuckDB.Generator-513"><a href="#DuckDB.Generator-513"><span class="linenos">513</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeToUnix</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"EPOCH"</span><span class="p">),</span> +</span><span id="DuckDB.Generator-514"><a href="#DuckDB.Generator-514"><span class="linenos">514</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDiToDi</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> +</span><span id="DuckDB.Generator-515"><a href="#DuckDB.Generator-515"><span class="linenos">515</span></a> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"CAST(SUBSTR(REPLACE(CAST(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS TEXT), '-', ''), 1, 8) AS INT)"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-516"><a href="#DuckDB.Generator-516"><span class="linenos">516</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsAdd</span><span class="p">:</span> <span class="n">_date_delta_sql</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">exp</span><span class="o">.</span><span class="n">TsOrDsDiff</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</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">"DATE_DIFF"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-519"><a href="#DuckDB.Generator-519"><span class="linenos">519</span></a> <span class="sa">f</span><span class="s2">"'</span><span class="si">{</span><span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'unit'</span><span class="p">)</span><span class="w"> </span><span class="ow">or</span><span class="w"> </span><span class="s1">'DAY'</span><span class="si">}</span><span class="s2">'"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-520"><a href="#DuckDB.Generator-520"><span class="linenos">520</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMP</span><span class="p">),</span> +</span><span id="DuckDB.Generator-521"><a href="#DuckDB.Generator-521"><span class="linenos">521</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMP</span><span class="p">),</span> +</span><span id="DuckDB.Generator-522"><a href="#DuckDB.Generator-522"><span class="linenos">522</span></a> <span class="p">),</span> +</span><span id="DuckDB.Generator-523"><a href="#DuckDB.Generator-523"><span class="linenos">523</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToStr</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</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">"STRFTIME"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"TO_TIMESTAMP"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">),</span> <span class="bp">self</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> +</span><span id="DuckDB.Generator-525"><a href="#DuckDB.Generator-525"><span class="linenos">525</span></a> <span class="p">),</span> +</span><span id="DuckDB.Generator-526"><a href="#DuckDB.Generator-526"><span class="linenos">526</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToTime</span><span class="p">:</span> <span class="n">_unix_to_time_sql</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">exp</span><span class="o">.</span><span class="n">UnixToTimeStr</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"CAST(TO_TIMESTAMP(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">) AS TEXT)"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-528"><a href="#DuckDB.Generator-528"><span class="linenos">528</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VariancePop</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"VAR_POP"</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">exp</span><span class="o">.</span><span class="n">WeekOfYear</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"WEEKOFYEAR"</span><span class="p">),</span> +</span><span id="DuckDB.Generator-530"><a href="#DuckDB.Generator-530"><span class="linenos">530</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Xor</span><span class="p">:</span> <span class="n">bool_xor_sql</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="n">SUPPORTED_JSON_PATH_PARTS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="DuckDB.Generator-534"><a href="#DuckDB.Generator-534"><span class="linenos">534</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONPathKey</span><span class="p">,</span> +</span><span id="DuckDB.Generator-535"><a href="#DuckDB.Generator-535"><span class="linenos">535</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONPathRoot</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">exp</span><span class="o">.</span><span class="n">JSONPathSubscript</span><span class="p">,</span> +</span><span id="DuckDB.Generator-537"><a href="#DuckDB.Generator-537"><span class="linenos">537</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONPathWildcard</span><span class="p">,</span> +</span><span id="DuckDB.Generator-538"><a href="#DuckDB.Generator-538"><span class="linenos">538</span></a> <span class="p">}</span> +</span><span id="DuckDB.Generator-539"><a href="#DuckDB.Generator-539"><span class="linenos">539</span></a> +</span><span id="DuckDB.Generator-540"><a href="#DuckDB.Generator-540"><span class="linenos">540</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="DuckDB.Generator-541"><a href="#DuckDB.Generator-541"><span class="linenos">541</span></a> <span class="o">**</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">TYPE_MAPPING</span><span class="p">,</span> +</span><span id="DuckDB.Generator-542"><a href="#DuckDB.Generator-542"><span class="linenos">542</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">BINARY</span><span class="p">:</span> <span class="s2">"BLOB"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-543"><a href="#DuckDB.Generator-543"><span class="linenos">543</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">BPCHAR</span><span class="p">:</span> <span class="s2">"TEXT"</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">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">CHAR</span><span class="p">:</span> <span class="s2">"TEXT"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-545"><a href="#DuckDB.Generator-545"><span class="linenos">545</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">FLOAT</span><span class="p">:</span> <span class="s2">"REAL"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-546"><a href="#DuckDB.Generator-546"><span class="linenos">546</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">NCHAR</span><span class="p">:</span> <span class="s2">"TEXT"</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">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">NVARCHAR</span><span class="p">:</span> <span class="s2">"TEXT"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-548"><a href="#DuckDB.Generator-548"><span class="linenos">548</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">UINT</span><span class="p">:</span> <span class="s2">"UINTEGER"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-549"><a href="#DuckDB.Generator-549"><span class="linenos">549</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-550"><a href="#DuckDB.Generator-550"><span class="linenos">550</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-551"><a href="#DuckDB.Generator-551"><span class="linenos">551</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-552"><a href="#DuckDB.Generator-552"><span class="linenos">552</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-553"><a href="#DuckDB.Generator-553"><span class="linenos">553</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-554"><a href="#DuckDB.Generator-554"><span class="linenos">554</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-555"><a href="#DuckDB.Generator-555"><span class="linenos">555</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-556"><a href="#DuckDB.Generator-556"><span class="linenos">556</span></a> <span class="p">}</span> +</span><span id="DuckDB.Generator-557"><a href="#DuckDB.Generator-557"><span class="linenos">557</span></a> +</span><span id="DuckDB.Generator-558"><a href="#DuckDB.Generator-558"><span class="linenos">558</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-559"><a href="#DuckDB.Generator-559"><span class="linenos">559</span></a> <span class="n">RESERVED_KEYWORDS</span> <span class="o">=</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">"array"</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">"analyse"</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">"union"</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">"all"</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">"when"</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">"in_p"</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">"default"</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">"create_p"</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">"window"</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">"asymmetric"</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">"to"</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">"else"</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">"localtime"</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">"from"</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">"end_p"</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">"select"</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">"current_date"</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">"foreign"</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">"with"</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">"grant"</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">"session_user"</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">"or"</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">"except"</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">"references"</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">"fetch"</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">"limit"</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">"group_p"</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">"leading"</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">"into"</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">"collate"</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">"offset"</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">"do"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-592"><a href="#DuckDB.Generator-592"><span class="linenos">592</span></a> <span class="s2">"then"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-593"><a href="#DuckDB.Generator-593"><span class="linenos">593</span></a> <span class="s2">"localtimestamp"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-594"><a href="#DuckDB.Generator-594"><span class="linenos">594</span></a> <span class="s2">"check_p"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-595"><a href="#DuckDB.Generator-595"><span class="linenos">595</span></a> <span class="s2">"lateral_p"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-596"><a href="#DuckDB.Generator-596"><span class="linenos">596</span></a> <span class="s2">"current_role"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-597"><a href="#DuckDB.Generator-597"><span class="linenos">597</span></a> <span class="s2">"where"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-598"><a href="#DuckDB.Generator-598"><span class="linenos">598</span></a> <span class="s2">"asc_p"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-599"><a href="#DuckDB.Generator-599"><span class="linenos">599</span></a> <span class="s2">"placing"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-600"><a href="#DuckDB.Generator-600"><span class="linenos">600</span></a> <span class="s2">"desc_p"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-601"><a href="#DuckDB.Generator-601"><span class="linenos">601</span></a> <span class="s2">"user"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-602"><a href="#DuckDB.Generator-602"><span class="linenos">602</span></a> <span class="s2">"unique"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-603"><a href="#DuckDB.Generator-603"><span class="linenos">603</span></a> <span class="s2">"initially"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-604"><a href="#DuckDB.Generator-604"><span class="linenos">604</span></a> <span class="s2">"column"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-605"><a href="#DuckDB.Generator-605"><span class="linenos">605</span></a> <span class="s2">"both"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-606"><a href="#DuckDB.Generator-606"><span class="linenos">606</span></a> <span class="s2">"some"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-607"><a href="#DuckDB.Generator-607"><span class="linenos">607</span></a> <span class="s2">"as"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-608"><a href="#DuckDB.Generator-608"><span class="linenos">608</span></a> <span class="s2">"any"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-609"><a href="#DuckDB.Generator-609"><span class="linenos">609</span></a> <span class="s2">"only"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-610"><a href="#DuckDB.Generator-610"><span class="linenos">610</span></a> <span class="s2">"deferrable"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-611"><a href="#DuckDB.Generator-611"><span class="linenos">611</span></a> <span class="s2">"null_p"</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">"current_time"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-613"><a href="#DuckDB.Generator-613"><span class="linenos">613</span></a> <span class="s2">"true_p"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-614"><a href="#DuckDB.Generator-614"><span class="linenos">614</span></a> <span class="s2">"table"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-615"><a href="#DuckDB.Generator-615"><span class="linenos">615</span></a> <span class="s2">"case"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-616"><a href="#DuckDB.Generator-616"><span class="linenos">616</span></a> <span class="s2">"trailing"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-617"><a href="#DuckDB.Generator-617"><span class="linenos">617</span></a> <span class="s2">"variadic"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-618"><a href="#DuckDB.Generator-618"><span class="linenos">618</span></a> <span class="s2">"for"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-619"><a href="#DuckDB.Generator-619"><span class="linenos">619</span></a> <span class="s2">"on"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-620"><a href="#DuckDB.Generator-620"><span class="linenos">620</span></a> <span class="s2">"distinct"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-621"><a href="#DuckDB.Generator-621"><span class="linenos">621</span></a> <span class="s2">"false_p"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-622"><a href="#DuckDB.Generator-622"><span class="linenos">622</span></a> <span class="s2">"not"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-623"><a href="#DuckDB.Generator-623"><span class="linenos">623</span></a> <span class="s2">"constraint"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-624"><a href="#DuckDB.Generator-624"><span class="linenos">624</span></a> <span class="s2">"current_timestamp"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-625"><a href="#DuckDB.Generator-625"><span class="linenos">625</span></a> <span class="s2">"returning"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-626"><a href="#DuckDB.Generator-626"><span class="linenos">626</span></a> <span class="s2">"primary"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-627"><a href="#DuckDB.Generator-627"><span class="linenos">627</span></a> <span class="s2">"intersect"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-628"><a href="#DuckDB.Generator-628"><span class="linenos">628</span></a> <span class="s2">"having"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-629"><a href="#DuckDB.Generator-629"><span class="linenos">629</span></a> <span class="s2">"analyze"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-630"><a href="#DuckDB.Generator-630"><span class="linenos">630</span></a> <span class="s2">"current_user"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-631"><a href="#DuckDB.Generator-631"><span class="linenos">631</span></a> <span class="s2">"and"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-632"><a href="#DuckDB.Generator-632"><span class="linenos">632</span></a> <span class="s2">"cast"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-633"><a href="#DuckDB.Generator-633"><span class="linenos">633</span></a> <span class="s2">"symmetric"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-634"><a href="#DuckDB.Generator-634"><span class="linenos">634</span></a> <span class="s2">"using"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-635"><a href="#DuckDB.Generator-635"><span class="linenos">635</span></a> <span class="s2">"order"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-636"><a href="#DuckDB.Generator-636"><span class="linenos">636</span></a> <span class="s2">"current_catalog"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-637"><a href="#DuckDB.Generator-637"><span class="linenos">637</span></a> <span class="p">}</span> +</span><span id="DuckDB.Generator-638"><a href="#DuckDB.Generator-638"><span class="linenos">638</span></a> +</span><span id="DuckDB.Generator-639"><a href="#DuckDB.Generator-639"><span class="linenos">639</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-640"><a href="#DuckDB.Generator-640"><span class="linenos">640</span></a> +</span><span id="DuckDB.Generator-641"><a href="#DuckDB.Generator-641"><span class="linenos">641</span></a> <span class="c1"># DuckDB doesn't generally support CREATE TABLE .. properties</span> +</span><span id="DuckDB.Generator-642"><a href="#DuckDB.Generator-642"><span class="linenos">642</span></a> <span class="c1"># https://duckdb.org/docs/sql/statements/create_table.html</span> +</span><span id="DuckDB.Generator-643"><a href="#DuckDB.Generator-643"><span class="linenos">643</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</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">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-645"><a href="#DuckDB.Generator-645"><span class="linenos">645</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-646"><a href="#DuckDB.Generator-646"><span class="linenos">646</span></a> <span class="p">}</span> </span><span id="DuckDB.Generator-647"><a href="#DuckDB.Generator-647"><span class="linenos">647</span></a> -</span><span id="DuckDB.Generator-648"><a href="#DuckDB.Generator-648"><span class="linenos">648</span></a> <span class="k">def</span> <span class="nf">strtotime_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">StrToTime</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="DuckDB.Generator-649"><a href="#DuckDB.Generator-649"><span class="linenos">649</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">"safe"</span><span class="p">):</span> -</span><span id="DuckDB.Generator-650"><a href="#DuckDB.Generator-650"><span class="linenos">650</span></a> <span class="n">formatted_time</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="DuckDB.Generator-651"><a href="#DuckDB.Generator-651"><span class="linenos">651</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CAST(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s1">'TRY_STRPTIME'</span><span class="p">,</span><span class="w"> </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">formatted_time</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS TIMESTAMP)"</span> -</span><span id="DuckDB.Generator-652"><a href="#DuckDB.Generator-652"><span class="linenos">652</span></a> <span class="k">return</span> <span class="n">str_to_time_sql</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-648"><a href="#DuckDB.Generator-648"><span class="linenos">648</span></a> <span class="c1"># There are a few exceptions (e.g. temporary tables) which are supported or</span> +</span><span id="DuckDB.Generator-649"><a href="#DuckDB.Generator-649"><span class="linenos">649</span></a> <span class="c1"># can be transpiled to DuckDB, so we explicitly override them accordingly</span> +</span><span id="DuckDB.Generator-650"><a href="#DuckDB.Generator-650"><span class="linenos">650</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-651"><a href="#DuckDB.Generator-651"><span class="linenos">651</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-652"><a href="#DuckDB.Generator-652"><span class="linenos">652</span></a> <span class="n">PROPERTIES_LOCATION</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">ReturnsProperty</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_ALIAS</span> </span><span id="DuckDB.Generator-653"><a href="#DuckDB.Generator-653"><span class="linenos">653</span></a> -</span><span id="DuckDB.Generator-654"><a href="#DuckDB.Generator-654"><span class="linenos">654</span></a> <span class="k">def</span> <span class="nf">strtodate_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">StrToDate</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="DuckDB.Generator-654"><a href="#DuckDB.Generator-654"><span class="linenos">654</span></a> <span class="k">def</span> <span class="nf">strtotime_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">StrToTime</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> </span><span id="DuckDB.Generator-655"><a href="#DuckDB.Generator-655"><span class="linenos">655</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">"safe"</span><span class="p">):</span> </span><span id="DuckDB.Generator-656"><a href="#DuckDB.Generator-656"><span class="linenos">656</span></a> <span class="n">formatted_time</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="DuckDB.Generator-657"><a href="#DuckDB.Generator-657"><span class="linenos">657</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CAST(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s1">'TRY_STRPTIME'</span><span class="p">,</span><span class="w"> </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">formatted_time</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS DATE)"</span> -</span><span id="DuckDB.Generator-658"><a href="#DuckDB.Generator-658"><span class="linenos">658</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CAST(</span><span class="si">{</span><span class="n">str_to_time_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="w"> </span><span class="n">expression</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS DATE)"</span> +</span><span id="DuckDB.Generator-657"><a href="#DuckDB.Generator-657"><span class="linenos">657</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CAST(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s1">'TRY_STRPTIME'</span><span class="p">,</span><span class="w"> </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">formatted_time</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS TIMESTAMP)"</span> +</span><span id="DuckDB.Generator-658"><a href="#DuckDB.Generator-658"><span class="linenos">658</span></a> <span class="k">return</span> <span class="n">str_to_time_sql</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-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">def</span> <span class="nf">parsejson_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ParseJSON</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</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">arg</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</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">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"safe"</span><span class="p">):</span> -</span><span id="DuckDB.Generator-663"><a href="#DuckDB.Generator-663"><span class="linenos">663</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">case</span><span class="p">()</span><span class="o">.</span><span class="n">when</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"json_valid"</span><span class="p">,</span> <span class="n">arg</span><span class="p">),</span> <span class="n">arg</span><span class="p">)</span><span class="o">.</span><span class="n">else_</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">null</span><span class="p">()))</span> -</span><span id="DuckDB.Generator-664"><a href="#DuckDB.Generator-664"><span class="linenos">664</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"JSON"</span><span class="p">,</span> <span class="n">arg</span><span class="p">)</span> +</span><span id="DuckDB.Generator-660"><a href="#DuckDB.Generator-660"><span class="linenos">660</span></a> <span class="k">def</span> <span class="nf">strtodate_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">StrToDate</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="DuckDB.Generator-661"><a href="#DuckDB.Generator-661"><span class="linenos">661</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">"safe"</span><span class="p">):</span> +</span><span id="DuckDB.Generator-662"><a href="#DuckDB.Generator-662"><span class="linenos">662</span></a> <span class="n">formatted_time</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="DuckDB.Generator-663"><a href="#DuckDB.Generator-663"><span class="linenos">663</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CAST(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s1">'TRY_STRPTIME'</span><span class="p">,</span><span class="w"> </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">formatted_time</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS DATE)"</span> +</span><span id="DuckDB.Generator-664"><a href="#DuckDB.Generator-664"><span class="linenos">664</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CAST(</span><span class="si">{</span><span class="n">str_to_time_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="w"> </span><span class="n">expression</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS DATE)"</span> </span><span id="DuckDB.Generator-665"><a href="#DuckDB.Generator-665"><span class="linenos">665</span></a> -</span><span id="DuckDB.Generator-666"><a href="#DuckDB.Generator-666"><span class="linenos">666</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-667"><a href="#DuckDB.Generator-667"><span class="linenos">667</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-668"><a href="#DuckDB.Generator-668"><span class="linenos">668</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-669"><a href="#DuckDB.Generator-669"><span class="linenos">669</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-670"><a href="#DuckDB.Generator-670"><span class="linenos">670</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-671"><a href="#DuckDB.Generator-671"><span class="linenos">671</span></a> <span class="p">)</span> -</span><span id="DuckDB.Generator-672"><a href="#DuckDB.Generator-672"><span class="linenos">672</span></a> -</span><span id="DuckDB.Generator-673"><a href="#DuckDB.Generator-673"><span class="linenos">673</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-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">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-676"><a href="#DuckDB.Generator-676"><span class="linenos">676</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-677"><a href="#DuckDB.Generator-677"><span class="linenos">677</span></a> -</span><span id="DuckDB.Generator-678"><a href="#DuckDB.Generator-678"><span class="linenos">678</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-679"><a href="#DuckDB.Generator-679"><span class="linenos">679</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-680"><a href="#DuckDB.Generator-680"><span class="linenos">680</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-681"><a href="#DuckDB.Generator-681"><span class="linenos">681</span></a> -</span><span id="DuckDB.Generator-682"><a href="#DuckDB.Generator-682"><span class="linenos">682</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-683"><a href="#DuckDB.Generator-683"><span class="linenos">683</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-684"><a href="#DuckDB.Generator-684"><span class="linenos">684</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-685"><a href="#DuckDB.Generator-685"><span class="linenos">685</span></a> -</span><span id="DuckDB.Generator-686"><a href="#DuckDB.Generator-686"><span class="linenos">686</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-687"><a href="#DuckDB.Generator-687"><span class="linenos">687</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-688"><a href="#DuckDB.Generator-688"><span class="linenos">688</span></a> -</span><span id="DuckDB.Generator-689"><a href="#DuckDB.Generator-689"><span class="linenos">689</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-690"><a href="#DuckDB.Generator-690"><span class="linenos">690</span></a> -</span><span id="DuckDB.Generator-691"><a href="#DuckDB.Generator-691"><span class="linenos">691</span></a> <span class="k">def</span> <span class="nf">tablesample_sql</span><span class="p">(</span> -</span><span id="DuckDB.Generator-692"><a href="#DuckDB.Generator-692"><span class="linenos">692</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="DuckDB.Generator-693"><a href="#DuckDB.Generator-693"><span class="linenos">693</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-694"><a href="#DuckDB.Generator-694"><span class="linenos">694</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-695"><a href="#DuckDB.Generator-695"><span class="linenos">695</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-696"><a href="#DuckDB.Generator-696"><span class="linenos">696</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</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="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-698"><a href="#DuckDB.Generator-698"><span class="linenos">698</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-699"><a href="#DuckDB.Generator-699"><span class="linenos">699</span></a> <span class="n">tablesample_keyword</span> <span class="o">=</span> <span class="s2">"TABLESAMPLE"</span> -</span><span id="DuckDB.Generator-700"><a href="#DuckDB.Generator-700"><span class="linenos">700</span></a> -</span><span id="DuckDB.Generator-701"><a href="#DuckDB.Generator-701"><span class="linenos">701</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-702"><a href="#DuckDB.Generator-702"><span class="linenos">702</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-703"><a href="#DuckDB.Generator-703"><span class="linenos">703</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-704"><a href="#DuckDB.Generator-704"><span class="linenos">704</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-705"><a href="#DuckDB.Generator-705"><span class="linenos">705</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-706"><a href="#DuckDB.Generator-706"><span class="linenos">706</span></a> <span class="s2">"defaulting to reservoir sampling"</span> -</span><span id="DuckDB.Generator-707"><a href="#DuckDB.Generator-707"><span class="linenos">707</span></a> <span class="p">)</span> -</span><span id="DuckDB.Generator-708"><a href="#DuckDB.Generator-708"><span class="linenos">708</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-709"><a href="#DuckDB.Generator-709"><span class="linenos">709</span></a> -</span><span id="DuckDB.Generator-710"><a href="#DuckDB.Generator-710"><span class="linenos">710</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-711"><a href="#DuckDB.Generator-711"><span class="linenos">711</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-712"><a href="#DuckDB.Generator-712"><span class="linenos">712</span></a> <span class="p">)</span> -</span><span id="DuckDB.Generator-713"><a href="#DuckDB.Generator-713"><span class="linenos">713</span></a> -</span><span id="DuckDB.Generator-714"><a href="#DuckDB.Generator-714"><span class="linenos">714</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-715"><a href="#DuckDB.Generator-715"><span class="linenos">715</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-716"><a href="#DuckDB.Generator-716"><span class="linenos">716</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-717"><a href="#DuckDB.Generator-717"><span class="linenos">717</span></a> -</span><span id="DuckDB.Generator-718"><a href="#DuckDB.Generator-718"><span class="linenos">718</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-719"><a href="#DuckDB.Generator-719"><span class="linenos">719</span></a> <span class="n">multiplier</span> <span class="o">=</span> <span class="mi">7</span> -</span><span id="DuckDB.Generator-720"><a href="#DuckDB.Generator-720"><span class="linenos">720</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-721"><a href="#DuckDB.Generator-721"><span class="linenos">721</span></a> <span class="n">multiplier</span> <span class="o">=</span> <span class="mi">90</span> -</span><span id="DuckDB.Generator-722"><a href="#DuckDB.Generator-722"><span class="linenos">722</span></a> -</span><span id="DuckDB.Generator-723"><a href="#DuckDB.Generator-723"><span class="linenos">723</span></a> <span class="k">if</span> <span class="n">multiplier</span><span class="p">:</span> -</span><span id="DuckDB.Generator-724"><a href="#DuckDB.Generator-724"><span class="linenos">724</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-725"><a href="#DuckDB.Generator-725"><span class="linenos">725</span></a> -</span><span id="DuckDB.Generator-726"><a href="#DuckDB.Generator-726"><span class="linenos">726</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-727"><a href="#DuckDB.Generator-727"><span class="linenos">727</span></a> -</span><span id="DuckDB.Generator-728"><a href="#DuckDB.Generator-728"><span class="linenos">728</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-729"><a href="#DuckDB.Generator-729"><span class="linenos">729</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-730"><a href="#DuckDB.Generator-730"><span class="linenos">730</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-731"><a href="#DuckDB.Generator-731"><span class="linenos">731</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-732"><a href="#DuckDB.Generator-732"><span class="linenos">732</span></a> -</span><span id="DuckDB.Generator-733"><a href="#DuckDB.Generator-733"><span class="linenos">733</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-734"><a href="#DuckDB.Generator-734"><span class="linenos">734</span></a> <span class="k">if</span> <span class="p">(</span> -</span><span id="DuckDB.Generator-735"><a href="#DuckDB.Generator-735"><span class="linenos">735</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-736"><a href="#DuckDB.Generator-736"><span class="linenos">736</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-737"><a href="#DuckDB.Generator-737"><span class="linenos">737</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-738"><a href="#DuckDB.Generator-738"><span class="linenos">738</span></a> <span class="p">):</span> -</span><span id="DuckDB.Generator-739"><a href="#DuckDB.Generator-739"><span class="linenos">739</span></a> <span class="c1"># Some dialects support `LEFT JOIN UNNEST(...)` without an explicit ON clause</span> -</span><span id="DuckDB.Generator-740"><a href="#DuckDB.Generator-740"><span class="linenos">740</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-741"><a href="#DuckDB.Generator-741"><span class="linenos">741</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-742"><a href="#DuckDB.Generator-742"><span class="linenos">742</span></a> -</span><span id="DuckDB.Generator-743"><a href="#DuckDB.Generator-743"><span class="linenos">743</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-744"><a href="#DuckDB.Generator-744"><span class="linenos">744</span></a> -</span><span id="DuckDB.Generator-745"><a href="#DuckDB.Generator-745"><span class="linenos">745</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-746"><a href="#DuckDB.Generator-746"><span class="linenos">746</span></a> <span class="c1"># GENERATE_SERIES(a, b) -> [a, b], RANGE(a, b) -> [a, b)</span> -</span><span id="DuckDB.Generator-747"><a href="#DuckDB.Generator-747"><span class="linenos">747</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-748"><a href="#DuckDB.Generator-748"><span class="linenos">748</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-749"><a href="#DuckDB.Generator-749"><span class="linenos">749</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-666"><a href="#DuckDB.Generator-666"><span class="linenos">666</span></a> <span class="k">def</span> <span class="nf">parsejson_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ParseJSON</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="DuckDB.Generator-667"><a href="#DuckDB.Generator-667"><span class="linenos">667</span></a> <span class="n">arg</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> +</span><span id="DuckDB.Generator-668"><a href="#DuckDB.Generator-668"><span class="linenos">668</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">"safe"</span><span class="p">):</span> +</span><span id="DuckDB.Generator-669"><a href="#DuckDB.Generator-669"><span class="linenos">669</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">case</span><span class="p">()</span><span class="o">.</span><span class="n">when</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"json_valid"</span><span class="p">,</span> <span class="n">arg</span><span class="p">),</span> <span class="n">arg</span><span class="p">)</span><span class="o">.</span><span class="n">else_</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">null</span><span class="p">()))</span> +</span><span id="DuckDB.Generator-670"><a href="#DuckDB.Generator-670"><span class="linenos">670</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"JSON"</span><span class="p">,</span> <span class="n">arg</span><span class="p">)</span> +</span><span id="DuckDB.Generator-671"><a href="#DuckDB.Generator-671"><span class="linenos">671</span></a> +</span><span id="DuckDB.Generator-672"><a href="#DuckDB.Generator-672"><span class="linenos">672</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-673"><a href="#DuckDB.Generator-673"><span class="linenos">673</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-674"><a href="#DuckDB.Generator-674"><span class="linenos">674</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-675"><a href="#DuckDB.Generator-675"><span class="linenos">675</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-676"><a href="#DuckDB.Generator-676"><span class="linenos">676</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-677"><a href="#DuckDB.Generator-677"><span class="linenos">677</span></a> <span class="p">)</span> +</span><span id="DuckDB.Generator-678"><a href="#DuckDB.Generator-678"><span class="linenos">678</span></a> +</span><span id="DuckDB.Generator-679"><a href="#DuckDB.Generator-679"><span class="linenos">679</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-680"><a href="#DuckDB.Generator-680"><span class="linenos">680</span></a> +</span><span id="DuckDB.Generator-681"><a href="#DuckDB.Generator-681"><span class="linenos">681</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-682"><a href="#DuckDB.Generator-682"><span class="linenos">682</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-683"><a href="#DuckDB.Generator-683"><span class="linenos">683</span></a> +</span><span id="DuckDB.Generator-684"><a href="#DuckDB.Generator-684"><span class="linenos">684</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-685"><a href="#DuckDB.Generator-685"><span class="linenos">685</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-686"><a href="#DuckDB.Generator-686"><span class="linenos">686</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-687"><a href="#DuckDB.Generator-687"><span class="linenos">687</span></a> +</span><span id="DuckDB.Generator-688"><a href="#DuckDB.Generator-688"><span class="linenos">688</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-689"><a href="#DuckDB.Generator-689"><span class="linenos">689</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-690"><a href="#DuckDB.Generator-690"><span class="linenos">690</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-691"><a href="#DuckDB.Generator-691"><span class="linenos">691</span></a> +</span><span id="DuckDB.Generator-692"><a href="#DuckDB.Generator-692"><span class="linenos">692</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-693"><a href="#DuckDB.Generator-693"><span class="linenos">693</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-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">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-696"><a href="#DuckDB.Generator-696"><span class="linenos">696</span></a> +</span><span id="DuckDB.Generator-697"><a href="#DuckDB.Generator-697"><span class="linenos">697</span></a> <span class="k">def</span> <span class="nf">tablesample_sql</span><span class="p">(</span> +</span><span id="DuckDB.Generator-698"><a href="#DuckDB.Generator-698"><span class="linenos">698</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="DuckDB.Generator-699"><a href="#DuckDB.Generator-699"><span class="linenos">699</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-700"><a href="#DuckDB.Generator-700"><span class="linenos">700</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-701"><a href="#DuckDB.Generator-701"><span class="linenos">701</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-702"><a href="#DuckDB.Generator-702"><span class="linenos">702</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</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="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-704"><a href="#DuckDB.Generator-704"><span class="linenos">704</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-705"><a href="#DuckDB.Generator-705"><span class="linenos">705</span></a> <span class="n">tablesample_keyword</span> <span class="o">=</span> <span class="s2">"TABLESAMPLE"</span> +</span><span id="DuckDB.Generator-706"><a href="#DuckDB.Generator-706"><span class="linenos">706</span></a> +</span><span id="DuckDB.Generator-707"><a href="#DuckDB.Generator-707"><span class="linenos">707</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-708"><a href="#DuckDB.Generator-708"><span class="linenos">708</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-709"><a href="#DuckDB.Generator-709"><span class="linenos">709</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-710"><a href="#DuckDB.Generator-710"><span class="linenos">710</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-711"><a href="#DuckDB.Generator-711"><span class="linenos">711</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-712"><a href="#DuckDB.Generator-712"><span class="linenos">712</span></a> <span class="s2">"defaulting to reservoir sampling"</span> +</span><span id="DuckDB.Generator-713"><a href="#DuckDB.Generator-713"><span class="linenos">713</span></a> <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</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-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="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-717"><a href="#DuckDB.Generator-717"><span class="linenos">717</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-718"><a href="#DuckDB.Generator-718"><span class="linenos">718</span></a> <span class="p">)</span> +</span><span id="DuckDB.Generator-719"><a href="#DuckDB.Generator-719"><span class="linenos">719</span></a> +</span><span id="DuckDB.Generator-720"><a href="#DuckDB.Generator-720"><span class="linenos">720</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-721"><a href="#DuckDB.Generator-721"><span class="linenos">721</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-722"><a href="#DuckDB.Generator-722"><span class="linenos">722</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-723"><a href="#DuckDB.Generator-723"><span class="linenos">723</span></a> +</span><span id="DuckDB.Generator-724"><a href="#DuckDB.Generator-724"><span class="linenos">724</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-725"><a href="#DuckDB.Generator-725"><span class="linenos">725</span></a> <span class="n">multiplier</span> <span class="o">=</span> <span class="mi">7</span> +</span><span id="DuckDB.Generator-726"><a href="#DuckDB.Generator-726"><span class="linenos">726</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-727"><a href="#DuckDB.Generator-727"><span class="linenos">727</span></a> <span class="n">multiplier</span> <span class="o">=</span> <span class="mi">90</span> +</span><span id="DuckDB.Generator-728"><a href="#DuckDB.Generator-728"><span class="linenos">728</span></a> +</span><span id="DuckDB.Generator-729"><a href="#DuckDB.Generator-729"><span class="linenos">729</span></a> <span class="k">if</span> <span class="n">multiplier</span><span class="p">:</span> +</span><span id="DuckDB.Generator-730"><a href="#DuckDB.Generator-730"><span class="linenos">730</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-731"><a href="#DuckDB.Generator-731"><span class="linenos">731</span></a> +</span><span id="DuckDB.Generator-732"><a href="#DuckDB.Generator-732"><span class="linenos">732</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-733"><a href="#DuckDB.Generator-733"><span class="linenos">733</span></a> +</span><span id="DuckDB.Generator-734"><a href="#DuckDB.Generator-734"><span class="linenos">734</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-735"><a href="#DuckDB.Generator-735"><span class="linenos">735</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-736"><a href="#DuckDB.Generator-736"><span class="linenos">736</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-737"><a href="#DuckDB.Generator-737"><span class="linenos">737</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-738"><a href="#DuckDB.Generator-738"><span class="linenos">738</span></a> +</span><span id="DuckDB.Generator-739"><a href="#DuckDB.Generator-739"><span class="linenos">739</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-740"><a href="#DuckDB.Generator-740"><span class="linenos">740</span></a> <span class="k">if</span> <span class="p">(</span> +</span><span id="DuckDB.Generator-741"><a href="#DuckDB.Generator-741"><span class="linenos">741</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-742"><a href="#DuckDB.Generator-742"><span class="linenos">742</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-743"><a href="#DuckDB.Generator-743"><span class="linenos">743</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-744"><a href="#DuckDB.Generator-744"><span class="linenos">744</span></a> <span class="p">):</span> +</span><span id="DuckDB.Generator-745"><a href="#DuckDB.Generator-745"><span class="linenos">745</span></a> <span class="c1"># Some dialects support `LEFT JOIN UNNEST(...)` without an explicit ON clause</span> +</span><span id="DuckDB.Generator-746"><a href="#DuckDB.Generator-746"><span class="linenos">746</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-747"><a href="#DuckDB.Generator-747"><span class="linenos">747</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-748"><a href="#DuckDB.Generator-748"><span class="linenos">748</span></a> +</span><span id="DuckDB.Generator-749"><a href="#DuckDB.Generator-749"><span class="linenos">749</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-750"><a href="#DuckDB.Generator-750"><span class="linenos">750</span></a> -</span><span id="DuckDB.Generator-751"><a href="#DuckDB.Generator-751"><span class="linenos">751</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-752"><a href="#DuckDB.Generator-752"><span class="linenos">752</span></a> -</span><span id="DuckDB.Generator-753"><a href="#DuckDB.Generator-753"><span class="linenos">753</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-754"><a href="#DuckDB.Generator-754"><span class="linenos">754</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-755"><a href="#DuckDB.Generator-755"><span class="linenos">755</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-756"><a href="#DuckDB.Generator-756"><span class="linenos">756</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-751"><a href="#DuckDB.Generator-751"><span class="linenos">751</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-752"><a href="#DuckDB.Generator-752"><span class="linenos">752</span></a> <span class="c1"># GENERATE_SERIES(a, b) -> [a, b], RANGE(a, b) -> [a, b)</span> +</span><span id="DuckDB.Generator-753"><a href="#DuckDB.Generator-753"><span class="linenos">753</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-754"><a href="#DuckDB.Generator-754"><span class="linenos">754</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-755"><a href="#DuckDB.Generator-755"><span class="linenos">755</span></a> +</span><span id="DuckDB.Generator-756"><a href="#DuckDB.Generator-756"><span class="linenos">756</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">function_fallback_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> </span><span id="DuckDB.Generator-757"><a href="#DuckDB.Generator-757"><span class="linenos">757</span></a> -</span><span id="DuckDB.Generator-758"><a href="#DuckDB.Generator-758"><span class="linenos">758</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-759"><a href="#DuckDB.Generator-759"><span class="linenos">759</span></a> -</span><span id="DuckDB.Generator-760"><a href="#DuckDB.Generator-760"><span class="linenos">760</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-761"><a href="#DuckDB.Generator-761"><span class="linenos">761</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-762"><a href="#DuckDB.Generator-762"><span class="linenos">762</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-763"><a href="#DuckDB.Generator-763"><span class="linenos">763</span></a> -</span><span id="DuckDB.Generator-764"><a href="#DuckDB.Generator-764"><span class="linenos">764</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-765"><a href="#DuckDB.Generator-765"><span class="linenos">765</span></a> -</span><span id="DuckDB.Generator-766"><a href="#DuckDB.Generator-766"><span class="linenos">766</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-767"><a href="#DuckDB.Generator-767"><span class="linenos">767</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-758"><a href="#DuckDB.Generator-758"><span class="linenos">758</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-759"><a href="#DuckDB.Generator-759"><span class="linenos">759</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-760"><a href="#DuckDB.Generator-760"><span class="linenos">760</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-761"><a href="#DuckDB.Generator-761"><span class="linenos">761</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-762"><a href="#DuckDB.Generator-762"><span class="linenos">762</span></a> +</span><span id="DuckDB.Generator-763"><a href="#DuckDB.Generator-763"><span class="linenos">763</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-764"><a href="#DuckDB.Generator-764"><span class="linenos">764</span></a> +</span><span id="DuckDB.Generator-765"><a href="#DuckDB.Generator-765"><span class="linenos">765</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-766"><a href="#DuckDB.Generator-766"><span class="linenos">766</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-767"><a href="#DuckDB.Generator-767"><span class="linenos">767</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-768"><a href="#DuckDB.Generator-768"><span class="linenos">768</span></a> -</span><span id="DuckDB.Generator-769"><a href="#DuckDB.Generator-769"><span class="linenos">769</span></a> <span class="k">return</span> <span class="n">bracket</span> +</span><span id="DuckDB.Generator-769"><a href="#DuckDB.Generator-769"><span class="linenos">769</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-770"><a href="#DuckDB.Generator-770"><span class="linenos">770</span></a> -</span><span id="DuckDB.Generator-771"><a href="#DuckDB.Generator-771"><span class="linenos">771</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-772"><a href="#DuckDB.Generator-772"><span class="linenos">772</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-771"><a href="#DuckDB.Generator-771"><span class="linenos">771</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-772"><a href="#DuckDB.Generator-772"><span class="linenos">772</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-773"><a href="#DuckDB.Generator-773"><span class="linenos">773</span></a> -</span><span id="DuckDB.Generator-774"><a href="#DuckDB.Generator-774"><span class="linenos">774</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-775"><a href="#DuckDB.Generator-775"><span class="linenos">775</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-776"><a href="#DuckDB.Generator-776"><span class="linenos">776</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-777"><a href="#DuckDB.Generator-777"><span class="linenos">777</span></a> <span class="c1"># https://duckdb.org/docs/sql/aggregates#ordered-set-aggregate-functions</span> -</span><span id="DuckDB.Generator-778"><a href="#DuckDB.Generator-778"><span class="linenos">778</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-779"><a href="#DuckDB.Generator-779"><span class="linenos">779</span></a> <span class="k">if</span> <span class="n">order_col</span><span class="p">:</span> -</span><span id="DuckDB.Generator-780"><a href="#DuckDB.Generator-780"><span class="linenos">780</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-781"><a href="#DuckDB.Generator-781"><span class="linenos">781</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-782"><a href="#DuckDB.Generator-782"><span class="linenos">782</span></a> -</span><span id="DuckDB.Generator-783"><a href="#DuckDB.Generator-783"><span class="linenos">783</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</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-784"><a href="#DuckDB.Generator-784"><span class="linenos">784</span></a> -</span><span id="DuckDB.Generator-785"><a href="#DuckDB.Generator-785"><span class="linenos">785</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-786"><a href="#DuckDB.Generator-786"><span class="linenos">786</span></a> -</span><span id="DuckDB.Generator-787"><a href="#DuckDB.Generator-787"><span class="linenos">787</span></a> <span class="k">def</span> <span class="nf">length_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Length</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="DuckDB.Generator-788"><a href="#DuckDB.Generator-788"><span class="linenos">788</span></a> <span class="n">arg</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> +</span><span id="DuckDB.Generator-774"><a href="#DuckDB.Generator-774"><span class="linenos">774</span></a> <span class="k">return</span> <span class="n">bracket</span> +</span><span id="DuckDB.Generator-775"><a href="#DuckDB.Generator-775"><span class="linenos">775</span></a> +</span><span id="DuckDB.Generator-776"><a href="#DuckDB.Generator-776"><span class="linenos">776</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-777"><a href="#DuckDB.Generator-777"><span class="linenos">777</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-778"><a href="#DuckDB.Generator-778"><span class="linenos">778</span></a> +</span><span id="DuckDB.Generator-779"><a href="#DuckDB.Generator-779"><span class="linenos">779</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-780"><a href="#DuckDB.Generator-780"><span class="linenos">780</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-781"><a href="#DuckDB.Generator-781"><span class="linenos">781</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-782"><a href="#DuckDB.Generator-782"><span class="linenos">782</span></a> <span class="c1"># https://duckdb.org/docs/sql/aggregates#ordered-set-aggregate-functions</span> +</span><span id="DuckDB.Generator-783"><a href="#DuckDB.Generator-783"><span class="linenos">783</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-784"><a href="#DuckDB.Generator-784"><span class="linenos">784</span></a> <span class="k">if</span> <span class="n">order_col</span><span class="p">:</span> +</span><span id="DuckDB.Generator-785"><a href="#DuckDB.Generator-785"><span class="linenos">785</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-786"><a href="#DuckDB.Generator-786"><span class="linenos">786</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-787"><a href="#DuckDB.Generator-787"><span class="linenos">787</span></a> +</span><span id="DuckDB.Generator-788"><a href="#DuckDB.Generator-788"><span class="linenos">788</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</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-789"><a href="#DuckDB.Generator-789"><span class="linenos">789</span></a> -</span><span id="DuckDB.Generator-790"><a href="#DuckDB.Generator-790"><span class="linenos">790</span></a> <span class="c1"># Dialects like BQ and Snowflake also accept binary values as args, so</span> -</span><span id="DuckDB.Generator-791"><a href="#DuckDB.Generator-791"><span class="linenos">791</span></a> <span class="c1"># DDB will attempt to infer the type or resort to case/when resolution</span> -</span><span id="DuckDB.Generator-792"><a href="#DuckDB.Generator-792"><span class="linenos">792</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">"binary"</span><span class="p">)</span> <span class="ow">or</span> <span class="n">arg</span><span class="o">.</span><span class="n">is_string</span><span class="p">:</span> -</span><span id="DuckDB.Generator-793"><a href="#DuckDB.Generator-793"><span class="linenos">793</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"LENGTH"</span><span class="p">,</span> <span class="n">arg</span><span class="p">)</span> +</span><span id="DuckDB.Generator-790"><a href="#DuckDB.Generator-790"><span class="linenos">790</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-791"><a href="#DuckDB.Generator-791"><span class="linenos">791</span></a> +</span><span id="DuckDB.Generator-792"><a href="#DuckDB.Generator-792"><span class="linenos">792</span></a> <span class="k">def</span> <span class="nf">length_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Length</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="DuckDB.Generator-793"><a href="#DuckDB.Generator-793"><span class="linenos">793</span></a> <span class="n">arg</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> </span><span id="DuckDB.Generator-794"><a href="#DuckDB.Generator-794"><span class="linenos">794</span></a> -</span><span id="DuckDB.Generator-795"><a href="#DuckDB.Generator-795"><span class="linenos">795</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">arg</span><span class="o">.</span><span class="n">type</span><span class="p">:</span> -</span><span id="DuckDB.Generator-796"><a href="#DuckDB.Generator-796"><span class="linenos">796</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-797"><a href="#DuckDB.Generator-797"><span class="linenos">797</span></a> -</span><span id="DuckDB.Generator-798"><a href="#DuckDB.Generator-798"><span class="linenos">798</span></a> <span class="n">arg</span> <span class="o">=</span> <span class="n">annotate_types</span><span class="p">(</span><span class="n">arg</span><span class="p">)</span> +</span><span id="DuckDB.Generator-795"><a href="#DuckDB.Generator-795"><span class="linenos">795</span></a> <span class="c1"># Dialects like BQ and Snowflake also accept binary values as args, so</span> +</span><span id="DuckDB.Generator-796"><a href="#DuckDB.Generator-796"><span class="linenos">796</span></a> <span class="c1"># DDB will attempt to infer the type or resort to case/when resolution</span> +</span><span id="DuckDB.Generator-797"><a href="#DuckDB.Generator-797"><span class="linenos">797</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">"binary"</span><span class="p">)</span> <span class="ow">or</span> <span class="n">arg</span><span class="o">.</span><span class="n">is_string</span><span class="p">:</span> +</span><span id="DuckDB.Generator-798"><a href="#DuckDB.Generator-798"><span class="linenos">798</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"LENGTH"</span><span class="p">,</span> <span class="n">arg</span><span class="p">)</span> </span><span id="DuckDB.Generator-799"><a href="#DuckDB.Generator-799"><span class="linenos">799</span></a> -</span><span id="DuckDB.Generator-800"><a href="#DuckDB.Generator-800"><span class="linenos">800</span></a> <span class="k">if</span> <span class="n">arg</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="o">*</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">TEXT_TYPES</span><span class="p">):</span> -</span><span id="DuckDB.Generator-801"><a href="#DuckDB.Generator-801"><span class="linenos">801</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"LENGTH"</span><span class="p">,</span> <span class="n">arg</span><span class="p">)</span> +</span><span id="DuckDB.Generator-800"><a href="#DuckDB.Generator-800"><span class="linenos">800</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">arg</span><span class="o">.</span><span class="n">type</span><span class="p">:</span> +</span><span id="DuckDB.Generator-801"><a href="#DuckDB.Generator-801"><span class="linenos">801</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-802"><a href="#DuckDB.Generator-802"><span class="linenos">802</span></a> -</span><span id="DuckDB.Generator-803"><a href="#DuckDB.Generator-803"><span class="linenos">803</span></a> <span class="c1"># We need these casts to make duckdb's static type checker happy</span> -</span><span id="DuckDB.Generator-804"><a href="#DuckDB.Generator-804"><span class="linenos">804</span></a> <span class="n">blob</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">arg</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">VARBINARY</span><span class="p">)</span> -</span><span id="DuckDB.Generator-805"><a href="#DuckDB.Generator-805"><span class="linenos">805</span></a> <span class="n">varchar</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">arg</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">VARCHAR</span><span class="p">)</span> -</span><span id="DuckDB.Generator-806"><a href="#DuckDB.Generator-806"><span class="linenos">806</span></a> -</span><span id="DuckDB.Generator-807"><a href="#DuckDB.Generator-807"><span class="linenos">807</span></a> <span class="n">case</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="DuckDB.Generator-808"><a href="#DuckDB.Generator-808"><span class="linenos">808</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">case</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"TYPEOF"</span><span class="p">,</span> <span class="n">arg</span><span class="p">))</span> -</span><span id="DuckDB.Generator-809"><a href="#DuckDB.Generator-809"><span class="linenos">809</span></a> <span class="o">.</span><span class="n">when</span><span class="p">(</span> -</span><span id="DuckDB.Generator-810"><a href="#DuckDB.Generator-810"><span class="linenos">810</span></a> <span class="s2">"'VARCHAR'"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Anonymous</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="s2">"LENGTH"</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="n">varchar</span><span class="p">])</span> -</span><span id="DuckDB.Generator-811"><a href="#DuckDB.Generator-811"><span class="linenos">811</span></a> <span class="p">)</span> <span class="c1"># anonymous to break length_sql recursion</span> -</span><span id="DuckDB.Generator-812"><a href="#DuckDB.Generator-812"><span class="linenos">812</span></a> <span class="o">.</span><span class="n">when</span><span class="p">(</span><span class="s2">"'BLOB'"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"OCTET_LENGTH"</span><span class="p">,</span> <span class="n">blob</span><span class="p">))</span> -</span><span id="DuckDB.Generator-813"><a href="#DuckDB.Generator-813"><span class="linenos">813</span></a> <span class="p">)</span> -</span><span id="DuckDB.Generator-814"><a href="#DuckDB.Generator-814"><span class="linenos">814</span></a> -</span><span id="DuckDB.Generator-815"><a href="#DuckDB.Generator-815"><span class="linenos">815</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">case</span><span class="p">)</span> -</span><span id="DuckDB.Generator-816"><a href="#DuckDB.Generator-816"><span class="linenos">816</span></a> -</span><span id="DuckDB.Generator-817"><a href="#DuckDB.Generator-817"><span class="linenos">817</span></a> <span class="k">def</span> <span class="nf">objectinsert_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ObjectInsert</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="DuckDB.Generator-818"><a href="#DuckDB.Generator-818"><span class="linenos">818</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-819"><a href="#DuckDB.Generator-819"><span class="linenos">819</span></a> <span class="n">key</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"key"</span><span class="p">)</span> -</span><span id="DuckDB.Generator-820"><a href="#DuckDB.Generator-820"><span class="linenos">820</span></a> <span class="n">key_sql</span> <span class="o">=</span> <span class="n">key</span><span class="o">.</span><span class="n">name</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="DuckDB.Generator-821"><a href="#DuckDB.Generator-821"><span class="linenos">821</span></a> <span class="n">value_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">"value"</span><span class="p">)</span> -</span><span id="DuckDB.Generator-822"><a href="#DuckDB.Generator-822"><span class="linenos">822</span></a> -</span><span id="DuckDB.Generator-823"><a href="#DuckDB.Generator-823"><span class="linenos">823</span></a> <span class="n">kv_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">key_sql</span><span class="si">}</span><span class="s2"> := </span><span class="si">{</span><span class="n">value_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="DuckDB.Generator-824"><a href="#DuckDB.Generator-824"><span class="linenos">824</span></a> -</span><span id="DuckDB.Generator-825"><a href="#DuckDB.Generator-825"><span class="linenos">825</span></a> <span class="c1"># If the input struct is empty e.g. transpiling OBJECT_INSERT(OBJECT_CONSTRUCT(), key, value) from Snowflake</span> -</span><span id="DuckDB.Generator-826"><a href="#DuckDB.Generator-826"><span class="linenos">826</span></a> <span class="c1"># then we can generate STRUCT_PACK which will build it since STRUCT_INSERT({}, key := value) is not valid DuckDB</span> -</span><span id="DuckDB.Generator-827"><a href="#DuckDB.Generator-827"><span class="linenos">827</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">Struct</span><span class="p">)</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">this</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> -</span><span id="DuckDB.Generator-828"><a href="#DuckDB.Generator-828"><span class="linenos">828</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"STRUCT_PACK"</span><span class="p">,</span> <span class="n">kv_sql</span><span class="p">)</span> +</span><span id="DuckDB.Generator-803"><a href="#DuckDB.Generator-803"><span class="linenos">803</span></a> <span class="n">arg</span> <span class="o">=</span> <span class="n">annotate_types</span><span class="p">(</span><span class="n">arg</span><span class="p">)</span> +</span><span id="DuckDB.Generator-804"><a href="#DuckDB.Generator-804"><span class="linenos">804</span></a> +</span><span id="DuckDB.Generator-805"><a href="#DuckDB.Generator-805"><span class="linenos">805</span></a> <span class="k">if</span> <span class="n">arg</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="o">*</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">TEXT_TYPES</span><span class="p">):</span> +</span><span id="DuckDB.Generator-806"><a href="#DuckDB.Generator-806"><span class="linenos">806</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"LENGTH"</span><span class="p">,</span> <span class="n">arg</span><span class="p">)</span> +</span><span id="DuckDB.Generator-807"><a href="#DuckDB.Generator-807"><span class="linenos">807</span></a> +</span><span id="DuckDB.Generator-808"><a href="#DuckDB.Generator-808"><span class="linenos">808</span></a> <span class="c1"># We need these casts to make duckdb's static type checker happy</span> +</span><span id="DuckDB.Generator-809"><a href="#DuckDB.Generator-809"><span class="linenos">809</span></a> <span class="n">blob</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">arg</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">VARBINARY</span><span class="p">)</span> +</span><span id="DuckDB.Generator-810"><a href="#DuckDB.Generator-810"><span class="linenos">810</span></a> <span class="n">varchar</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">arg</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">VARCHAR</span><span class="p">)</span> +</span><span id="DuckDB.Generator-811"><a href="#DuckDB.Generator-811"><span class="linenos">811</span></a> +</span><span id="DuckDB.Generator-812"><a href="#DuckDB.Generator-812"><span class="linenos">812</span></a> <span class="n">case</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="DuckDB.Generator-813"><a href="#DuckDB.Generator-813"><span class="linenos">813</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">case</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"TYPEOF"</span><span class="p">,</span> <span class="n">arg</span><span class="p">))</span> +</span><span id="DuckDB.Generator-814"><a href="#DuckDB.Generator-814"><span class="linenos">814</span></a> <span class="o">.</span><span class="n">when</span><span class="p">(</span> +</span><span id="DuckDB.Generator-815"><a href="#DuckDB.Generator-815"><span class="linenos">815</span></a> <span class="s2">"'VARCHAR'"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Anonymous</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="s2">"LENGTH"</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="n">varchar</span><span class="p">])</span> +</span><span id="DuckDB.Generator-816"><a href="#DuckDB.Generator-816"><span class="linenos">816</span></a> <span class="p">)</span> <span class="c1"># anonymous to break length_sql recursion</span> +</span><span id="DuckDB.Generator-817"><a href="#DuckDB.Generator-817"><span class="linenos">817</span></a> <span class="o">.</span><span class="n">when</span><span class="p">(</span><span class="s2">"'BLOB'"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"OCTET_LENGTH"</span><span class="p">,</span> <span class="n">blob</span><span class="p">))</span> +</span><span id="DuckDB.Generator-818"><a href="#DuckDB.Generator-818"><span class="linenos">818</span></a> <span class="p">)</span> +</span><span id="DuckDB.Generator-819"><a href="#DuckDB.Generator-819"><span class="linenos">819</span></a> +</span><span id="DuckDB.Generator-820"><a href="#DuckDB.Generator-820"><span class="linenos">820</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">case</span><span class="p">)</span> +</span><span id="DuckDB.Generator-821"><a href="#DuckDB.Generator-821"><span class="linenos">821</span></a> +</span><span id="DuckDB.Generator-822"><a href="#DuckDB.Generator-822"><span class="linenos">822</span></a> <span class="k">def</span> <span class="nf">objectinsert_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ObjectInsert</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="DuckDB.Generator-823"><a href="#DuckDB.Generator-823"><span class="linenos">823</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-824"><a href="#DuckDB.Generator-824"><span class="linenos">824</span></a> <span class="n">key</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"key"</span><span class="p">)</span> +</span><span id="DuckDB.Generator-825"><a href="#DuckDB.Generator-825"><span class="linenos">825</span></a> <span class="n">key_sql</span> <span class="o">=</span> <span class="n">key</span><span class="o">.</span><span class="n">name</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="DuckDB.Generator-826"><a href="#DuckDB.Generator-826"><span class="linenos">826</span></a> <span class="n">value_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">"value"</span><span class="p">)</span> +</span><span id="DuckDB.Generator-827"><a href="#DuckDB.Generator-827"><span class="linenos">827</span></a> +</span><span id="DuckDB.Generator-828"><a href="#DuckDB.Generator-828"><span class="linenos">828</span></a> <span class="n">kv_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">key_sql</span><span class="si">}</span><span class="s2"> := </span><span class="si">{</span><span class="n">value_sql</span><span class="si">}</span><span class="s2">"</span> </span><span id="DuckDB.Generator-829"><a href="#DuckDB.Generator-829"><span class="linenos">829</span></a> -</span><span id="DuckDB.Generator-830"><a href="#DuckDB.Generator-830"><span class="linenos">830</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"STRUCT_INSERT"</span><span class="p">,</span> <span class="n">this</span><span class="p">,</span> <span class="n">kv_sql</span><span class="p">)</span> +</span><span id="DuckDB.Generator-830"><a href="#DuckDB.Generator-830"><span class="linenos">830</span></a> <span class="c1"># If the input struct is empty e.g. transpiling OBJECT_INSERT(OBJECT_CONSTRUCT(), key, value) from Snowflake</span> +</span><span id="DuckDB.Generator-831"><a href="#DuckDB.Generator-831"><span class="linenos">831</span></a> <span class="c1"># then we can generate STRUCT_PACK which will build it since STRUCT_INSERT({}, key := value) is not valid DuckDB</span> +</span><span id="DuckDB.Generator-832"><a href="#DuckDB.Generator-832"><span class="linenos">832</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">Struct</span><span class="p">)</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">this</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> +</span><span id="DuckDB.Generator-833"><a href="#DuckDB.Generator-833"><span class="linenos">833</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"STRUCT_PACK"</span><span class="p">,</span> <span class="n">kv_sql</span><span class="p">)</span> +</span><span id="DuckDB.Generator-834"><a href="#DuckDB.Generator-834"><span class="linenos">834</span></a> +</span><span id="DuckDB.Generator-835"><a href="#DuckDB.Generator-835"><span class="linenos">835</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"STRUCT_INSERT"</span><span class="p">,</span> <span class="n">this</span><span class="p">,</span> <span class="n">kv_sql</span><span class="p">)</span> </span></pre></div> @@ -3681,7 +3702,7 @@ Default: True</li> <div class="attr variable"> <span class="name">TRANSFORMS</span> = <input id="DuckDB.Generator.TRANSFORMS-view-value" class="view-value-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1"> - <label class="view-value-button pdoc-button" for="DuckDB.Generator.TRANSFORMS-view-value"></label><span class="default_value">{<class '<a href="../expressions.html#JSONPathKey">sqlglot.expressions.JSONPathKey</a>'>: <function <lambda>>, <class '<a href="../expressions.html#JSONPathRoot">sqlglot.expressions.JSONPathRoot</a>'>: <function <lambda>>, <class '<a href="../expressions.html#JSONPathSubscript">sqlglot.expressions.JSONPathSubscript</a>'>: <function <lambda>>, <class '<a href="../expressions.html#JSONPathWildcard">sqlglot.expressions.JSONPathWildcard</a>'>: <function <lambda>>, <class '<a href="../expressions.html#AllowedValuesProperty">sqlglot.expressions.AllowedValuesProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#AutoRefreshProperty">sqlglot.expressions.AutoRefreshProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#BackupProperty">sqlglot.expressions.BackupProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#CaseSpecificColumnConstraint">sqlglot.expressions.CaseSpecificColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#CharacterSetColumnConstraint">sqlglot.expressions.CharacterSetColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#CharacterSetProperty">sqlglot.expressions.CharacterSetProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#ClusteredColumnConstraint">sqlglot.expressions.ClusteredColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#CollateColumnConstraint">sqlglot.expressions.CollateColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#CommentColumnConstraint">sqlglot.expressions.CommentColumnConstraint</a>'>: <function no_comment_column_constraint_sql>, <class '<a href="../expressions.html#ConnectByRoot">sqlglot.expressions.ConnectByRoot</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#CopyGrantsProperty">sqlglot.expressions.CopyGrantsProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#DateFormatColumnConstraint">sqlglot.expressions.DateFormatColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#DefaultColumnConstraint">sqlglot.expressions.DefaultColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#DynamicProperty">sqlglot.expressions.DynamicProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#EncodeColumnConstraint">sqlglot.expressions.EncodeColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#EphemeralColumnConstraint">sqlglot.expressions.EphemeralColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#ExcludeColumnConstraint">sqlglot.expressions.ExcludeColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#ExecuteAsProperty">sqlglot.expressions.ExecuteAsProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#ExternalProperty">sqlglot.expressions.ExternalProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#GlobalProperty">sqlglot.expressions.GlobalProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#HeapProperty">sqlglot.expressions.HeapProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#IcebergProperty">sqlglot.expressions.IcebergProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#InheritsProperty">sqlglot.expressions.InheritsProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#InlineLengthColumnConstraint">sqlglot.expressions.InlineLengthColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#InputModelProperty">sqlglot.expressions.InputModelProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#IntervalSpan">sqlglot.expressions.IntervalSpan</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#JSONExtract">sqlglot.expressions.JSONExtract</a>'>: <function _arrow_json_extract_sql>, <class '<a href="../expressions.html#JSONExtractScalar">sqlglot.expressions.JSONExtractScalar</a>'>: <function _arrow_json_extract_sql>, <class '<a href="../expressions.html#LanguageProperty">sqlglot.expressions.LanguageProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#LocationProperty">sqlglot.expressions.LocationProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#LogProperty">sqlglot.expressions.LogProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#MaterializedProperty">sqlglot.expressions.MaterializedProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#NonClusteredColumnConstraint">sqlglot.expressions.NonClusteredColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#NoPrimaryIndexProperty">sqlglot.expressions.NoPrimaryIndexProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#NotForReplicationColumnConstraint">sqlglot.expressions.NotForReplicationColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#OnCommitProperty">sqlglot.expressions.OnCommitProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#OnProperty">sqlglot.expressions.OnProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#OnUpdateColumnConstraint">sqlglot.expressions.OnUpdateColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#OutputModelProperty">sqlglot.expressions.OutputModelProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#PathColumnConstraint">sqlglot.expressions.PathColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#ProjectionPolicyColumnConstraint">sqlglot.expressions.ProjectionPolicyColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#RemoteWithConnectionModelProperty">sqlglot.expressions.RemoteWithConnectionModelProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#ReturnsProperty">sqlglot.expressions.ReturnsProperty</a>'>: <function <a href="#DuckDB.Generator">DuckDB.Generator</a>.<lambda>>, <class '<a href="../expressions.html#SampleProperty">sqlglot.expressions.SampleProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#SecureProperty">sqlglot.expressions.SecureProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#SetConfigProperty">sqlglot.expressions.SetConfigProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#SetProperty">sqlglot.expressions.SetProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#SettingsProperty">sqlglot.expressions.SettingsProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#SharingProperty">sqlglot.expressions.SharingProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#SqlReadWriteProperty">sqlglot.expressions.SqlReadWriteProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#SqlSecurityProperty">sqlglot.expressions.SqlSecurityProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#StabilityProperty">sqlglot.expressions.StabilityProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#StrictProperty">sqlglot.expressions.StrictProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#TemporaryProperty">sqlglot.expressions.TemporaryProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#TagColumnConstraint">sqlglot.expressions.TagColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#TitleColumnConstraint">sqlglot.expressions.TitleColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#Timestamp">sqlglot.expressions.Timestamp</a>'>: <function no_timestamp_sql>, <class '<a href="../expressions.html#ToMap">sqlglot.expressions.ToMap</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#ToTableProperty">sqlglot.expressions.ToTableProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#TransformModelProperty">sqlglot.expressions.TransformModelProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#TransientProperty">sqlglot.expressions.TransientProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#UppercaseColumnConstraint">sqlglot.expressions.UppercaseColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#UnloggedProperty">sqlglot.expressions.UnloggedProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#VarMap">sqlglot.expressions.VarMap</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#ViewAttributeProperty">sqlglot.expressions.ViewAttributeProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#VolatileProperty">sqlglot.expressions.VolatileProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#WithJournalTableProperty">sqlglot.expressions.WithJournalTableProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#WithSchemaBindingProperty">sqlglot.expressions.WithSchemaBindingProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#WithOperator">sqlglot.expressions.WithOperator</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#ApproxDistinct">sqlglot.expressions.ApproxDistinct</a>'>: <function approx_count_distinct_sql>, <class '<a href="../expressions.html#Array">sqlglot.expressions.Array</a>'>: <function inline_array_unless_query>, <class '<a href="../expressions.html#ArrayContainsAll">sqlglot.expressions.ArrayContainsAll</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#ArrayFilter">sqlglot.expressions.ArrayFilter</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#ArraySize">sqlglot.expressions.ArraySize</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#ArgMax">sqlglot.expressions.ArgMax</a>'>: <function arg_max_or_min_no_count.<locals>._arg_max_or_min_sql>, <class '<a href="../expressions.html#ArgMin">sqlglot.expressions.ArgMin</a>'>: <function arg_max_or_min_no_count.<locals>._arg_max_or_min_sql>, <class '<a href="../expressions.html#ArraySort">sqlglot.expressions.ArraySort</a>'>: <function _array_sort_sql>, <class '<a href="../expressions.html#ArraySum">sqlglot.expressions.ArraySum</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#BitwiseXor">sqlglot.expressions.BitwiseXor</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#CurrentDate">sqlglot.expressions.CurrentDate</a>'>: <function <a href="#DuckDB.Generator">DuckDB.Generator</a>.<lambda>>, <class '<a href="../expressions.html#CurrentTime">sqlglot.expressions.CurrentTime</a>'>: <function <a href="#DuckDB.Generator">DuckDB.Generator</a>.<lambda>>, <class '<a href="../expressions.html#CurrentTimestamp">sqlglot.expressions.CurrentTimestamp</a>'>: <function <a href="#DuckDB.Generator">DuckDB.Generator</a>.<lambda>>, <class '<a href="../expressions.html#DayOfMonth">sqlglot.expressions.DayOfMonth</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#DayOfWeek">sqlglot.expressions.DayOfWeek</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#DayOfYear">sqlglot.expressions.DayOfYear</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#DataType">sqlglot.expressions.DataType</a>'>: <function _datatype_sql>, <class '<a href="../expressions.html#Date">sqlglot.expressions.Date</a>'>: <function _date_sql>, <class '<a href="../expressions.html#DateAdd">sqlglot.expressions.DateAdd</a>'>: <function _date_delta_sql>, <class '<a href="../expressions.html#DateFromParts">sqlglot.expressions.DateFromParts</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#DateSub">sqlglot.expressions.DateSub</a>'>: <function _date_delta_sql>, <class '<a href="../expressions.html#DateDiff">sqlglot.expressions.DateDiff</a>'>: <function <a href="#DuckDB.Generator">DuckDB.Generator</a>.<lambda>>, <class '<a href="../expressions.html#DateStrToDate">sqlglot.expressions.DateStrToDate</a>'>: <function datestrtodate_sql>, <class '<a href="../expressions.html#Datetime">sqlglot.expressions.Datetime</a>'>: <function no_datetime_sql>, <class '<a href="../expressions.html#DatetimeSub">sqlglot.expressions.DatetimeSub</a>'>: <function _date_delta_sql>, <class '<a href="../expressions.html#DatetimeAdd">sqlglot.expressions.DatetimeAdd</a>'>: <function _date_delta_sql>, <class '<a href="../expressions.html#DateToDi">sqlglot.expressions.DateToDi</a>'>: <function <a href="#DuckDB.Generator">DuckDB.Generator</a>.<lambda>>, <class '<a href="../expressions.html#Decode">sqlglot.expressions.Decode</a>'>: <function <a href="#DuckDB.Generator">DuckDB.Generator</a>.<lambda>>, <class '<a href="../expressions.html#DiToDate">sqlglot.expressions.DiToDate</a>'>: <function <a href="#DuckDB.Generator">DuckDB.Generator</a>.<lambda>>, <class '<a href="../expressions.html#Encode">sqlglot.expressions.Encode</a>'>: <function <a href="#DuckDB.Generator">DuckDB.Generator</a>.<lambda>>, <class '<a href="../expressions.html#Explode">sqlglot.expressions.Explode</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#IntDiv">sqlglot.expressions.IntDiv</a>'>: <function <a href="#DuckDB.Generator">DuckDB.Generator</a>.<lambda>>, <class '<a href="../expressions.html#IsInf">sqlglot.expressions.IsInf</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#IsNan">sqlglot.expressions.IsNan</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#JSONFormat">sqlglot.expressions.JSONFormat</a>'>: <function _json_format_sql>, <class '<a href="../expressions.html#LogicalOr">sqlglot.expressions.LogicalOr</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#LogicalAnd">sqlglot.expressions.LogicalAnd</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#MD5Digest">sqlglot.expressions.MD5Digest</a>'>: <function <a href="#DuckDB.Generator">DuckDB.Generator</a>.<lambda>>, <class '<a href="../expressions.html#MonthsBetween">sqlglot.expressions.MonthsBetween</a>'>: <function <a href="#DuckDB.Generator">DuckDB.Generator</a>.<lambda>>, <class '<a href="../expressions.html#PercentileCont">sqlglot.expressions.PercentileCont</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#PercentileDisc">sqlglot.expressions.PercentileDisc</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#Pivot">sqlglot.expressions.Pivot</a>'>: <function preprocess.<locals>._to_sql>, <class '<a href="../expressions.html#RegexpExtract">sqlglot.expressions.RegexpExtract</a>'>: <function regexp_extract_sql>, <class '<a href="../expressions.html#RegexpReplace">sqlglot.expressions.RegexpReplace</a>'>: <function <a href="#DuckDB.Generator">DuckDB.Generator</a>.<lambda>>, <class '<a href="../expressions.html#RegexpLike">sqlglot.expressions.RegexpLike</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#RegexpSplit">sqlglot.expressions.RegexpSplit</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#Return">sqlglot.expressions.Return</a>'>: <function <a href="#DuckDB.Generator">DuckDB.Generator</a>.<lambda>>, <class '<a href="../expressions.html#Rand">sqlglot.expressions.Rand</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#SafeDivide">sqlglot.expressions.SafeDivide</a>'>: <function no_safe_divide_sql>, <class '<a href="../expressions.html#Split">sqlglot.expressions.Split</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#SortArray">sqlglot.expressions.SortArray</a>'>: <function _sort_array_sql>, <class '<a href="../expressions.html#StrPosition">sqlglot.expressions.StrPosition</a>'>: <function str_position_sql>, <class '<a href="../expressions.html#StrToUnix">sqlglot.expressions.StrToUnix</a>'>: <function <a href="#DuckDB.Generator">DuckDB.Generator</a>.<lambda>>, <class '<a href="../expressions.html#Struct">sqlglot.expressions.Struct</a>'>: <function _struct_sql>, <class '<a href="../expressions.html#TimeAdd">sqlglot.expressions.TimeAdd</a>'>: <function _date_delta_sql>, <class '<a href="../expressions.html#Time">sqlglot.expressions.Time</a>'>: <function no_time_sql>, <class '<a href="../expressions.html#TimestampDiff">sqlglot.expressions.TimestampDiff</a>'>: <function <a href="#DuckDB.Generator">DuckDB.Generator</a>.<lambda>>, <class '<a href="../expressions.html#TimestampTrunc">sqlglot.expressions.TimestampTrunc</a>'>: <function timestamptrunc_sql.<locals>._timestamptrunc_sql>, <class '<a href="../expressions.html#TimeStrToDate">sqlglot.expressions.TimeStrToDate</a>'>: <function <a href="#DuckDB.Generator">DuckDB.Generator</a>.<lambda>>, <class '<a href="../expressions.html#TimeStrToTime">sqlglot.expressions.TimeStrToTime</a>'>: <function timestrtotime_sql>, <class '<a href="../expressions.html#TimeStrToUnix">sqlglot.expressions.TimeStrToUnix</a>'>: <function <a href="#DuckDB.Generator">DuckDB.Generator</a>.<lambda>>, <class '<a href="../expressions.html#TimeToStr">sqlglot.expressions.TimeToStr</a>'>: <function <a href="#DuckDB.Generator">DuckDB.Generator</a>.<lambda>>, <class '<a href="../expressions.html#TimeToUnix">sqlglot.expressions.TimeToUnix</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#TsOrDiToDi">sqlglot.expressions.TsOrDiToDi</a>'>: <function <a href="#DuckDB.Generator">DuckDB.Generator</a>.<lambda>>, <class '<a href="../expressions.html#TsOrDsAdd">sqlglot.expressions.TsOrDsAdd</a>'>: <function _date_delta_sql>, <class '<a href="../expressions.html#TsOrDsDiff">sqlglot.expressions.TsOrDsDiff</a>'>: <function <a href="#DuckDB.Generator">DuckDB.Generator</a>.<lambda>>, <class '<a href="../expressions.html#UnixToStr">sqlglot.expressions.UnixToStr</a>'>: <function <a href="#DuckDB.Generator">DuckDB.Generator</a>.<lambda>>, <class '<a href="../expressions.html#UnixToTime">sqlglot.expressions.UnixToTime</a>'>: <function _unix_to_time_sql>, <class '<a href="../expressions.html#UnixToTimeStr">sqlglot.expressions.UnixToTimeStr</a>'>: <function <a href="#DuckDB.Generator">DuckDB.Generator</a>.<lambda>>, <class '<a href="../expressions.html#VariancePop">sqlglot.expressions.VariancePop</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#WeekOfYear">sqlglot.expressions.WeekOfYear</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#Xor">sqlglot.expressions.Xor</a>'>: <function bool_xor_sql>}</span> + <label class="view-value-button pdoc-button" for="DuckDB.Generator.TRANSFORMS-view-value"></label><span class="default_value">{<class '<a href="../expressions.html#JSONPathKey">sqlglot.expressions.JSONPathKey</a>'>: <function <lambda>>, <class '<a href="../expressions.html#JSONPathRoot">sqlglot.expressions.JSONPathRoot</a>'>: <function <lambda>>, <class '<a href="../expressions.html#JSONPathSubscript">sqlglot.expressions.JSONPathSubscript</a>'>: <function <lambda>>, <class '<a href="../expressions.html#JSONPathWildcard">sqlglot.expressions.JSONPathWildcard</a>'>: <function <lambda>>, <class '<a href="../expressions.html#AllowedValuesProperty">sqlglot.expressions.AllowedValuesProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#AutoRefreshProperty">sqlglot.expressions.AutoRefreshProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#BackupProperty">sqlglot.expressions.BackupProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#CaseSpecificColumnConstraint">sqlglot.expressions.CaseSpecificColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#CharacterSetColumnConstraint">sqlglot.expressions.CharacterSetColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#CharacterSetProperty">sqlglot.expressions.CharacterSetProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#ClusteredColumnConstraint">sqlglot.expressions.ClusteredColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#CollateColumnConstraint">sqlglot.expressions.CollateColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#CommentColumnConstraint">sqlglot.expressions.CommentColumnConstraint</a>'>: <function no_comment_column_constraint_sql>, <class '<a href="../expressions.html#ConnectByRoot">sqlglot.expressions.ConnectByRoot</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#CopyGrantsProperty">sqlglot.expressions.CopyGrantsProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#DateFormatColumnConstraint">sqlglot.expressions.DateFormatColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#DefaultColumnConstraint">sqlglot.expressions.DefaultColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#DynamicProperty">sqlglot.expressions.DynamicProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#EncodeColumnConstraint">sqlglot.expressions.EncodeColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#EphemeralColumnConstraint">sqlglot.expressions.EphemeralColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#ExcludeColumnConstraint">sqlglot.expressions.ExcludeColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#ExecuteAsProperty">sqlglot.expressions.ExecuteAsProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#ExternalProperty">sqlglot.expressions.ExternalProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#GlobalProperty">sqlglot.expressions.GlobalProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#HeapProperty">sqlglot.expressions.HeapProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#IcebergProperty">sqlglot.expressions.IcebergProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#InheritsProperty">sqlglot.expressions.InheritsProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#InlineLengthColumnConstraint">sqlglot.expressions.InlineLengthColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#InputModelProperty">sqlglot.expressions.InputModelProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#IntervalSpan">sqlglot.expressions.IntervalSpan</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#LanguageProperty">sqlglot.expressions.LanguageProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#LocationProperty">sqlglot.expressions.LocationProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#LogProperty">sqlglot.expressions.LogProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#MaterializedProperty">sqlglot.expressions.MaterializedProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#NonClusteredColumnConstraint">sqlglot.expressions.NonClusteredColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#NoPrimaryIndexProperty">sqlglot.expressions.NoPrimaryIndexProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#NotForReplicationColumnConstraint">sqlglot.expressions.NotForReplicationColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#OnCommitProperty">sqlglot.expressions.OnCommitProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#OnProperty">sqlglot.expressions.OnProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#OnUpdateColumnConstraint">sqlglot.expressions.OnUpdateColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#OutputModelProperty">sqlglot.expressions.OutputModelProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#PathColumnConstraint">sqlglot.expressions.PathColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#ProjectionPolicyColumnConstraint">sqlglot.expressions.ProjectionPolicyColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#RemoteWithConnectionModelProperty">sqlglot.expressions.RemoteWithConnectionModelProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#ReturnsProperty">sqlglot.expressions.ReturnsProperty</a>'>: <function <a href="#DuckDB.Generator">DuckDB.Generator</a>.<lambda>>, <class '<a href="../expressions.html#SampleProperty">sqlglot.expressions.SampleProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#SecureProperty">sqlglot.expressions.SecureProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#SetConfigProperty">sqlglot.expressions.SetConfigProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#SetProperty">sqlglot.expressions.SetProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#SettingsProperty">sqlglot.expressions.SettingsProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#SharingProperty">sqlglot.expressions.SharingProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#SqlReadWriteProperty">sqlglot.expressions.SqlReadWriteProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#SqlSecurityProperty">sqlglot.expressions.SqlSecurityProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#StabilityProperty">sqlglot.expressions.StabilityProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#StrictProperty">sqlglot.expressions.StrictProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#TemporaryProperty">sqlglot.expressions.TemporaryProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#TagColumnConstraint">sqlglot.expressions.TagColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#TitleColumnConstraint">sqlglot.expressions.TitleColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#ToMap">sqlglot.expressions.ToMap</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#ToTableProperty">sqlglot.expressions.ToTableProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#TransformModelProperty">sqlglot.expressions.TransformModelProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#TransientProperty">sqlglot.expressions.TransientProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#UppercaseColumnConstraint">sqlglot.expressions.UppercaseColumnConstraint</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#UnloggedProperty">sqlglot.expressions.UnloggedProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#VarMap">sqlglot.expressions.VarMap</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#ViewAttributeProperty">sqlglot.expressions.ViewAttributeProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#VolatileProperty">sqlglot.expressions.VolatileProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#WithJournalTableProperty">sqlglot.expressions.WithJournalTableProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#WithSchemaBindingProperty">sqlglot.expressions.WithSchemaBindingProperty</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#WithOperator">sqlglot.expressions.WithOperator</a>'>: <function Generator.<lambda>>, <class '<a href="../expressions.html#ApproxDistinct">sqlglot.expressions.ApproxDistinct</a>'>: <function approx_count_distinct_sql>, <class '<a href="../expressions.html#Array">sqlglot.expressions.Array</a>'>: <function inline_array_unless_query>, <class '<a href="../expressions.html#ArrayContainsAll">sqlglot.expressions.ArrayContainsAll</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#ArrayFilter">sqlglot.expressions.ArrayFilter</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#ArraySize">sqlglot.expressions.ArraySize</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#ArgMax">sqlglot.expressions.ArgMax</a>'>: <function arg_max_or_min_no_count.<locals>._arg_max_or_min_sql>, <class '<a href="../expressions.html#ArgMin">sqlglot.expressions.ArgMin</a>'>: <function arg_max_or_min_no_count.<locals>._arg_max_or_min_sql>, <class '<a href="../expressions.html#ArraySort">sqlglot.expressions.ArraySort</a>'>: <function _array_sort_sql>, <class '<a href="../expressions.html#ArraySum">sqlglot.expressions.ArraySum</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#BitwiseXor">sqlglot.expressions.BitwiseXor</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#CurrentDate">sqlglot.expressions.CurrentDate</a>'>: <function <a href="#DuckDB.Generator">DuckDB.Generator</a>.<lambda>>, <class '<a href="../expressions.html#CurrentTime">sqlglot.expressions.CurrentTime</a>'>: <function <a href="#DuckDB.Generator">DuckDB.Generator</a>.<lambda>>, <class '<a href="../expressions.html#CurrentTimestamp">sqlglot.expressions.CurrentTimestamp</a>'>: <function <a href="#DuckDB.Generator">DuckDB.Generator</a>.<lambda>>, <class '<a href="../expressions.html#DayOfMonth">sqlglot.expressions.DayOfMonth</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#DayOfWeek">sqlglot.expressions.DayOfWeek</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#DayOfYear">sqlglot.expressions.DayOfYear</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#DataType">sqlglot.expressions.DataType</a>'>: <function _datatype_sql>, <class '<a href="../expressions.html#Date">sqlglot.expressions.Date</a>'>: <function _date_sql>, <class '<a href="../expressions.html#DateAdd">sqlglot.expressions.DateAdd</a>'>: <function _date_delta_sql>, <class '<a href="../expressions.html#DateFromParts">sqlglot.expressions.DateFromParts</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#DateSub">sqlglot.expressions.DateSub</a>'>: <function _date_delta_sql>, <class '<a href="../expressions.html#DateDiff">sqlglot.expressions.DateDiff</a>'>: <function <a href="#DuckDB.Generator">DuckDB.Generator</a>.<lambda>>, <class '<a href="../expressions.html#DateStrToDate">sqlglot.expressions.DateStrToDate</a>'>: <function datestrtodate_sql>, <class '<a href="../expressions.html#Datetime">sqlglot.expressions.Datetime</a>'>: <function no_datetime_sql>, <class '<a href="../expressions.html#DatetimeSub">sqlglot.expressions.DatetimeSub</a>'>: <function _date_delta_sql>, <class '<a href="../expressions.html#DatetimeAdd">sqlglot.expressions.DatetimeAdd</a>'>: <function _date_delta_sql>, <class '<a href="../expressions.html#DateToDi">sqlglot.expressions.DateToDi</a>'>: <function <a href="#DuckDB.Generator">DuckDB.Generator</a>.<lambda>>, <class '<a href="../expressions.html#Decode">sqlglot.expressions.Decode</a>'>: <function <a href="#DuckDB.Generator">DuckDB.Generator</a>.<lambda>>, <class '<a href="../expressions.html#DiToDate">sqlglot.expressions.DiToDate</a>'>: <function <a href="#DuckDB.Generator">DuckDB.Generator</a>.<lambda>>, <class '<a href="../expressions.html#Encode">sqlglot.expressions.Encode</a>'>: <function <a href="#DuckDB.Generator">DuckDB.Generator</a>.<lambda>>, <class '<a href="../expressions.html#Explode">sqlglot.expressions.Explode</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#IntDiv">sqlglot.expressions.IntDiv</a>'>: <function <a href="#DuckDB.Generator">DuckDB.Generator</a>.<lambda>>, <class '<a href="../expressions.html#IsInf">sqlglot.expressions.IsInf</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#IsNan">sqlglot.expressions.IsNan</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#JSONExtract">sqlglot.expressions.JSONExtract</a>'>: <function _arrow_json_extract_sql>, <class '<a href="../expressions.html#JSONExtractScalar">sqlglot.expressions.JSONExtractScalar</a>'>: <function _arrow_json_extract_sql>, <class '<a href="../expressions.html#JSONFormat">sqlglot.expressions.JSONFormat</a>'>: <function _json_format_sql>, <class '<a href="../expressions.html#LogicalOr">sqlglot.expressions.LogicalOr</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#LogicalAnd">sqlglot.expressions.LogicalAnd</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#MD5Digest">sqlglot.expressions.MD5Digest</a>'>: <function <a href="#DuckDB.Generator">DuckDB.Generator</a>.<lambda>>, <class '<a href="../expressions.html#MonthsBetween">sqlglot.expressions.MonthsBetween</a>'>: <function <a href="#DuckDB.Generator">DuckDB.Generator</a>.<lambda>>, <class '<a href="../expressions.html#PercentileCont">sqlglot.expressions.PercentileCont</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#PercentileDisc">sqlglot.expressions.PercentileDisc</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#Pivot">sqlglot.expressions.Pivot</a>'>: <function preprocess.<locals>._to_sql>, <class '<a href="../expressions.html#RegexpExtract">sqlglot.expressions.RegexpExtract</a>'>: <function regexp_extract_sql>, <class '<a href="../expressions.html#RegexpReplace">sqlglot.expressions.RegexpReplace</a>'>: <function <a href="#DuckDB.Generator">DuckDB.Generator</a>.<lambda>>, <class '<a href="../expressions.html#RegexpLike">sqlglot.expressions.RegexpLike</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#RegexpSplit">sqlglot.expressions.RegexpSplit</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#Return">sqlglot.expressions.Return</a>'>: <function <a href="#DuckDB.Generator">DuckDB.Generator</a>.<lambda>>, <class '<a href="../expressions.html#Rand">sqlglot.expressions.Rand</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#SafeDivide">sqlglot.expressions.SafeDivide</a>'>: <function no_safe_divide_sql>, <class '<a href="../expressions.html#Split">sqlglot.expressions.Split</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#SortArray">sqlglot.expressions.SortArray</a>'>: <function _sort_array_sql>, <class '<a href="../expressions.html#StrPosition">sqlglot.expressions.StrPosition</a>'>: <function str_position_sql>, <class '<a href="../expressions.html#StrToUnix">sqlglot.expressions.StrToUnix</a>'>: <function <a href="#DuckDB.Generator">DuckDB.Generator</a>.<lambda>>, <class '<a href="../expressions.html#Struct">sqlglot.expressions.Struct</a>'>: <function _struct_sql>, <class '<a href="../expressions.html#TimeAdd">sqlglot.expressions.TimeAdd</a>'>: <function _date_delta_sql>, <class '<a href="../expressions.html#Time">sqlglot.expressions.Time</a>'>: <function no_time_sql>, <class '<a href="../expressions.html#Timestamp">sqlglot.expressions.Timestamp</a>'>: <function no_timestamp_sql>, <class '<a href="../expressions.html#TimestampDiff">sqlglot.expressions.TimestampDiff</a>'>: <function <a href="#DuckDB.Generator">DuckDB.Generator</a>.<lambda>>, <class '<a href="../expressions.html#TimestampTrunc">sqlglot.expressions.TimestampTrunc</a>'>: <function timestamptrunc_sql.<locals>._timestamptrunc_sql>, <class '<a href="../expressions.html#TimeStrToDate">sqlglot.expressions.TimeStrToDate</a>'>: <function <a href="#DuckDB.Generator">DuckDB.Generator</a>.<lambda>>, <class '<a href="../expressions.html#TimeStrToTime">sqlglot.expressions.TimeStrToTime</a>'>: <function timestrtotime_sql>, <class '<a href="../expressions.html#TimeStrToUnix">sqlglot.expressions.TimeStrToUnix</a>'>: <function <a href="#DuckDB.Generator">DuckDB.Generator</a>.<lambda>>, <class '<a href="../expressions.html#TimeToStr">sqlglot.expressions.TimeToStr</a>'>: <function <a href="#DuckDB.Generator">DuckDB.Generator</a>.<lambda>>, <class '<a href="../expressions.html#TimeToUnix">sqlglot.expressions.TimeToUnix</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#TsOrDiToDi">sqlglot.expressions.TsOrDiToDi</a>'>: <function <a href="#DuckDB.Generator">DuckDB.Generator</a>.<lambda>>, <class '<a href="../expressions.html#TsOrDsAdd">sqlglot.expressions.TsOrDsAdd</a>'>: <function _date_delta_sql>, <class '<a href="../expressions.html#TsOrDsDiff">sqlglot.expressions.TsOrDsDiff</a>'>: <function <a href="#DuckDB.Generator">DuckDB.Generator</a>.<lambda>>, <class '<a href="../expressions.html#UnixToStr">sqlglot.expressions.UnixToStr</a>'>: <function <a href="#DuckDB.Generator">DuckDB.Generator</a>.<lambda>>, <class '<a href="../expressions.html#UnixToTime">sqlglot.expressions.UnixToTime</a>'>: <function _unix_to_time_sql>, <class '<a href="../expressions.html#UnixToTimeStr">sqlglot.expressions.UnixToTimeStr</a>'>: <function <a href="#DuckDB.Generator">DuckDB.Generator</a>.<lambda>>, <class '<a href="../expressions.html#VariancePop">sqlglot.expressions.VariancePop</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#WeekOfYear">sqlglot.expressions.WeekOfYear</a>'>: <function rename_func.<locals>.<lambda>>, <class '<a href="../expressions.html#Xor">sqlglot.expressions.Xor</a>'>: <function bool_xor_sql>}</span> </div> @@ -3694,7 +3715,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#JSONPathWildcard">sqlglot.expressions.JSONPathWildcard</a>'>, <class '<a href="../expressions.html#JSONPathKey">sqlglot.expressions.JSONPathKey</a>'>, <class '<a href="../expressions.html#JSONPathSubscript">sqlglot.expressions.JSONPathSubscript</a>'>, <class '<a href="../expressions.html#JSONPathRoot">sqlglot.expressions.JSONPathRoot</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> @@ -3720,7 +3741,7 @@ Default: True</li> <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">{'select', 'foreign', 'using', 'lateral_p', 'trailing', 'analyse', 'analyze', 'end_p', 'and', 'returning', 'both', 'except', 'into', 'or', 'having', 'current_timestamp', 'references', 'offset', 'as', 'true_p', 'some', 'where', 'symmetric', 'session_user', 'default', 'constraint', 'do', 'group_p', 'else', 'asymmetric', 'check_p', 'unique', 'distinct', 'then', 'current_catalog', 'case', 'order', 'desc_p', 'leading', 'current_time', 'initially', 'create_p', 'grant', 'intersect', 'to', 'asc_p', 'all', 'when', 'for', 'only', 'on', 'current_date', 'cast', 'limit', 'window', 'false_p', 'any', 'deferrable', 'primary', 'array', 'table', 'current_user', 'union', 'in_p', 'not', 'placing', 'collate', 'user', 'localtime', 'with', 'current_role', 'variadic', 'localtimestamp', 'fetch', 'from', 'null_p', 'column'}</span> + <label class="view-value-button pdoc-button" for="DuckDB.Generator.RESERVED_KEYWORDS-view-value"></label><span class="default_value">{'references', 'grant', 'to', 'check_p', 'current_date', 'variadic', 'from', 'user', 'localtime', 'order', 'current_time', 'true_p', 'select', 'as', 'except', 'asymmetric', 'group_p', 'do', 'offset', 'unique', 'deferrable', 'else', 'create_p', 'primary', 'limit', 'when', 'case', 'default', 'current_catalog', 'column', 'not', 'localtimestamp', 'null_p', 'current_role', 'symmetric', 'trailing', 'analyse', 'only', 'foreign', 'both', 'using', 'collate', 'in_p', 'intersect', 'analyze', 'false_p', 'window', 'leading', 'all', 'into', 'for', 'desc_p', 'having', 'and', 'constraint', 'returning', 'asc_p', 'current_user', 'distinct', 'lateral_p', 'or', 'initially', 'on', 'placing', 'union', 'table', 'array', 'fetch', 'with', 'cast', 'end_p', 'current_timestamp', 'some', 'any', 'where', 'session_user', 'then'}</span> </div> @@ -3765,11 +3786,11 @@ Default: True</li> </div> <a class="headerlink" href="#DuckDB.Generator.strtotime_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DuckDB.Generator.strtotime_sql-648"><a href="#DuckDB.Generator.strtotime_sql-648"><span class="linenos">648</span></a> <span class="k">def</span> <span class="nf">strtotime_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">StrToTime</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="DuckDB.Generator.strtotime_sql-649"><a href="#DuckDB.Generator.strtotime_sql-649"><span class="linenos">649</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">"safe"</span><span class="p">):</span> -</span><span id="DuckDB.Generator.strtotime_sql-650"><a href="#DuckDB.Generator.strtotime_sql-650"><span class="linenos">650</span></a> <span class="n">formatted_time</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="DuckDB.Generator.strtotime_sql-651"><a href="#DuckDB.Generator.strtotime_sql-651"><span class="linenos">651</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CAST(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s1">'TRY_STRPTIME'</span><span class="p">,</span><span class="w"> </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">formatted_time</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS TIMESTAMP)"</span> -</span><span id="DuckDB.Generator.strtotime_sql-652"><a href="#DuckDB.Generator.strtotime_sql-652"><span class="linenos">652</span></a> <span class="k">return</span> <span class="n">str_to_time_sql</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.strtotime_sql-654"><a href="#DuckDB.Generator.strtotime_sql-654"><span class="linenos">654</span></a> <span class="k">def</span> <span class="nf">strtotime_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">StrToTime</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="DuckDB.Generator.strtotime_sql-655"><a href="#DuckDB.Generator.strtotime_sql-655"><span class="linenos">655</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">"safe"</span><span class="p">):</span> +</span><span id="DuckDB.Generator.strtotime_sql-656"><a href="#DuckDB.Generator.strtotime_sql-656"><span class="linenos">656</span></a> <span class="n">formatted_time</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="DuckDB.Generator.strtotime_sql-657"><a href="#DuckDB.Generator.strtotime_sql-657"><span class="linenos">657</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CAST(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s1">'TRY_STRPTIME'</span><span class="p">,</span><span class="w"> </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">formatted_time</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS TIMESTAMP)"</span> +</span><span id="DuckDB.Generator.strtotime_sql-658"><a href="#DuckDB.Generator.strtotime_sql-658"><span class="linenos">658</span></a> <span class="k">return</span> <span class="n">str_to_time_sql</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> @@ -3787,11 +3808,11 @@ Default: True</li> </div> <a class="headerlink" href="#DuckDB.Generator.strtodate_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DuckDB.Generator.strtodate_sql-654"><a href="#DuckDB.Generator.strtodate_sql-654"><span class="linenos">654</span></a> <span class="k">def</span> <span class="nf">strtodate_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">StrToDate</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="DuckDB.Generator.strtodate_sql-655"><a href="#DuckDB.Generator.strtodate_sql-655"><span class="linenos">655</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">"safe"</span><span class="p">):</span> -</span><span id="DuckDB.Generator.strtodate_sql-656"><a href="#DuckDB.Generator.strtodate_sql-656"><span class="linenos">656</span></a> <span class="n">formatted_time</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="DuckDB.Generator.strtodate_sql-657"><a href="#DuckDB.Generator.strtodate_sql-657"><span class="linenos">657</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CAST(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s1">'TRY_STRPTIME'</span><span class="p">,</span><span class="w"> </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">formatted_time</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS DATE)"</span> -</span><span id="DuckDB.Generator.strtodate_sql-658"><a href="#DuckDB.Generator.strtodate_sql-658"><span class="linenos">658</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CAST(</span><span class="si">{</span><span class="n">str_to_time_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="w"> </span><span class="n">expression</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS DATE)"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DuckDB.Generator.strtodate_sql-660"><a href="#DuckDB.Generator.strtodate_sql-660"><span class="linenos">660</span></a> <span class="k">def</span> <span class="nf">strtodate_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">StrToDate</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="DuckDB.Generator.strtodate_sql-661"><a href="#DuckDB.Generator.strtodate_sql-661"><span class="linenos">661</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">"safe"</span><span class="p">):</span> +</span><span id="DuckDB.Generator.strtodate_sql-662"><a href="#DuckDB.Generator.strtodate_sql-662"><span class="linenos">662</span></a> <span class="n">formatted_time</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="DuckDB.Generator.strtodate_sql-663"><a href="#DuckDB.Generator.strtodate_sql-663"><span class="linenos">663</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CAST(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s1">'TRY_STRPTIME'</span><span class="p">,</span><span class="w"> </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">formatted_time</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS DATE)"</span> +</span><span id="DuckDB.Generator.strtodate_sql-664"><a href="#DuckDB.Generator.strtodate_sql-664"><span class="linenos">664</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CAST(</span><span class="si">{</span><span class="n">str_to_time_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="w"> </span><span class="n">expression</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS DATE)"</span> </span></pre></div> @@ -3809,11 +3830,11 @@ Default: True</li> </div> <a class="headerlink" href="#DuckDB.Generator.parsejson_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DuckDB.Generator.parsejson_sql-660"><a href="#DuckDB.Generator.parsejson_sql-660"><span class="linenos">660</span></a> <span class="k">def</span> <span class="nf">parsejson_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ParseJSON</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="DuckDB.Generator.parsejson_sql-661"><a href="#DuckDB.Generator.parsejson_sql-661"><span class="linenos">661</span></a> <span class="n">arg</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> -</span><span id="DuckDB.Generator.parsejson_sql-662"><a href="#DuckDB.Generator.parsejson_sql-662"><span class="linenos">662</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">"safe"</span><span class="p">):</span> -</span><span id="DuckDB.Generator.parsejson_sql-663"><a href="#DuckDB.Generator.parsejson_sql-663"><span class="linenos">663</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">case</span><span class="p">()</span><span class="o">.</span><span class="n">when</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"json_valid"</span><span class="p">,</span> <span class="n">arg</span><span class="p">),</span> <span class="n">arg</span><span class="p">)</span><span class="o">.</span><span class="n">else_</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">null</span><span class="p">()))</span> -</span><span id="DuckDB.Generator.parsejson_sql-664"><a href="#DuckDB.Generator.parsejson_sql-664"><span class="linenos">664</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"JSON"</span><span class="p">,</span> <span class="n">arg</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DuckDB.Generator.parsejson_sql-666"><a href="#DuckDB.Generator.parsejson_sql-666"><span class="linenos">666</span></a> <span class="k">def</span> <span class="nf">parsejson_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ParseJSON</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="DuckDB.Generator.parsejson_sql-667"><a href="#DuckDB.Generator.parsejson_sql-667"><span class="linenos">667</span></a> <span class="n">arg</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> +</span><span id="DuckDB.Generator.parsejson_sql-668"><a href="#DuckDB.Generator.parsejson_sql-668"><span class="linenos">668</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">"safe"</span><span class="p">):</span> +</span><span id="DuckDB.Generator.parsejson_sql-669"><a href="#DuckDB.Generator.parsejson_sql-669"><span class="linenos">669</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">case</span><span class="p">()</span><span class="o">.</span><span class="n">when</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"json_valid"</span><span class="p">,</span> <span class="n">arg</span><span class="p">),</span> <span class="n">arg</span><span class="p">)</span><span class="o">.</span><span class="n">else_</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">null</span><span class="p">()))</span> +</span><span id="DuckDB.Generator.parsejson_sql-670"><a href="#DuckDB.Generator.parsejson_sql-670"><span class="linenos">670</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"JSON"</span><span class="p">,</span> <span class="n">arg</span><span class="p">)</span> </span></pre></div> @@ -3831,14 +3852,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-666"><a href="#DuckDB.Generator.timefromparts_sql-666"><span class="linenos">666</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-667"><a href="#DuckDB.Generator.timefromparts_sql-667"><span class="linenos">667</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-668"><a href="#DuckDB.Generator.timefromparts_sql-668"><span class="linenos">668</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-669"><a href="#DuckDB.Generator.timefromparts_sql-669"><span class="linenos">669</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-670"><a href="#DuckDB.Generator.timefromparts_sql-670"><span class="linenos">670</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-671"><a href="#DuckDB.Generator.timefromparts_sql-671"><span class="linenos">671</span></a> <span class="p">)</span> -</span><span id="DuckDB.Generator.timefromparts_sql-672"><a href="#DuckDB.Generator.timefromparts_sql-672"><span class="linenos">672</span></a> -</span><span id="DuckDB.Generator.timefromparts_sql-673"><a href="#DuckDB.Generator.timefromparts_sql-673"><span class="linenos">673</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-672"><a href="#DuckDB.Generator.timefromparts_sql-672"><span class="linenos">672</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-673"><a href="#DuckDB.Generator.timefromparts_sql-673"><span class="linenos">673</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-674"><a href="#DuckDB.Generator.timefromparts_sql-674"><span class="linenos">674</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-675"><a href="#DuckDB.Generator.timefromparts_sql-675"><span class="linenos">675</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-676"><a href="#DuckDB.Generator.timefromparts_sql-676"><span class="linenos">676</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-677"><a href="#DuckDB.Generator.timefromparts_sql-677"><span class="linenos">677</span></a> <span class="p">)</span> +</span><span id="DuckDB.Generator.timefromparts_sql-678"><a href="#DuckDB.Generator.timefromparts_sql-678"><span class="linenos">678</span></a> +</span><span id="DuckDB.Generator.timefromparts_sql-679"><a href="#DuckDB.Generator.timefromparts_sql-679"><span class="linenos">679</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> @@ -3856,21 +3877,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-675"><a href="#DuckDB.Generator.timestampfromparts_sql-675"><span class="linenos">675</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-676"><a href="#DuckDB.Generator.timestampfromparts_sql-676"><span class="linenos">676</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-677"><a href="#DuckDB.Generator.timestampfromparts_sql-677"><span class="linenos">677</span></a> -</span><span id="DuckDB.Generator.timestampfromparts_sql-678"><a href="#DuckDB.Generator.timestampfromparts_sql-678"><span class="linenos">678</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-679"><a href="#DuckDB.Generator.timestampfromparts_sql-679"><span class="linenos">679</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-680"><a href="#DuckDB.Generator.timestampfromparts_sql-680"><span class="linenos">680</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-681"><a href="#DuckDB.Generator.timestampfromparts_sql-681"><span class="linenos">681</span></a> -</span><span id="DuckDB.Generator.timestampfromparts_sql-682"><a href="#DuckDB.Generator.timestampfromparts_sql-682"><span class="linenos">682</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-683"><a href="#DuckDB.Generator.timestampfromparts_sql-683"><span class="linenos">683</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-684"><a href="#DuckDB.Generator.timestampfromparts_sql-684"><span class="linenos">684</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-685"><a href="#DuckDB.Generator.timestampfromparts_sql-685"><span class="linenos">685</span></a> -</span><span id="DuckDB.Generator.timestampfromparts_sql-686"><a href="#DuckDB.Generator.timestampfromparts_sql-686"><span class="linenos">686</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-687"><a href="#DuckDB.Generator.timestampfromparts_sql-687"><span class="linenos">687</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-688"><a href="#DuckDB.Generator.timestampfromparts_sql-688"><span class="linenos">688</span></a> -</span><span id="DuckDB.Generator.timestampfromparts_sql-689"><a href="#DuckDB.Generator.timestampfromparts_sql-689"><span class="linenos">689</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-681"><a href="#DuckDB.Generator.timestampfromparts_sql-681"><span class="linenos">681</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-682"><a href="#DuckDB.Generator.timestampfromparts_sql-682"><span class="linenos">682</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-683"><a href="#DuckDB.Generator.timestampfromparts_sql-683"><span class="linenos">683</span></a> +</span><span id="DuckDB.Generator.timestampfromparts_sql-684"><a href="#DuckDB.Generator.timestampfromparts_sql-684"><span class="linenos">684</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-685"><a href="#DuckDB.Generator.timestampfromparts_sql-685"><span class="linenos">685</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-686"><a href="#DuckDB.Generator.timestampfromparts_sql-686"><span class="linenos">686</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-687"><a href="#DuckDB.Generator.timestampfromparts_sql-687"><span class="linenos">687</span></a> +</span><span id="DuckDB.Generator.timestampfromparts_sql-688"><a href="#DuckDB.Generator.timestampfromparts_sql-688"><span class="linenos">688</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-689"><a href="#DuckDB.Generator.timestampfromparts_sql-689"><span class="linenos">689</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-690"><a href="#DuckDB.Generator.timestampfromparts_sql-690"><span class="linenos">690</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-691"><a href="#DuckDB.Generator.timestampfromparts_sql-691"><span class="linenos">691</span></a> +</span><span id="DuckDB.Generator.timestampfromparts_sql-692"><a href="#DuckDB.Generator.timestampfromparts_sql-692"><span class="linenos">692</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-693"><a href="#DuckDB.Generator.timestampfromparts_sql-693"><span class="linenos">693</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-694"><a href="#DuckDB.Generator.timestampfromparts_sql-694"><span class="linenos">694</span></a> +</span><span id="DuckDB.Generator.timestampfromparts_sql-695"><a href="#DuckDB.Generator.timestampfromparts_sql-695"><span class="linenos">695</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> @@ -3888,28 +3909,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-691"><a href="#DuckDB.Generator.tablesample_sql-691"><span class="linenos">691</span></a> <span class="k">def</span> <span class="nf">tablesample_sql</span><span class="p">(</span> -</span><span id="DuckDB.Generator.tablesample_sql-692"><a href="#DuckDB.Generator.tablesample_sql-692"><span class="linenos">692</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="DuckDB.Generator.tablesample_sql-693"><a href="#DuckDB.Generator.tablesample_sql-693"><span class="linenos">693</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-694"><a href="#DuckDB.Generator.tablesample_sql-694"><span class="linenos">694</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-695"><a href="#DuckDB.Generator.tablesample_sql-695"><span class="linenos">695</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-696"><a href="#DuckDB.Generator.tablesample_sql-696"><span class="linenos">696</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-697"><a href="#DuckDB.Generator.tablesample_sql-697"><span class="linenos">697</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-698"><a href="#DuckDB.Generator.tablesample_sql-698"><span class="linenos">698</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-699"><a href="#DuckDB.Generator.tablesample_sql-699"><span class="linenos">699</span></a> <span class="n">tablesample_keyword</span> <span class="o">=</span> <span class="s2">"TABLESAMPLE"</span> -</span><span id="DuckDB.Generator.tablesample_sql-700"><a href="#DuckDB.Generator.tablesample_sql-700"><span class="linenos">700</span></a> -</span><span id="DuckDB.Generator.tablesample_sql-701"><a href="#DuckDB.Generator.tablesample_sql-701"><span class="linenos">701</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-702"><a href="#DuckDB.Generator.tablesample_sql-702"><span class="linenos">702</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-703"><a href="#DuckDB.Generator.tablesample_sql-703"><span class="linenos">703</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-704"><a href="#DuckDB.Generator.tablesample_sql-704"><span class="linenos">704</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-705"><a href="#DuckDB.Generator.tablesample_sql-705"><span class="linenos">705</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-706"><a href="#DuckDB.Generator.tablesample_sql-706"><span class="linenos">706</span></a> <span class="s2">"defaulting to reservoir sampling"</span> -</span><span id="DuckDB.Generator.tablesample_sql-707"><a href="#DuckDB.Generator.tablesample_sql-707"><span class="linenos">707</span></a> <span class="p">)</span> -</span><span id="DuckDB.Generator.tablesample_sql-708"><a href="#DuckDB.Generator.tablesample_sql-708"><span class="linenos">708</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-709"><a href="#DuckDB.Generator.tablesample_sql-709"><span class="linenos">709</span></a> -</span><span id="DuckDB.Generator.tablesample_sql-710"><a href="#DuckDB.Generator.tablesample_sql-710"><span class="linenos">710</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-711"><a href="#DuckDB.Generator.tablesample_sql-711"><span class="linenos">711</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-712"><a href="#DuckDB.Generator.tablesample_sql-712"><span class="linenos">712</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DuckDB.Generator.tablesample_sql-697"><a href="#DuckDB.Generator.tablesample_sql-697"><span class="linenos">697</span></a> <span class="k">def</span> <span class="nf">tablesample_sql</span><span class="p">(</span> +</span><span id="DuckDB.Generator.tablesample_sql-698"><a href="#DuckDB.Generator.tablesample_sql-698"><span class="linenos">698</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="DuckDB.Generator.tablesample_sql-699"><a href="#DuckDB.Generator.tablesample_sql-699"><span class="linenos">699</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-700"><a href="#DuckDB.Generator.tablesample_sql-700"><span class="linenos">700</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-701"><a href="#DuckDB.Generator.tablesample_sql-701"><span class="linenos">701</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-702"><a href="#DuckDB.Generator.tablesample_sql-702"><span class="linenos">702</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-703"><a href="#DuckDB.Generator.tablesample_sql-703"><span class="linenos">703</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-704"><a href="#DuckDB.Generator.tablesample_sql-704"><span class="linenos">704</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-705"><a href="#DuckDB.Generator.tablesample_sql-705"><span class="linenos">705</span></a> <span class="n">tablesample_keyword</span> <span class="o">=</span> <span class="s2">"TABLESAMPLE"</span> +</span><span id="DuckDB.Generator.tablesample_sql-706"><a href="#DuckDB.Generator.tablesample_sql-706"><span class="linenos">706</span></a> +</span><span id="DuckDB.Generator.tablesample_sql-707"><a href="#DuckDB.Generator.tablesample_sql-707"><span class="linenos">707</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-708"><a href="#DuckDB.Generator.tablesample_sql-708"><span class="linenos">708</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-709"><a href="#DuckDB.Generator.tablesample_sql-709"><span class="linenos">709</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-710"><a href="#DuckDB.Generator.tablesample_sql-710"><span class="linenos">710</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-711"><a href="#DuckDB.Generator.tablesample_sql-711"><span class="linenos">711</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-712"><a href="#DuckDB.Generator.tablesample_sql-712"><span class="linenos">712</span></a> <span class="s2">"defaulting to reservoir sampling"</span> +</span><span id="DuckDB.Generator.tablesample_sql-713"><a href="#DuckDB.Generator.tablesample_sql-713"><span class="linenos">713</span></a> <span class="p">)</span> +</span><span id="DuckDB.Generator.tablesample_sql-714"><a href="#DuckDB.Generator.tablesample_sql-714"><span class="linenos">714</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-715"><a href="#DuckDB.Generator.tablesample_sql-715"><span class="linenos">715</span></a> +</span><span id="DuckDB.Generator.tablesample_sql-716"><a href="#DuckDB.Generator.tablesample_sql-716"><span class="linenos">716</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-717"><a href="#DuckDB.Generator.tablesample_sql-717"><span class="linenos">717</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-718"><a href="#DuckDB.Generator.tablesample_sql-718"><span class="linenos">718</span></a> <span class="p">)</span> </span></pre></div> @@ -3927,19 +3948,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-714"><a href="#DuckDB.Generator.interval_sql-714"><span class="linenos">714</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-715"><a href="#DuckDB.Generator.interval_sql-715"><span class="linenos">715</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-716"><a href="#DuckDB.Generator.interval_sql-716"><span class="linenos">716</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-717"><a href="#DuckDB.Generator.interval_sql-717"><span class="linenos">717</span></a> -</span><span id="DuckDB.Generator.interval_sql-718"><a href="#DuckDB.Generator.interval_sql-718"><span class="linenos">718</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-719"><a href="#DuckDB.Generator.interval_sql-719"><span class="linenos">719</span></a> <span class="n">multiplier</span> <span class="o">=</span> <span class="mi">7</span> -</span><span id="DuckDB.Generator.interval_sql-720"><a href="#DuckDB.Generator.interval_sql-720"><span class="linenos">720</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-721"><a href="#DuckDB.Generator.interval_sql-721"><span class="linenos">721</span></a> <span class="n">multiplier</span> <span class="o">=</span> <span class="mi">90</span> -</span><span id="DuckDB.Generator.interval_sql-722"><a href="#DuckDB.Generator.interval_sql-722"><span class="linenos">722</span></a> -</span><span id="DuckDB.Generator.interval_sql-723"><a href="#DuckDB.Generator.interval_sql-723"><span class="linenos">723</span></a> <span class="k">if</span> <span class="n">multiplier</span><span class="p">:</span> -</span><span id="DuckDB.Generator.interval_sql-724"><a href="#DuckDB.Generator.interval_sql-724"><span class="linenos">724</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-725"><a href="#DuckDB.Generator.interval_sql-725"><span class="linenos">725</span></a> -</span><span id="DuckDB.Generator.interval_sql-726"><a href="#DuckDB.Generator.interval_sql-726"><span class="linenos">726</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-720"><a href="#DuckDB.Generator.interval_sql-720"><span class="linenos">720</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-721"><a href="#DuckDB.Generator.interval_sql-721"><span class="linenos">721</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-722"><a href="#DuckDB.Generator.interval_sql-722"><span class="linenos">722</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-723"><a href="#DuckDB.Generator.interval_sql-723"><span class="linenos">723</span></a> +</span><span id="DuckDB.Generator.interval_sql-724"><a href="#DuckDB.Generator.interval_sql-724"><span class="linenos">724</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-725"><a href="#DuckDB.Generator.interval_sql-725"><span class="linenos">725</span></a> <span class="n">multiplier</span> <span class="o">=</span> <span class="mi">7</span> +</span><span id="DuckDB.Generator.interval_sql-726"><a href="#DuckDB.Generator.interval_sql-726"><span class="linenos">726</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-727"><a href="#DuckDB.Generator.interval_sql-727"><span class="linenos">727</span></a> <span class="n">multiplier</span> <span class="o">=</span> <span class="mi">90</span> +</span><span id="DuckDB.Generator.interval_sql-728"><a href="#DuckDB.Generator.interval_sql-728"><span class="linenos">728</span></a> +</span><span id="DuckDB.Generator.interval_sql-729"><a href="#DuckDB.Generator.interval_sql-729"><span class="linenos">729</span></a> <span class="k">if</span> <span class="n">multiplier</span><span class="p">:</span> +</span><span id="DuckDB.Generator.interval_sql-730"><a href="#DuckDB.Generator.interval_sql-730"><span class="linenos">730</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-731"><a href="#DuckDB.Generator.interval_sql-731"><span class="linenos">731</span></a> +</span><span id="DuckDB.Generator.interval_sql-732"><a href="#DuckDB.Generator.interval_sql-732"><span class="linenos">732</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> @@ -3957,10 +3978,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-728"><a href="#DuckDB.Generator.columndef_sql-728"><span class="linenos">728</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-729"><a href="#DuckDB.Generator.columndef_sql-729"><span class="linenos">729</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-730"><a href="#DuckDB.Generator.columndef_sql-730"><span class="linenos">730</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-731"><a href="#DuckDB.Generator.columndef_sql-731"><span class="linenos">731</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-734"><a href="#DuckDB.Generator.columndef_sql-734"><span class="linenos">734</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-735"><a href="#DuckDB.Generator.columndef_sql-735"><span class="linenos">735</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-736"><a href="#DuckDB.Generator.columndef_sql-736"><span class="linenos">736</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-737"><a href="#DuckDB.Generator.columndef_sql-737"><span class="linenos">737</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> @@ -3978,17 +3999,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-733"><a href="#DuckDB.Generator.join_sql-733"><span class="linenos">733</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-734"><a href="#DuckDB.Generator.join_sql-734"><span class="linenos">734</span></a> <span class="k">if</span> <span class="p">(</span> -</span><span id="DuckDB.Generator.join_sql-735"><a href="#DuckDB.Generator.join_sql-735"><span class="linenos">735</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-736"><a href="#DuckDB.Generator.join_sql-736"><span class="linenos">736</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-737"><a href="#DuckDB.Generator.join_sql-737"><span class="linenos">737</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-738"><a href="#DuckDB.Generator.join_sql-738"><span class="linenos">738</span></a> <span class="p">):</span> -</span><span id="DuckDB.Generator.join_sql-739"><a href="#DuckDB.Generator.join_sql-739"><span class="linenos">739</span></a> <span class="c1"># Some dialects support `LEFT JOIN UNNEST(...)` without an explicit ON clause</span> -</span><span id="DuckDB.Generator.join_sql-740"><a href="#DuckDB.Generator.join_sql-740"><span class="linenos">740</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-741"><a href="#DuckDB.Generator.join_sql-741"><span class="linenos">741</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-742"><a href="#DuckDB.Generator.join_sql-742"><span class="linenos">742</span></a> -</span><span id="DuckDB.Generator.join_sql-743"><a href="#DuckDB.Generator.join_sql-743"><span class="linenos">743</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-739"><a href="#DuckDB.Generator.join_sql-739"><span class="linenos">739</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-740"><a href="#DuckDB.Generator.join_sql-740"><span class="linenos">740</span></a> <span class="k">if</span> <span class="p">(</span> +</span><span id="DuckDB.Generator.join_sql-741"><a href="#DuckDB.Generator.join_sql-741"><span class="linenos">741</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-742"><a href="#DuckDB.Generator.join_sql-742"><span class="linenos">742</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-743"><a href="#DuckDB.Generator.join_sql-743"><span class="linenos">743</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-744"><a href="#DuckDB.Generator.join_sql-744"><span class="linenos">744</span></a> <span class="p">):</span> +</span><span id="DuckDB.Generator.join_sql-745"><a href="#DuckDB.Generator.join_sql-745"><span class="linenos">745</span></a> <span class="c1"># Some dialects support `LEFT JOIN UNNEST(...)` without an explicit ON clause</span> +</span><span id="DuckDB.Generator.join_sql-746"><a href="#DuckDB.Generator.join_sql-746"><span class="linenos">746</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-747"><a href="#DuckDB.Generator.join_sql-747"><span class="linenos">747</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-748"><a href="#DuckDB.Generator.join_sql-748"><span class="linenos">748</span></a> +</span><span id="DuckDB.Generator.join_sql-749"><a href="#DuckDB.Generator.join_sql-749"><span class="linenos">749</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> @@ -4006,13 +4027,12 @@ 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-745"><a href="#DuckDB.Generator.generateseries_sql-745"><span class="linenos">745</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-746"><a href="#DuckDB.Generator.generateseries_sql-746"><span class="linenos">746</span></a> <span class="c1"># GENERATE_SERIES(a, b) -> [a, b], RANGE(a, b) -> [a, b)</span> -</span><span id="DuckDB.Generator.generateseries_sql-747"><a href="#DuckDB.Generator.generateseries_sql-747"><span class="linenos">747</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-748"><a href="#DuckDB.Generator.generateseries_sql-748"><span class="linenos">748</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-749"><a href="#DuckDB.Generator.generateseries_sql-749"><span class="linenos">749</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-750"><a href="#DuckDB.Generator.generateseries_sql-750"><span class="linenos">750</span></a> -</span><span id="DuckDB.Generator.generateseries_sql-751"><a href="#DuckDB.Generator.generateseries_sql-751"><span class="linenos">751</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-751"><a href="#DuckDB.Generator.generateseries_sql-751"><span class="linenos">751</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-752"><a href="#DuckDB.Generator.generateseries_sql-752"><span class="linenos">752</span></a> <span class="c1"># GENERATE_SERIES(a, b) -> [a, b], RANGE(a, b) -> [a, b)</span> +</span><span id="DuckDB.Generator.generateseries_sql-753"><a href="#DuckDB.Generator.generateseries_sql-753"><span class="linenos">753</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-754"><a href="#DuckDB.Generator.generateseries_sql-754"><span class="linenos">754</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-755"><a href="#DuckDB.Generator.generateseries_sql-755"><span class="linenos">755</span></a> +</span><span id="DuckDB.Generator.generateseries_sql-756"><a href="#DuckDB.Generator.generateseries_sql-756"><span class="linenos">756</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">function_fallback_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> </span></pre></div> @@ -4030,23 +4050,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-753"><a href="#DuckDB.Generator.bracket_sql-753"><span class="linenos">753</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-754"><a href="#DuckDB.Generator.bracket_sql-754"><span class="linenos">754</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-755"><a href="#DuckDB.Generator.bracket_sql-755"><span class="linenos">755</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-756"><a href="#DuckDB.Generator.bracket_sql-756"><span class="linenos">756</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-757"><a href="#DuckDB.Generator.bracket_sql-757"><span class="linenos">757</span></a> -</span><span id="DuckDB.Generator.bracket_sql-758"><a href="#DuckDB.Generator.bracket_sql-758"><span class="linenos">758</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-759"><a href="#DuckDB.Generator.bracket_sql-759"><span class="linenos">759</span></a> -</span><span id="DuckDB.Generator.bracket_sql-760"><a href="#DuckDB.Generator.bracket_sql-760"><span class="linenos">760</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-761"><a href="#DuckDB.Generator.bracket_sql-761"><span class="linenos">761</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-762"><a href="#DuckDB.Generator.bracket_sql-762"><span class="linenos">762</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-763"><a href="#DuckDB.Generator.bracket_sql-763"><span class="linenos">763</span></a> -</span><span id="DuckDB.Generator.bracket_sql-764"><a href="#DuckDB.Generator.bracket_sql-764"><span class="linenos">764</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-765"><a href="#DuckDB.Generator.bracket_sql-765"><span class="linenos">765</span></a> -</span><span id="DuckDB.Generator.bracket_sql-766"><a href="#DuckDB.Generator.bracket_sql-766"><span class="linenos">766</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-767"><a href="#DuckDB.Generator.bracket_sql-767"><span class="linenos">767</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> + <div class="pdoc-code codehilite"><pre><span></span><span id="DuckDB.Generator.bracket_sql-758"><a href="#DuckDB.Generator.bracket_sql-758"><span class="linenos">758</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-759"><a href="#DuckDB.Generator.bracket_sql-759"><span class="linenos">759</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-760"><a href="#DuckDB.Generator.bracket_sql-760"><span class="linenos">760</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-761"><a href="#DuckDB.Generator.bracket_sql-761"><span class="linenos">761</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-762"><a href="#DuckDB.Generator.bracket_sql-762"><span class="linenos">762</span></a> +</span><span id="DuckDB.Generator.bracket_sql-763"><a href="#DuckDB.Generator.bracket_sql-763"><span class="linenos">763</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-764"><a href="#DuckDB.Generator.bracket_sql-764"><span class="linenos">764</span></a> +</span><span id="DuckDB.Generator.bracket_sql-765"><a href="#DuckDB.Generator.bracket_sql-765"><span class="linenos">765</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-766"><a href="#DuckDB.Generator.bracket_sql-766"><span class="linenos">766</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-767"><a href="#DuckDB.Generator.bracket_sql-767"><span class="linenos">767</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-768"><a href="#DuckDB.Generator.bracket_sql-768"><span class="linenos">768</span></a> -</span><span id="DuckDB.Generator.bracket_sql-769"><a href="#DuckDB.Generator.bracket_sql-769"><span class="linenos">769</span></a> <span class="k">return</span> <span class="n">bracket</span> +</span><span id="DuckDB.Generator.bracket_sql-769"><a href="#DuckDB.Generator.bracket_sql-769"><span class="linenos">769</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-770"><a href="#DuckDB.Generator.bracket_sql-770"><span class="linenos">770</span></a> +</span><span id="DuckDB.Generator.bracket_sql-771"><a href="#DuckDB.Generator.bracket_sql-771"><span class="linenos">771</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-772"><a href="#DuckDB.Generator.bracket_sql-772"><span class="linenos">772</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-773"><a href="#DuckDB.Generator.bracket_sql-773"><span class="linenos">773</span></a> +</span><span id="DuckDB.Generator.bracket_sql-774"><a href="#DuckDB.Generator.bracket_sql-774"><span class="linenos">774</span></a> <span class="k">return</span> <span class="n">bracket</span> </span></pre></div> @@ -4064,21 +4084,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-771"><a href="#DuckDB.Generator.withingroup_sql-771"><span class="linenos">771</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-772"><a href="#DuckDB.Generator.withingroup_sql-772"><span class="linenos">772</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-773"><a href="#DuckDB.Generator.withingroup_sql-773"><span class="linenos">773</span></a> -</span><span id="DuckDB.Generator.withingroup_sql-774"><a href="#DuckDB.Generator.withingroup_sql-774"><span class="linenos">774</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-775"><a href="#DuckDB.Generator.withingroup_sql-775"><span class="linenos">775</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-776"><a href="#DuckDB.Generator.withingroup_sql-776"><span class="linenos">776</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-777"><a href="#DuckDB.Generator.withingroup_sql-777"><span class="linenos">777</span></a> <span class="c1"># https://duckdb.org/docs/sql/aggregates#ordered-set-aggregate-functions</span> -</span><span id="DuckDB.Generator.withingroup_sql-778"><a href="#DuckDB.Generator.withingroup_sql-778"><span class="linenos">778</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-779"><a href="#DuckDB.Generator.withingroup_sql-779"><span class="linenos">779</span></a> <span class="k">if</span> <span class="n">order_col</span><span class="p">:</span> -</span><span id="DuckDB.Generator.withingroup_sql-780"><a href="#DuckDB.Generator.withingroup_sql-780"><span class="linenos">780</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-781"><a href="#DuckDB.Generator.withingroup_sql-781"><span class="linenos">781</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-782"><a href="#DuckDB.Generator.withingroup_sql-782"><span class="linenos">782</span></a> -</span><span id="DuckDB.Generator.withingroup_sql-783"><a href="#DuckDB.Generator.withingroup_sql-783"><span class="linenos">783</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</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-784"><a href="#DuckDB.Generator.withingroup_sql-784"><span class="linenos">784</span></a> -</span><span id="DuckDB.Generator.withingroup_sql-785"><a href="#DuckDB.Generator.withingroup_sql-785"><span class="linenos">785</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-776"><a href="#DuckDB.Generator.withingroup_sql-776"><span class="linenos">776</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-777"><a href="#DuckDB.Generator.withingroup_sql-777"><span class="linenos">777</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-778"><a href="#DuckDB.Generator.withingroup_sql-778"><span class="linenos">778</span></a> +</span><span id="DuckDB.Generator.withingroup_sql-779"><a href="#DuckDB.Generator.withingroup_sql-779"><span class="linenos">779</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-780"><a href="#DuckDB.Generator.withingroup_sql-780"><span class="linenos">780</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-781"><a href="#DuckDB.Generator.withingroup_sql-781"><span class="linenos">781</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-782"><a href="#DuckDB.Generator.withingroup_sql-782"><span class="linenos">782</span></a> <span class="c1"># https://duckdb.org/docs/sql/aggregates#ordered-set-aggregate-functions</span> +</span><span id="DuckDB.Generator.withingroup_sql-783"><a href="#DuckDB.Generator.withingroup_sql-783"><span class="linenos">783</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-784"><a href="#DuckDB.Generator.withingroup_sql-784"><span class="linenos">784</span></a> <span class="k">if</span> <span class="n">order_col</span><span class="p">:</span> +</span><span id="DuckDB.Generator.withingroup_sql-785"><a href="#DuckDB.Generator.withingroup_sql-785"><span class="linenos">785</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-786"><a href="#DuckDB.Generator.withingroup_sql-786"><span class="linenos">786</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-787"><a href="#DuckDB.Generator.withingroup_sql-787"><span class="linenos">787</span></a> +</span><span id="DuckDB.Generator.withingroup_sql-788"><a href="#DuckDB.Generator.withingroup_sql-788"><span class="linenos">788</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</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-789"><a href="#DuckDB.Generator.withingroup_sql-789"><span class="linenos">789</span></a> +</span><span id="DuckDB.Generator.withingroup_sql-790"><a href="#DuckDB.Generator.withingroup_sql-790"><span class="linenos">790</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> @@ -4096,35 +4116,35 @@ Default: True</li> </div> <a class="headerlink" href="#DuckDB.Generator.length_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DuckDB.Generator.length_sql-787"><a href="#DuckDB.Generator.length_sql-787"><span class="linenos">787</span></a> <span class="k">def</span> <span class="nf">length_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Length</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="DuckDB.Generator.length_sql-788"><a href="#DuckDB.Generator.length_sql-788"><span class="linenos">788</span></a> <span class="n">arg</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> -</span><span id="DuckDB.Generator.length_sql-789"><a href="#DuckDB.Generator.length_sql-789"><span class="linenos">789</span></a> -</span><span id="DuckDB.Generator.length_sql-790"><a href="#DuckDB.Generator.length_sql-790"><span class="linenos">790</span></a> <span class="c1"># Dialects like BQ and Snowflake also accept binary values as args, so</span> -</span><span id="DuckDB.Generator.length_sql-791"><a href="#DuckDB.Generator.length_sql-791"><span class="linenos">791</span></a> <span class="c1"># DDB will attempt to infer the type or resort to case/when resolution</span> -</span><span id="DuckDB.Generator.length_sql-792"><a href="#DuckDB.Generator.length_sql-792"><span class="linenos">792</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">"binary"</span><span class="p">)</span> <span class="ow">or</span> <span class="n">arg</span><span class="o">.</span><span class="n">is_string</span><span class="p">:</span> -</span><span id="DuckDB.Generator.length_sql-793"><a href="#DuckDB.Generator.length_sql-793"><span class="linenos">793</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"LENGTH"</span><span class="p">,</span> <span class="n">arg</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DuckDB.Generator.length_sql-792"><a href="#DuckDB.Generator.length_sql-792"><span class="linenos">792</span></a> <span class="k">def</span> <span class="nf">length_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Length</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="DuckDB.Generator.length_sql-793"><a href="#DuckDB.Generator.length_sql-793"><span class="linenos">793</span></a> <span class="n">arg</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> </span><span id="DuckDB.Generator.length_sql-794"><a href="#DuckDB.Generator.length_sql-794"><span class="linenos">794</span></a> -</span><span id="DuckDB.Generator.length_sql-795"><a href="#DuckDB.Generator.length_sql-795"><span class="linenos">795</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">arg</span><span class="o">.</span><span class="n">type</span><span class="p">:</span> -</span><span id="DuckDB.Generator.length_sql-796"><a href="#DuckDB.Generator.length_sql-796"><span class="linenos">796</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.length_sql-797"><a href="#DuckDB.Generator.length_sql-797"><span class="linenos">797</span></a> -</span><span id="DuckDB.Generator.length_sql-798"><a href="#DuckDB.Generator.length_sql-798"><span class="linenos">798</span></a> <span class="n">arg</span> <span class="o">=</span> <span class="n">annotate_types</span><span class="p">(</span><span class="n">arg</span><span class="p">)</span> +</span><span id="DuckDB.Generator.length_sql-795"><a href="#DuckDB.Generator.length_sql-795"><span class="linenos">795</span></a> <span class="c1"># Dialects like BQ and Snowflake also accept binary values as args, so</span> +</span><span id="DuckDB.Generator.length_sql-796"><a href="#DuckDB.Generator.length_sql-796"><span class="linenos">796</span></a> <span class="c1"># DDB will attempt to infer the type or resort to case/when resolution</span> +</span><span id="DuckDB.Generator.length_sql-797"><a href="#DuckDB.Generator.length_sql-797"><span class="linenos">797</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">"binary"</span><span class="p">)</span> <span class="ow">or</span> <span class="n">arg</span><span class="o">.</span><span class="n">is_string</span><span class="p">:</span> +</span><span id="DuckDB.Generator.length_sql-798"><a href="#DuckDB.Generator.length_sql-798"><span class="linenos">798</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"LENGTH"</span><span class="p">,</span> <span class="n">arg</span><span class="p">)</span> </span><span id="DuckDB.Generator.length_sql-799"><a href="#DuckDB.Generator.length_sql-799"><span class="linenos">799</span></a> -</span><span id="DuckDB.Generator.length_sql-800"><a href="#DuckDB.Generator.length_sql-800"><span class="linenos">800</span></a> <span class="k">if</span> <span class="n">arg</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="o">*</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">TEXT_TYPES</span><span class="p">):</span> -</span><span id="DuckDB.Generator.length_sql-801"><a href="#DuckDB.Generator.length_sql-801"><span class="linenos">801</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"LENGTH"</span><span class="p">,</span> <span class="n">arg</span><span class="p">)</span> +</span><span id="DuckDB.Generator.length_sql-800"><a href="#DuckDB.Generator.length_sql-800"><span class="linenos">800</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">arg</span><span class="o">.</span><span class="n">type</span><span class="p">:</span> +</span><span id="DuckDB.Generator.length_sql-801"><a href="#DuckDB.Generator.length_sql-801"><span class="linenos">801</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.length_sql-802"><a href="#DuckDB.Generator.length_sql-802"><span class="linenos">802</span></a> -</span><span id="DuckDB.Generator.length_sql-803"><a href="#DuckDB.Generator.length_sql-803"><span class="linenos">803</span></a> <span class="c1"># We need these casts to make duckdb's static type checker happy</span> -</span><span id="DuckDB.Generator.length_sql-804"><a href="#DuckDB.Generator.length_sql-804"><span class="linenos">804</span></a> <span class="n">blob</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">arg</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">VARBINARY</span><span class="p">)</span> -</span><span id="DuckDB.Generator.length_sql-805"><a href="#DuckDB.Generator.length_sql-805"><span class="linenos">805</span></a> <span class="n">varchar</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">arg</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">VARCHAR</span><span class="p">)</span> -</span><span id="DuckDB.Generator.length_sql-806"><a href="#DuckDB.Generator.length_sql-806"><span class="linenos">806</span></a> -</span><span id="DuckDB.Generator.length_sql-807"><a href="#DuckDB.Generator.length_sql-807"><span class="linenos">807</span></a> <span class="n">case</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="DuckDB.Generator.length_sql-808"><a href="#DuckDB.Generator.length_sql-808"><span class="linenos">808</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">case</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"TYPEOF"</span><span class="p">,</span> <span class="n">arg</span><span class="p">))</span> -</span><span id="DuckDB.Generator.length_sql-809"><a href="#DuckDB.Generator.length_sql-809"><span class="linenos">809</span></a> <span class="o">.</span><span class="n">when</span><span class="p">(</span> -</span><span id="DuckDB.Generator.length_sql-810"><a href="#DuckDB.Generator.length_sql-810"><span class="linenos">810</span></a> <span class="s2">"'VARCHAR'"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Anonymous</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="s2">"LENGTH"</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="n">varchar</span><span class="p">])</span> -</span><span id="DuckDB.Generator.length_sql-811"><a href="#DuckDB.Generator.length_sql-811"><span class="linenos">811</span></a> <span class="p">)</span> <span class="c1"># anonymous to break length_sql recursion</span> -</span><span id="DuckDB.Generator.length_sql-812"><a href="#DuckDB.Generator.length_sql-812"><span class="linenos">812</span></a> <span class="o">.</span><span class="n">when</span><span class="p">(</span><span class="s2">"'BLOB'"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"OCTET_LENGTH"</span><span class="p">,</span> <span class="n">blob</span><span class="p">))</span> -</span><span id="DuckDB.Generator.length_sql-813"><a href="#DuckDB.Generator.length_sql-813"><span class="linenos">813</span></a> <span class="p">)</span> -</span><span id="DuckDB.Generator.length_sql-814"><a href="#DuckDB.Generator.length_sql-814"><span class="linenos">814</span></a> -</span><span id="DuckDB.Generator.length_sql-815"><a href="#DuckDB.Generator.length_sql-815"><span class="linenos">815</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">case</span><span class="p">)</span> +</span><span id="DuckDB.Generator.length_sql-803"><a href="#DuckDB.Generator.length_sql-803"><span class="linenos">803</span></a> <span class="n">arg</span> <span class="o">=</span> <span class="n">annotate_types</span><span class="p">(</span><span class="n">arg</span><span class="p">)</span> +</span><span id="DuckDB.Generator.length_sql-804"><a href="#DuckDB.Generator.length_sql-804"><span class="linenos">804</span></a> +</span><span id="DuckDB.Generator.length_sql-805"><a href="#DuckDB.Generator.length_sql-805"><span class="linenos">805</span></a> <span class="k">if</span> <span class="n">arg</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="o">*</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">TEXT_TYPES</span><span class="p">):</span> +</span><span id="DuckDB.Generator.length_sql-806"><a href="#DuckDB.Generator.length_sql-806"><span class="linenos">806</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"LENGTH"</span><span class="p">,</span> <span class="n">arg</span><span class="p">)</span> +</span><span id="DuckDB.Generator.length_sql-807"><a href="#DuckDB.Generator.length_sql-807"><span class="linenos">807</span></a> +</span><span id="DuckDB.Generator.length_sql-808"><a href="#DuckDB.Generator.length_sql-808"><span class="linenos">808</span></a> <span class="c1"># We need these casts to make duckdb's static type checker happy</span> +</span><span id="DuckDB.Generator.length_sql-809"><a href="#DuckDB.Generator.length_sql-809"><span class="linenos">809</span></a> <span class="n">blob</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">arg</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">VARBINARY</span><span class="p">)</span> +</span><span id="DuckDB.Generator.length_sql-810"><a href="#DuckDB.Generator.length_sql-810"><span class="linenos">810</span></a> <span class="n">varchar</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">arg</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">VARCHAR</span><span class="p">)</span> +</span><span id="DuckDB.Generator.length_sql-811"><a href="#DuckDB.Generator.length_sql-811"><span class="linenos">811</span></a> +</span><span id="DuckDB.Generator.length_sql-812"><a href="#DuckDB.Generator.length_sql-812"><span class="linenos">812</span></a> <span class="n">case</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="DuckDB.Generator.length_sql-813"><a href="#DuckDB.Generator.length_sql-813"><span class="linenos">813</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">case</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"TYPEOF"</span><span class="p">,</span> <span class="n">arg</span><span class="p">))</span> +</span><span id="DuckDB.Generator.length_sql-814"><a href="#DuckDB.Generator.length_sql-814"><span class="linenos">814</span></a> <span class="o">.</span><span class="n">when</span><span class="p">(</span> +</span><span id="DuckDB.Generator.length_sql-815"><a href="#DuckDB.Generator.length_sql-815"><span class="linenos">815</span></a> <span class="s2">"'VARCHAR'"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Anonymous</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="s2">"LENGTH"</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="n">varchar</span><span class="p">])</span> +</span><span id="DuckDB.Generator.length_sql-816"><a href="#DuckDB.Generator.length_sql-816"><span class="linenos">816</span></a> <span class="p">)</span> <span class="c1"># anonymous to break length_sql recursion</span> +</span><span id="DuckDB.Generator.length_sql-817"><a href="#DuckDB.Generator.length_sql-817"><span class="linenos">817</span></a> <span class="o">.</span><span class="n">when</span><span class="p">(</span><span class="s2">"'BLOB'"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"OCTET_LENGTH"</span><span class="p">,</span> <span class="n">blob</span><span class="p">))</span> +</span><span id="DuckDB.Generator.length_sql-818"><a href="#DuckDB.Generator.length_sql-818"><span class="linenos">818</span></a> <span class="p">)</span> +</span><span id="DuckDB.Generator.length_sql-819"><a href="#DuckDB.Generator.length_sql-819"><span class="linenos">819</span></a> +</span><span id="DuckDB.Generator.length_sql-820"><a href="#DuckDB.Generator.length_sql-820"><span class="linenos">820</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">case</span><span class="p">)</span> </span></pre></div> @@ -4142,20 +4162,20 @@ Default: True</li> </div> <a class="headerlink" href="#DuckDB.Generator.objectinsert_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DuckDB.Generator.objectinsert_sql-817"><a href="#DuckDB.Generator.objectinsert_sql-817"><span class="linenos">817</span></a> <span class="k">def</span> <span class="nf">objectinsert_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ObjectInsert</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="DuckDB.Generator.objectinsert_sql-818"><a href="#DuckDB.Generator.objectinsert_sql-818"><span class="linenos">818</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.objectinsert_sql-819"><a href="#DuckDB.Generator.objectinsert_sql-819"><span class="linenos">819</span></a> <span class="n">key</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"key"</span><span class="p">)</span> -</span><span id="DuckDB.Generator.objectinsert_sql-820"><a href="#DuckDB.Generator.objectinsert_sql-820"><span class="linenos">820</span></a> <span class="n">key_sql</span> <span class="o">=</span> <span class="n">key</span><span class="o">.</span><span class="n">name</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="DuckDB.Generator.objectinsert_sql-821"><a href="#DuckDB.Generator.objectinsert_sql-821"><span class="linenos">821</span></a> <span class="n">value_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">"value"</span><span class="p">)</span> -</span><span id="DuckDB.Generator.objectinsert_sql-822"><a href="#DuckDB.Generator.objectinsert_sql-822"><span class="linenos">822</span></a> -</span><span id="DuckDB.Generator.objectinsert_sql-823"><a href="#DuckDB.Generator.objectinsert_sql-823"><span class="linenos">823</span></a> <span class="n">kv_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">key_sql</span><span class="si">}</span><span class="s2"> := </span><span class="si">{</span><span class="n">value_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="DuckDB.Generator.objectinsert_sql-824"><a href="#DuckDB.Generator.objectinsert_sql-824"><span class="linenos">824</span></a> -</span><span id="DuckDB.Generator.objectinsert_sql-825"><a href="#DuckDB.Generator.objectinsert_sql-825"><span class="linenos">825</span></a> <span class="c1"># If the input struct is empty e.g. transpiling OBJECT_INSERT(OBJECT_CONSTRUCT(), key, value) from Snowflake</span> -</span><span id="DuckDB.Generator.objectinsert_sql-826"><a href="#DuckDB.Generator.objectinsert_sql-826"><span class="linenos">826</span></a> <span class="c1"># then we can generate STRUCT_PACK which will build it since STRUCT_INSERT({}, key := value) is not valid DuckDB</span> -</span><span id="DuckDB.Generator.objectinsert_sql-827"><a href="#DuckDB.Generator.objectinsert_sql-827"><span class="linenos">827</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">Struct</span><span class="p">)</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">this</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> -</span><span id="DuckDB.Generator.objectinsert_sql-828"><a href="#DuckDB.Generator.objectinsert_sql-828"><span class="linenos">828</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"STRUCT_PACK"</span><span class="p">,</span> <span class="n">kv_sql</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DuckDB.Generator.objectinsert_sql-822"><a href="#DuckDB.Generator.objectinsert_sql-822"><span class="linenos">822</span></a> <span class="k">def</span> <span class="nf">objectinsert_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ObjectInsert</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="DuckDB.Generator.objectinsert_sql-823"><a href="#DuckDB.Generator.objectinsert_sql-823"><span class="linenos">823</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.objectinsert_sql-824"><a href="#DuckDB.Generator.objectinsert_sql-824"><span class="linenos">824</span></a> <span class="n">key</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"key"</span><span class="p">)</span> +</span><span id="DuckDB.Generator.objectinsert_sql-825"><a href="#DuckDB.Generator.objectinsert_sql-825"><span class="linenos">825</span></a> <span class="n">key_sql</span> <span class="o">=</span> <span class="n">key</span><span class="o">.</span><span class="n">name</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="DuckDB.Generator.objectinsert_sql-826"><a href="#DuckDB.Generator.objectinsert_sql-826"><span class="linenos">826</span></a> <span class="n">value_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">"value"</span><span class="p">)</span> +</span><span id="DuckDB.Generator.objectinsert_sql-827"><a href="#DuckDB.Generator.objectinsert_sql-827"><span class="linenos">827</span></a> +</span><span id="DuckDB.Generator.objectinsert_sql-828"><a href="#DuckDB.Generator.objectinsert_sql-828"><span class="linenos">828</span></a> <span class="n">kv_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">key_sql</span><span class="si">}</span><span class="s2"> := </span><span class="si">{</span><span class="n">value_sql</span><span class="si">}</span><span class="s2">"</span> </span><span id="DuckDB.Generator.objectinsert_sql-829"><a href="#DuckDB.Generator.objectinsert_sql-829"><span class="linenos">829</span></a> -</span><span id="DuckDB.Generator.objectinsert_sql-830"><a href="#DuckDB.Generator.objectinsert_sql-830"><span class="linenos">830</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"STRUCT_INSERT"</span><span class="p">,</span> <span class="n">this</span><span class="p">,</span> <span class="n">kv_sql</span><span class="p">)</span> +</span><span id="DuckDB.Generator.objectinsert_sql-830"><a href="#DuckDB.Generator.objectinsert_sql-830"><span class="linenos">830</span></a> <span class="c1"># If the input struct is empty e.g. transpiling OBJECT_INSERT(OBJECT_CONSTRUCT(), key, value) from Snowflake</span> +</span><span id="DuckDB.Generator.objectinsert_sql-831"><a href="#DuckDB.Generator.objectinsert_sql-831"><span class="linenos">831</span></a> <span class="c1"># then we can generate STRUCT_PACK which will build it since STRUCT_INSERT({}, key := value) is not valid DuckDB</span> +</span><span id="DuckDB.Generator.objectinsert_sql-832"><a href="#DuckDB.Generator.objectinsert_sql-832"><span class="linenos">832</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">Struct</span><span class="p">)</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">this</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> +</span><span id="DuckDB.Generator.objectinsert_sql-833"><a href="#DuckDB.Generator.objectinsert_sql-833"><span class="linenos">833</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"STRUCT_PACK"</span><span class="p">,</span> <span class="n">kv_sql</span><span class="p">)</span> +</span><span id="DuckDB.Generator.objectinsert_sql-834"><a href="#DuckDB.Generator.objectinsert_sql-834"><span class="linenos">834</span></a> +</span><span id="DuckDB.Generator.objectinsert_sql-835"><a href="#DuckDB.Generator.objectinsert_sql-835"><span class="linenos">835</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"STRUCT_INSERT"</span><span class="p">,</span> <span class="n">this</span><span class="p">,</span> <span class="n">kv_sql</span><span class="p">)</span> </span></pre></div> @@ -4494,7 +4514,6 @@ Default: True</li> <dd id="DuckDB.Generator.bitwisexor_sql" class="function"><a href="../generator.html#Generator.bitwisexor_sql">bitwisexor_sql</a></dd> <dd id="DuckDB.Generator.cast_sql" class="function"><a href="../generator.html#Generator.cast_sql">cast_sql</a></dd> <dd id="DuckDB.Generator.currentdate_sql" class="function"><a href="../generator.html#Generator.currentdate_sql">currentdate_sql</a></dd> - <dd id="DuckDB.Generator.currenttimestamp_sql" class="function"><a href="../generator.html#Generator.currenttimestamp_sql">currenttimestamp_sql</a></dd> <dd id="DuckDB.Generator.collate_sql" class="function"><a href="../generator.html#Generator.collate_sql">collate_sql</a></dd> <dd id="DuckDB.Generator.command_sql" class="function"><a href="../generator.html#Generator.command_sql">command_sql</a></dd> <dd id="DuckDB.Generator.comment_sql" class="function"><a href="../generator.html#Generator.comment_sql">comment_sql</a></dd> @@ -4608,6 +4627,7 @@ Default: True</li> <dd id="DuckDB.Generator.rand_sql" class="function"><a href="../generator.html#Generator.rand_sql">rand_sql</a></dd> <dd id="DuckDB.Generator.changes_sql" class="function"><a href="../generator.html#Generator.changes_sql">changes_sql</a></dd> <dd id="DuckDB.Generator.pad_sql" class="function"><a href="../generator.html#Generator.pad_sql">pad_sql</a></dd> + <dd id="DuckDB.Generator.summarize_sql" class="function"><a href="../generator.html#Generator.summarize_sql">summarize_sql</a></dd> </div> </dl> |